Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
doku:papi [2016/06/15 13:23] shdoku:papi [2016/06/16 14:01] sh
Line 8: Line 8:
  
 ==== Usage of papi: ==== ==== Usage of papi: ====
-The user will have to modify the source code and insert ''papi'' calls (see below). Invocation and usage is then as simple as+The user will have to modify the source code and insert ''papi'' calls (see below). Invocation and usage is then as simple as,
  
-    
    module purge    module purge
    module load papi/5.4.3    module load papi/5.4.3
-   gcc my_program.c -lpapi    ( gfortran my_program.f -lpapi )+   gcc my_program.c -lpapi    
    ./a.out    ./a.out
        
 +or for Fortran users,
 +
 +   module purge
 +   module load papi/5.4.3
 +   gfortran  my_program.f -I/opt/sw/x86_64/glibc-2.12/ivybridge-ep/papi/5.4.3/gnu-4.4.7/include -lpapi
 +   ./a.out
 +
        
 ==== Interfacing with papi : ==== ==== Interfacing with papi : ====
Line 83: Line 89:
    PAPI_shutdown();    PAPI_shutdown();
        
-   +or similarly for Fortran users,    
 + 
 +             include 'f77papi.h' 
 +             integer check, evntst 
 +             integer*8 t0, t1, c0, c1, value 
 +        
 +             check = PAPI_NULL 
 +       C 
 +           PAPI Initialization 
 +       C 
 +             check = PAPI_VER_CURRENT 
 +             call PAPIF_library_init(check) 
 +             if (check.ne.PAPI_VER_CURRENT) then 
 +                write(6,*) 'PAPI init error' 
 +                write(6,*) '00 check:', check, PAPI_VER_CURRENT 
 +                stop 
 +             endif 
 +       C 
 +           PAPI Event Set Creation 
 +       C 
 +             evntst = PAPI_NULL 
 +             call PAPIF_create_eventset(evntst, check) 
 +             if (check.ne.PAPI_OK) then 
 +                write(6,*) 'PAPI event set creation error' 
 +                write(6,*) '01 check:', check, PAPI_OK 
 +                stop 
 +             endif 
 +       C 
 +           PAPI Specify a Particular Target Event to Analyze 
 +             PAPI_TOT_CYC         Total cycles executed          
 +             PAPI_FP_OPS          Floating point operations executed 
 +             PAPI_L1_DCM          Level 1 data cache misses           
 +             PAPI_L2_DCM          Level 2 data cache misses           
 +             for other events see /opt/sw/x86_64/glibc-2.12/ivybridge-ep/papi/5.4.3/gnu-4.4.7/include/papiStdEventDefs.h 
 +       C 
 +             call PAPIF_add_event(evntst, PAPI_FP_OPS, check) 
 +             if (check.ne.PAPI_OK) then 
 +                write(6,*) 'PAPI event set adding error' 
 +                write(6,*) '02 check:', check, PAPI_OK 
 +                stop 
 +             endif 
 +       C 
 +           PAPI Time Estimators Initialization                 
 +               
 +             call PAPIF_get_real_usec(t0) 
 +             call PAPIF_get_real_cyc(c0) 
 +       C 
 +           PAPI Counting Start                                 
 +               
 +             call PAPIF_start(evntst, check) 
 +             if (check.ne.PAPI_OK) then 
 +                write(6,*) 'PAPI start error !' 
 +                write(6,*) '03 check:', check, PAPI_OK 
 +                stop 
 +             endif 
 +        
 +       C 
 +           *** Here follows the original code section to be analyzed *** 
 +       C 
 +        
 +             
 +           PAPI Counting Stop                                  
 +               
 +             call PAPIF_stop(evntst, value, check) 
 +             if (check.ne.PAPI_OK) then 
 +                write(6,*) 'PAPI stop error !' 
 +                write(6,*) '04 check:', check, PAPI_OK 
 +                stop 
 +             endif 
 +             
 +           PAPI Time Estimators Stop                           
 +               
 +             call PAPIF_get_real_usec(t1) 
 +             call PAPIF_get_real_cyc(c1) 
 +             
 +           PAPI Results                                        
 +               
 +             write(6,'(a17,8x,i20)') 'PAPI event count ', value 
 +             write(6,'(a25,i20)') 'PAPI time passed in usec ', t1 - t0 
 +             write(6,'(a19,6x,i20)') 'PAPI cycles passed ', c1 - c0 
 +             
 +           PAPI Free Event Set                                 
 +               
 +             call PAPIF_cleanup_eventset(evntst, check) 
 +             if (check.ne.PAPI_OK) then 
 +                write(6,*) 'PAPI event set cleanup error !' 
 +                write(6,*) '05 check:', check, PAPI_OK 
 +                stop 
 +             endif 
 +             call PAPIF_destroy_eventset(evntst, check) 
 +             if (check.ne.PAPI_OK) then 
 +                write(6,*) 'PAPI event set destruction error !' 
 +                write(6,*) '06 check:', check, PAPI_OK 
 +                stop 
 +             endif 
 +             
 +           PAPI Finalize                                       
 +               
 +             call PAPIF_shutdown(check) 
 +             if (check.ne.PAPI_OK) then 
 +                write(6,*) 'PAPI finalize failed !' 
 +                write(6,*) '07 check:', check, PAPI_OK 
 +                stop 
 +             endif 
  
 + 
 ==== Practical tips: ==== ==== Practical tips: ====
   * A quick overview of supported events and corresponding ''papi'' variables for a particular type of CPU is obtained from executing command ''papi_avail''   * A quick overview of supported events and corresponding ''papi'' variables for a particular type of CPU is obtained from executing command ''papi_avail''
  • doku/papi.txt
  • Last modified: 2016/07/06 12:28
  • by ir