OpenACC Tutorial - Profiling: Difference between revisions

Jump to navigation Jump to search
More information for the analysis
(Interpretation of Intensity)
(More information for the analysis)
Line 287: Line 287:


== Understanding the code  == <!--T:22-->
== Understanding the code  == <!--T:22-->
Let's look closely at the following code from <code>matrix_functions.h</code>:
Let's look closely at the main loop in the
[https://github.com/calculquebec/cq-formation-openacc/blob/main/cpp/matrix_functions.h#L29 <code>matvec()</code> function implemented in <code>matrix_functions.h</code>]:
</translate>
</translate>
<syntaxhighlight lang="cpp" line highlight="1,5,10,12">
<syntaxhighlight lang="cpp" line highlight="1,5,10,12">
Line 307: Line 308:
Given the code above, we search for data dependencies:
Given the code above, we search for data dependencies:
* Does one loop iteration affect other loop iterations?
* Does one loop iteration affect other loop iterations?
* Do loop iterations read from and write to different places in the same array?
** For example, when generating the '''[https://en.wikipedia.org/wiki/Fibonacci_number Fibonacci sequence]''', each new value depends on the previous two values. Therefore, efficient parallelism is very difficult to implement, if not impossible.
* Is sum a data dependency? No, it’s a reduction.
* Is the accumulation of values in <code>sum</code> a data dependency?
** No, it’s a '''[https://en.wikipedia.org/wiki/Reduction_operator reduction]'''! And modern compilers are good at optimizing such reductions.
* Do loop iterations read from and write to the same array, such that written values are used or overwritten in other iterations?
** Fortunately, that does not happen in the above code.


<!--T:25-->
<!--T:25-->
cc_staff
782

edits

Navigation menu