Fortran PAPIF_stop始终读为0

时间:2013-08-13 22:51:41

标签: fortran papi

我在fortran中有一个简单的程序,它使用PAPI API来读取性能计数器值。所有API(PAPIF_start,PAPIF_stop等)都正常工作(意思是,返回PAPI_OK)。但是,PAPIF_stop读取的值始终为0.我在BG / Q上尝试了另一个分析软件,以确保这些值不应为0.任何想法为什么会出现这种情况?这是我第一次尝试编写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

1 个答案:

答案 0 :(得分:0)