I tried to parallelize the nested loop using OpenMP, but I am not sure if this is the correct way to do that. Here is the part of the code having nested loops. This is just a generic code. I am giving noofrecords as 50k, it takes a lot of time even after parallelization. Can someone suggest any better idea to parallelize the code. I am just parallelizing the outer loop in the below code.
int ctd=0;
#pragma omp parallel for default(none), private(j,k,l), shared(A,B,C,D,ctd)
for(int j=0; j <noofrecords; j++)
{
for( int k=0; k<noofrecords; k++)
{
for( int l=0; l<noofrecords; l++)
{
if(condition)
{
D[ctd].a1=A[i].a1;
ctd++;
}}}}
cdt. See stackoverflow.com/questions/43057426/…ctdis a shared variable, your algorithm is fundamentally sequential. There's not going to be any way to parallelize this effectively if condition holds true many times. Moreover, if you later need to know exactly which index ofDcorresponded to which record, then there would be no way to parallelize this algorithm at all.Darray.