swapping device pointers in accelerator(or data) region

Hi,
Is there any way to swap device pointers when using the accelerator framework? I would like to do something like this:


int* grid;
int* grid2;

#pragma acc data region copy(grid[n]) local(grid2[n])
{
    #pragma acc region
    {
         ...loops and stuff...

         int* tmp = grid;
         grid = grid2;
         grid2 = tmp;  
    }
}

Thanks!

Hi Adam,

Unfortunately we don’t support pointer assignment within accelerator regions. The reason is that ‘grid’ isn’t a pointer in this context. Rather it’s a structured memory block and includes information such as the type and bounds of the arrays. I’ve put in a feature request (TPR#17700) to see if there is any way we can remove this restriction.

Thanks,
Mat

I’ve been looking at some old issue reports and was going to close this one.

Since this post, we do support pointer manipulation within OpenACC compute regions. However, this particular piece of code is illegal per the OpenACC Standard since the association of a host and device variable is not allowed to change within the compute region.

  • Mat