Hi,
I am running the following Openacc C code with the latest PGI compiler.
########################################
void integrate_n_rk4_phasedifferences(const unsigned networkSize, unsigned iter, double *output, double *test) ;
void sweep(int max);
int main(int argc, char argv[]) {
int max;
sweep(1000);
}
void sweep(int max){
int networkSize = 4, l, m;
double test[2510];
double output[8];
#pragma acc parallel loop independent ,collapse(1),
private(output),
copy(test[0:25*10])
for (l=0;l<max;l++){
integrate_n_rk4_phasedifferences(networkSize, l, output, test);
if(max-l-1<25){
for(m=1;m<9;m++){
test[(max-l-1)*10+m]=output[m];
}
test[(max-l-1)*10+9]=l;
test[(max-l-1)*10+0]=l;
}
}
//debug kernel
printf(“\ndebug kernel begins\n”);
for(l=0;l<25;l++){
for(m=0;m<10;m++)printf(“%lf “,test[l*10+m]);
printf(”\n”);
}
printf(“debug kernel ends\n”);
}
#pragma acc routine seq
void integrate_n_rk4_phasedifferences(const unsigned networkSize, unsigned iter, double *output, double *test) {
#pragma acc data deviceptr(output)
{
unsigned i, point_dimension = networkSize*2;
#pragma acc loop seq private(point_dimension)
for(i=1;i<point_dimension+1;i++){
//for(i=1;i<9;i++){
output_=i+(double)iter/1000000;
}
output[8]=point_dimension;
}
}
###########################################
As you can see in the function ‘integrate…’, in the for loop, when a constant value ‘9’ is used in loop condition, the results are correct in the output, whereas when using a variable ‘point_dimension+1’ for the same loop condition, the results are inconsistent and inaccurate.
This is the right output with constant ‘9’ : (first 3 lines )
999.000000 1.000999 2.000999 3.000999 4.000999 5.000999 6.000999 7.000999 8.000000 999.000000
998.000000 1.000998 2.000998 3.000998 4.000998 5.000998 6.000998 7.000998 8.000000 998.000000
997.000000 1.000997 2.000997 3.000997 4.000997 5.000997 6.000997 7.000997 8.000000 997.000000
Inaccurate output with variable ‘point_dimension + 1’ resulting in the same value ‘9’ :
999.000000 1.000996 2.000996 3.000996 4.000996 5.000996 6.000996 7.000996 8.000000 999.000000
998.000000 1.000993 2.000993 3.000993 4.000993 5.000993 6.000993 7.000993 8.000000 998.000000
997.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 8.000000 997.000000
What is strange is that even in this case, when I print the value of ‘point_dimension’ using output[8], itz value is the right value ‘8’.
It seems that a for loop called inside a sequential routine has inaccurate behavior without constant condition check.
Any help is greatly appreciated.
Thanks,
Krishna._