OpenACC: Difference between revisions

Jump to navigation Jump to search
Removed incomplete but still duplicated information
No edit summary
(Removed incomplete but still duplicated information)
Line 4: Line 4:


= OpenACC compiler instructions =
= OpenACC compiler instructions =
Similar to [[OpenMP]], OpenACC can convert a for-loop into parallel code that would run on an accelerator. This can be achieved with compiler instructions <code>#pragma acc ...</code> before a for-loop.
Similar to [[OpenMP]], OpenACC can convert a for-loop into parallel code that would run on an accelerator. This can be achieved with compiler instructions <code>#pragma acc ...</code> before a for-loop. All <code>pragma</code> directives are described in the [https://www.openacc.org/specification OpenACC specification].
 
== <code>pragma acc parallel</code> ==
This will start the following structured block of code in parallel execution on the accelerator.
 
Optional clauses:
* <code>vector_length(size)</code>: determines the vector length to use for vector or SIMD operations.
** For example, <code>size</code> can be: 256, 512
 
== <code>pragma acc loop</code> ==
The following for-loop will be converted for an execution on the accelerator.
 
Optional clauses:
* <code>reduction(op:variable)</code>: the loop is doing a reduction in a variable defined outside of the loop. For each thread in parallel, a private version of that variable will be used.
** Typical operators: <code>+</code> (sum), <code>*</code> (product)


= Code examples =
= Code examples =
cc_staff
782

edits

Navigation menu