This version is outdated by a newer approved version.DiffThis version (2016/07/05 12:49) is a draft.
Approvals: 0/1

This is an old revision of the document!


           PROGRAM testpapi
           include 'f77papi.h'
           integer check, evntst
           integer*8 t0, t1, c0, c1, value
     
           check = PAPI_NULL
     C
     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
     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
     C     PAPI Specify a Particular Target Event to Analyze
     C       PAPI_TOT_CYC         Total cycles executed         
     C       PAPI_FP_OPS          Floating point operations executed
     C       PAPI_L1_DCM          Level 1 data cache misses          
     C       PAPI_L2_DCM          Level 2 data cache misses          
     C       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
     C     PAPI Time Estimators Initialization                
     C        
           call PAPIF_get_real_usec(t0)
           call PAPIF_get_real_cyc(c0)
     C
     C     PAPI Counting Start                                
     C        
           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
     C     *** Here follows the original code section to be analyzed ***
     C
     
     C      
     C     PAPI Counting Stop                                 
     C        
           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
     C      
     C     PAPI Time Estimators Stop                          
     C        
           call PAPIF_get_real_usec(t1)
           call PAPIF_get_real_cyc(c1)
     C      
     C     PAPI Results                                       
     C        
           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
     C      
     C     PAPI Free Event Set                                
     C        
           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
     C      
     C     PAPI Finalize                                      
     C        
           call PAPIF_shutdown(check)
           if (check.ne.PAPI_OK) then
              write(6,*) 'PAPI finalize failed !'
              write(6,*) '07 check:', check, PAPI_OK
              stop
           endif

d

<code>

    PROGRAM testpapi
    include 'f77papi.h'
    integer check, evntst
    integer*8 t0, t1, c0, c1, value
    check = PAPI_NULL

C 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 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 C PAPI Specify a Particular Target Event to Analyze C PAPI_TOT_CYC Total cycles executed C PAPI_FP_OPS Floating point operations executed C PAPI_L1_DCM Level 1 data cache misses C PAPI_L2_DCM Level 2 data cache misses C for other events see C /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 C PAPI Time Estimators Initialization C

    call PAPIF_get_real_usec(t0)
    call PAPIF_get_real_cyc(c0)

C C PAPI Counting Start C

    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 C * Here follows the original code section to be analyzed * C

C C PAPI Counting Stop C

    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

C C PAPI Time Estimators Stop C

    call PAPIF_get_real_usec(t1)
    call PAPIF_get_real_cyc(c1)

C C PAPI Results C

    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

C C PAPI Free Event Set C

    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

C C PAPI Finalize C

    call PAPIF_shutdown(check)
    if (check.ne.PAPI_OK) then
       write(6,*) 'PAPI finalize failed !'
       write(6,*) '07 check:', check, PAPI_OK
       stop
    endif
    END PROGRAM
  • doku/papi_ll_fortran.1467722943.txt.gz
  • Last modified: 2016/07/05 12:49
  • by ir