domainslib icon indicating copy to clipboard operation
domainslib copied to clipboard

Add support for parallel array initialisation

Open kayceesrk opened this issue 5 years ago • 3 comments

Array initialisation is likely to be the source of bottlenecks in parallel workloads. Array initialisation for arbitrary typed elements needs to be sequential since the elements need to be initialised to a sensible value before GC gets to see it. However, for primitive types, int and float, one can allow parallel initialisation. OCaml supports Array.create_float, which returns uninitialised array, which can then be initialised in parallel. One can also safely return an uninitialized integer array by

let create_int : int -> int array = Obj.magic (Array.create_float)

Once the array is created, it can then be initialised in parallel.

kayceesrk avatar Apr 23 '20 07:04 kayceesrk

@sudha247 you might be interested implementing this.

kayceesrk avatar Apr 23 '20 09:04 kayceesrk

Some work in progress to support this upstream: https://github.com/ocaml/ocaml/pull/9513

kayceesrk avatar May 01 '20 05:05 kayceesrk

Better way to implement this thanks to @stedolan https://gist.github.com/stedolan/f0cb0f5ab24f283d398e48763db1ae62

kayceesrk avatar May 19 '20 11:05 kayceesrk