I want to create a 1D array of size (10^7) and want to populate it randomly. Is it possible to create many 10 arrays each of size 10^6, populate them randomly and later merge them into one array using OpenMP?
std::random_device rd{};
std::mt19937 rng{rd()};
std::bernoulli_distribution distribution(p);
int array_size = 10000000, N = 50;
array = new uint64_t[array_size];
#pragma omp parallel
{
#pragma omp parallel for
for(int i = 0; i < (array_size); i++){
uint64_t rn = 0;
for(int j = 0; j < N; j++){
rn = ((rn<<1)+(distribution(rng)?1:0));
}
array[i] = rn;
}
}
Aucun commentaire:
Enregistrer un commentaire