Community
cancel
Showing results for 
Search instead for 
Did you mean: 
chbq
Beginner
21 Views

My problem with workqueuing model , please do me a favor

hi ,I want to parallel do-while codes with the workqueuing modol. soI writen a simple program for testing, however,the following codes does not get the right result as the serial ones,can you tell me why? thank you!

float ParallelTest(float *Array)
{
int pjn,step;
float sum=0;
pjn=1000;
#pragma intel omp parallel taskq shared(pjn,Array) reduction(+:sum)
{
do
{
#pragma intel omp task captureprivate(pjn)
{
for(step=0;step{
sum+=Array[step]/(10*SIZE*SIZE);
// I add these codes for increasing calculation time
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
}
}
pjn=pjn/2;
}while(pjn!=1);
}
return sum;
}

the serial codes is :

float ParallelTest(float *Array)
{
int pjn,step;
float sum=0;
pjn=1000;
do
{
for(step=0;step{
sum+=Array[step]/(10*SIZE*SIZE);
// I add these codes for increasing calculation time
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
sum=sum*10/10*20/20*30/30;
}
pjn=pjn/2;
}while(pjn!=1);
return sum;
}

0 Kudos
0 Replies