Compiler error

Hello,

I’m a new user of openacc an pgi compilers and I’m following your tutorials of youtube (Introduction to Parallel Programming with OpenACC - Part 1 - YouTube)

But I’m encountering an error. Compiling for multicore works fine. Although, when i compile for a tesla GPU, like this:

make jsolvec.exe OPT="-ta:tesla:cc60 -Minfo=accel"

I get the following errors:

PGCC-S-0155-Compiler failed to translate accelerator region (see -Minfo messages): Could not find allocated-variable index for symbol (jsolvec.cpp: 129)

The code that it’s generating the problem is this:

while ((residual > TOLERANCE) && (iters < max_iters)) {
    ++iters;
    // swap input and output vectors
    xtmp = xnew;
    xnew = xold;
    xold = xtmp;
	#pragma acc parallel loop  
    for (i = 0; i < nsize; ++i) { 
      TYPE rsum = (TYPE)0;
	#pragma acc loop reduction(+:residual)
      for (j = 0; j < nsize; ++j) {
        if (i != j) rsum += A[i*nsize + j] * xold[j];
      }
      xnew[i] = (b[i] - rsum) / A[i*nsize + i];
    }
}

where line 129 is the first for loop.

Why is this happening?

Hi Caap,

Typically when I see this error is because the data structure being used in the device code is complex so the compiler is having trouble automatically creating the data directives.

Try adding a data region before the while loop and then use “present” clauses on the parallel region. If this is in a class and the variables are class data members, then the this pointer needs to be copied as well.

Also, did you mean to use “residual” in the reduction clause? It looks like it should be “rsum”.


#pragma acc data copyin(this[0:0], A[0:size]), copy(xnew[0:size],xold[0:size])
{
while ((residual > TOLERANCE) && (iters < max_iters)) { 
    ++iters; 
    // swap input and output vectors 
    xtmp = xnew; 
    xnew = xold; 
    xold = xtmp; 
   #pragma acc parallel loop  present(this,xnew,xold,A)
    for (i = 0; i < nsize; ++i) { 
      TYPE rsum = (TYPE)0; 
   #pragma acc loop reduction(+:rsum) 
      for (j = 0; j < nsize; ++j) { 
        if (i != j) rsum += A[i*nsize + j] * xold[j]; 
      } 
      xnew[i] = (b[i] - rsum) / A[i*nsize + i]; 
    } 
}
}// End OpenACC Data region

-Mat

Thanks for the help Mat, it works fine :)