How to reset arrays fast with OpenACC

In my code I need to reset some arrays to 0:

do j = 1, 128
do i = 1, 128
p = 0.0d0
enddo
enddo

What’s the best way to run this type of codelets on GPU using OpenACC?


Thanks,

Ping

It depends on the size of your arrays and if you need to copy them to the device. If the arrays are small, it might better to initialize them on the host and then copy them over. Larger ones, may better to initialize in an openACC compute region. You’ll need to experiment at what point it costs more it launch and execute the kernel than it cost to copy the initialize data.

  • Mat