Translations:OpenACC Tutorial - Adding directives/4/en: Difference between revisions

Jump to navigation Jump to search
Importing a new version from external source
(Importing a new version from external source)
(Importing a new version from external source)
 
Line 1: Line 1:
== OpenACC directives ==
== OpenACC directives ==
OpenACC directives are much like OpenMP directives. They take the form of <tt>pragma</tt> in C/C++, and comments in Fortran. There are several advantages to using directives. First, since it involves very minor modifications to the code, changes can be done ''incrementally'', one <tt>pragma</tt> at a time. This is especially useful for debugging purpose, since making a single change at a time allows one to quickly identify which change created a bug. Second, OpenACC support can be disabled at compile time. When OpenACC support is disabled, the <tt>pragma</tt> are considered comments, and ignored by the compiler. This means that a single source code can be used to compile both an accelerated version and a normal version. Third, since all of the offloading work is done by the compiler, the same code can be compiled for various accelerator types: GPUs, MIC (Xeon Phi) or CPUs. It also means that a new generation of devices only requires one to update the compiler, not to change the code.
OpenACC directives are much like [[OpenMP]] directives.
They take the form of <tt>pragma</tt> statements in C/C++, and comments in Fortran.
There are several advantages to using directives:
* First, since it involves very minor modifications to the code, changes can be done ''incrementally'', one <tt>pragma</tt> at a time. This is especially useful for debugging purpose, since making a single change at a time allows one to quickly identify which change created a bug.
* Second, OpenACC support can be disabled at compile time. When OpenACC support is disabled, the <tt>pragma</tt> are considered comments, and ignored by the compiler. This means that a single source code can be used to compile both an accelerated version and a normal version.
* Third, since all of the offloading work is done by the compiler, the same code can be compiled for various accelerator types: GPUs or SIMD instructions on CPUs. It also means that a new generation of devices only requires one to update the compiler, not to change the code.
38,760

edits

Navigation menu