Search code examples
c++pragmaopenacc

Should OpenACC pragmas or runtime routines be preferred?


OpenACC has some pragmas and runtime routines, which can be used to basically achieve the same thing.

For example, there is #pragma acc wait and acc_wait() or #pragma acc update [...] and acc_update_[...]().

I started to mostly use the runtime routines in my C++ code.

Is there a difference? Should I prefer one over the other or is it just a matter of style and personal preference?


Solution

  • In general, the pragma's are preferred since they will be ignored by other compilers and when compiling without OpenACC enabled. The runtime API calls would need to be guarded by a macro, like "#ifdef _OPENACC" to maintain portability.

    Though, if you don't mind adding the macro guards or loosing portability, then it's mostly a matter of style. Functionally, they are equivalent.