samedi 13 juillet 2019

How to parallelize properly the construction of a random array in Julia?

I was reading the documentation for parallel computing on Julia, however it is not enough clear to me how to parallelize properly the construction of a random array.

A have a function that depends on a random variable with uniform distribution on [0,1], and after a for loop that construct, index by index, a huge vector (of the order of 10*2^24 elements or bigger), then I want to parallelize the construction of this vector to speed-up the process, the problem is that this is not so easy because I dont want to repeat sequences of random numbers.

An example

function my_random_vector(n,m=24)
  arr = zeros(2^m)
  for i in 1:2^m
     arr[i] = my_random_function(n)
  end
  return arr
end

where my_random_function is a function of rand(), where n is just some parameter (maybe the number of independent samples to sum, or a maximum, or something else).

Can someone show me how I can parallelize correctly the above construction of a random vector?


There is a non-published package like this, however it is five years old and Im not so sure of it correctness about the parallel computing of random arrays.




Aucun commentaire:

Enregistrer un commentaire