0
votes

I'm trying to parallelize this loop but I'm having a problem with the function fRSolver (&sw, ts->cmax);

#pragma acc parallel loop collapse(2) present(d, sw, ts)
for (k = KBEG; k <= KEND; k++){
for (j = JBEG; j <= JEND; j++){

     .
     .
     .
     #pragma acc routine(fRSolver) vector
     d->fRSolver (&sw, ts->cmax);
}}

I get this error:

139, Accelerator region ignored
141, Accelerator restriction: loop contains unsupported statement type
175, Accelerator restriction: unsupported statement type: opcode=JSRA

d is a type D variable:

typedef struct D_{
  .
  .
  .
  void (*fRSolver)  (const Sw *, double *);
}D;

fRSolver is a pointer to a function void HSolver (const Sw *sw, double *cmax)

Is there a way I can accelerate this loop without changing the way the function HSolver is called?

1

1 Answers

0
votes

Is there a way I can accelerate this loop without changing the way the function HSolver is called?

No, sorry. Function pointers and indirect function calls are not supported within device code. This requires late binding (i.e. the function resolution is done at runtime) and we currently don't have a way on the device to resolve the functions address. Same issue occurs with C++ virtual functions and Fortran type bound procedures.

It's definitely on our list of things we'd like to support, and hopefully will at some point, but thus far has proven to be a major challenge. You need to modify the code to have fRSolver be a direct call, resolved at link time.