OpenACC Tutorial - Profiling: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 152: Line 152:
pgc++ CXXFLAGS=-fast -Minfo=all,intensity,ccff LDFLAGS=-fast main.o -o cg.x -fast
pgc++ CXXFLAGS=-fast -Minfo=all,intensity,ccff LDFLAGS=-fast main.o -o cg.x -fast
}}
}}
== Computational Intensity  ==
Computational Intensity of a loop is a measure of how much work is being done compared to memory operations.
'''Computation Intensity = Compute Operations / Memory Operations'''
Computational Intensity of 1.0 or greater is often a clue that something might run well on a GPU.
== Understanding the code  ==
Lets look more closely at the following code:
<syntaxhighlight lang="cpp" line highlight="1,5,10,12">
for(int i=0;i<num_rows;i++) {
  double sum=0;
  int row_start=row_offsets[i];
  int row_end=row_offsets[i+1];
  for(int j=row_start; j<row_end;j++) {
    unsigned int Acol=cols[j];
    double Acoef=Acoefs[j];
    double xcoef=xcoefs[Acol];
    sum+=Acoef*xcoef;
  }
  ycoefs[i]=sum;
}
</syntaxhighlight>
Given the code above, we search for data dependencies:
* Does one loop iteration affect other loop iterations?
* Do loop iterations read from and write to different places in the same array?
* Is sum a data dependency? No, it’s a reduction.
Bureaucrats, cc_docs_admin, cc_staff
337

edits