Initialize global variables with OpenACC pragma?

Hello,

I wonder, is there any pragma or API which helps to initialize global variables to a particular value, for example, 0. I know acc_malloc and create(Y[0:n][0:m]) help us allocate global variables only. I think this would help us reduce the data movement from host to device memory. For some output variables, we create in global memory, initialize to zero, perform some computation and copyout to host memory.

Thank you,
Regards,
Minh

Hi Minh,

I wonder, is there any pragma or API which helps to initialize global variables to a particular value, for example, 0.

No, sorry. You need to put this initialization in a loop with an accelerator compute region.

Though, I do have an open feature request (TPR#18614) asking that the compiler perform idiom recognition on these types of loops and replace them with an optimized memset kernel. I’ll add your request to this report.

Thanks,
Mat