OpenACC Tutorial - Adding directives: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 81: Line 81:


<translate>
<translate>
== The <tt>kernels</tt> directive ==
The <tt>kernels</tt> directive is what we call a ''descriptive'' directive. It is used to tell the compiler that the programmer thinks this region can be made parallel. At this point, the compiler is free to do whatever it wants with this information. Typically, it will
# Analyze the code to try to identify parallelism
# If found, identify which data must be transferred and when
# Create a kernel
# Offload the kernel to the GPU
One example of this directive is the following code:
<syntaxhighlight lang="cpp" line>
#pragma acc kernels
{
for (int i=0; i<N; i++)
{
  C[i] = A[i] + B[i];
}
}
</syntaxhighlight>
[[OpenACC Tutorial|Back to the lesson plan]]
[[OpenACC Tutorial|Back to the lesson plan]]
</translate>
</translate>
Bureaucrats, cc_docs_admin, cc_staff, rsnt_translations
2,837

edits

Navigation menu