Parallel function calls

Hello. I have the following code:

for(i=0;i<N;i++){
           function(i,B);
    }

where function (i,B) is this:

void function(i,B){
         for(j=0;j<N;j++){
         //Do calculations on B
   }
}

I want to make it parrallel using OpenAcc. Is making the function parallel alone is one thing. Is it possible to have parallel calls of the fuction?

Yes. You can do something like the following to accelerate the outer loop across the gangs and the loop within “function” across the vectors.

#pragma acc routine vector
void function(i,B){ 
#pragma acc loop vector
         for(j=0;j<N;j++){ 
         //Do calculations on B 
...

#pragma acc parallel loop gang
for(i=0;i<N;i++){ 
           function(i,B); 
    }
  • Mat