Any strategy can make the sharing data is valid among class

Hi all,
I have a double loop want to parallel. The first loop is in main function. The inner loop have a function which belongs to another class. And I copyin the data to GPU in the main function before the first loop. But it is can not work, the function belonged to another class can not found the data I transfred to GPU. How to solve this problem? Any strategy can make the sharing data is valid among classes?

Thanks a lot.

Hi xiongxa,

But it is can not work, the function belonged to another class can not found the data I transfred to GPU.

Why not? You would just need to copy the second class to the GPU and possibly decorate the class method with the “acc routine” directive.

Worst case, you can compile with CUDA Unified Memory (-ta=tesla:managed) to have the CUDA runtime handle the dynamic data for you. The caveat being that UM only works with dynamic data so if your class objects are static, then you still need to put them in an OpenACC data region. Though, any dynamic data would be managed.

If you can provide a reproducing example code, hopefully I can show you how to make it work.

-Mat

Hi Mat,

Thanks a lot. We solved the problem with ‘declare directive’ to create a longer lifetime varible in the device and assign the value from host. Hope this can help others who run into the same problem.

xi’an