I am trying to overload a simple parenthesis in the following class
class MyClass{
private:
double *P;
// some code to allocate required variables on the device on the device
#pragma acc routine
public:
double &operator()( int i, int j, int k );
}
// constructor
MyClass::MyClass( int n )
{
N = n;
P=new double[N*N*N];
for(int i=0;i<N*N*N;i++)
{
P[i]=0.0;
}
#pragma acc enter data create(this[0:1])
#pragma acc enter data create(P[0:N*N*N])
#pragma acc update device(this)
}
#pragma acc routine
double& MyClass::operator()(int i, int j,int k)
{
// some assertion to catch bugs
//
return P[i+N*j+N*N*k];
}
int main()
{
MyClass P1;
// using a very simple assignment
#pragma acc kernels
#pragma acc loop
for ( int i = 0; i < N; i++ )
{
#pragma acc loop
for ( int j = 0; j < N; j++ )
{
#pragma acc loop
for ( int k = 0; k < N; k++ )
{
P1( i, j, k )=2.0 ;
}
}
}
}
// the compiler errors : 238, Generating implicit copy(P1) 244, Complex loop carried dependence of prevents parallelization Accelerator scalar kernel generated Accelerator kernel generated Generating Tesla code 244, #pragma acc loop seq 247, #pragma acc loop seq 250, #pragma acc loop seq 247, Complex loop carried dependence of prevents parallelization 250, Complex loop carried dependence of prevents parallelization
Is passing a reference has anything to do with this?