I'm writing a parallel program using open mp in which I generate a matrix of random floating point numbers and then do a number of calculations on it. I currently want to make the step where I generate the matrix run in parallel, but I have the problem that the rand() function was not meant to run concurrently. I don't want to use locks to provide mutex on rand because this is the only thing being done in the loop and it would probably just be more efficient to run it sequentially. Is there any way to do this step efficiently in parallel?
Here if the current code for this part (with out mutex on rand);
#pragma omp parallel default(private)
{
int i= omp_get_thread_num();
for(int j=0; j<cols; j++)
matrix[i][j]= rand()%1000 + (float)(rand()%100)/(float)(rand()%1000);
}