PAPI API を使用してパフォーマンス カウンター値を読み取る単純なプログラムを fortran で作成しています。すべての API (PAPIF_start、PAPIF_stop など) はすべて正しく機能します (つまり、PAPI_OK を返します)。ただし、PAPIF_stop が読み取る値は常に 0 です。BG/Q で別のプロファイリング ソフトウェアを試して、これらの値が 0 にならないようにしました。これは、Fortran コードを作成する初めての試みです。したがって、私には明らかではないFortranの問題である可能性が非常に高いです。どんな助けにも感謝します。ありがとう!--DE
c-----------------------------------------------------------------------
subroutine papi_add_events(event_set)
integer, intent(inout) :: event_set
include 'f77papi.h'
c create the eventset
integer check
integer*8 event_code
event_set = PAPI_NULL
call PAPIF_create_eventset(event_set, check)
if (check .ne. PAPI_OK) then
print *, 'Error in subroutine PAPIF_create_eventset'
call abort
end if
!event_code = PAPI_L1_DCM ! Total L1 Data Cache misses
call PAPIF_event_name_to_code('PAPI_FP_INS', event_code, check)
if (check .NE. PAPI_OK) then
print *, 'Abort After PAPIF_event_name_to_code: ', check
call abort
endif
call PAPIF_add_event(event_set, event_code, check)
if (check .NE. PAPI_OK) then
print *, 'Abort PAPIF_add_events1: ', check, ' ', event_code
call abort
endif
!event_code = PAPI_MEM_RCY ! Cycle stalled waiting for memory reads
call PAPIF_event_name_to_code('PAPI_TOT_CYC', event_code, check)
call PAPIF_add_event(event_set, event_code, check)
if (check .NE. PAPI_OK) then
print *, 'Abort PAPIF_add_events2: ', check, ' ', event_code
call abort
endif
call PAPIF_start(event_set, check)
if(check .ne. PAPI_OK) then
print *, 'Abort after PAPIF_start: ', check
call abort
endif
return
end
c-----------------------------------------------------------------------
subroutine papi_stop_counting(event_set, values)
integer, intent(in) :: event_set
integer*8, intent(inout) :: values(*) !shows an array
c Local variable
integer check
include 'f77papi.h'
! stop counting
call PAPIF_stop(event_set, values(1), check) !*Not sure if it should be values(1) or values*
if (check .ne. PAPI_OK) then
print *, 'Abort after PAPIF_stop: ', check
call abort
endif
return
end
c-----------------------------------------------------------------------
次のような別の関数からこれらのサブルーチンを呼び出しています。
subroutine myfunction
integer event_set ! For papi
integer*8 values(50) !For reading papi values
call papi_lib_init ! *Not shown, but is present and works. *
call papi_add_events(event_set)
do_flops()
call papi_stop_counting(event_set, values)
print *, 'Value 1: ', values(1)
print *, 'Value 2: ', values(2)
return
end
私が得る出力は次のとおりです。
Value 1: 0
Value 2: 0