Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Arguments for PAPIF_flops_rate, PAPIF_flips_rate, PAPIF_epc #154

Merged

Conversation

Treece-Burgess
Copy link
Contributor

@Treece-Burgess Treece-Burgess commented Jan 29, 2024

Pull Request Description

This PR updates the PAPI Fortran wrappers for: PAPIF_flops_rate, PAPIF_flips_rate, and PAPIF_epc. All three of the aforementioned functions had a first argument of int event. However, setting int event equal to events such as PAPI_FP_OPS for PAPIF_flops_rate, PAPI_FP_INS for PAPIF_flips_rate, and PAPI_TOT_INS for PAPIF_epc would result in an error being output, specifically -7. Which means the "Hardware event does not exist". This is not the correct behavior due to the events existing and the associated C low-level functions running correctly given the same input.

To fix this issue, int event was changed to int *EventCode for PAPIF_flops_rate, PAPIF_flips_rate, and PAPIF_epc. As well as *EventCode being passed to the C function calls within the wrappers.

Two other minor updates are:

  • Updated documentation for PAPIF_flops_rate, PAPIF_flips_rate, and PAPIF_epc within the papi_fwrappers.c source file.
  • Changed argument name from event to EventCode, the idea with this change is to keep the argument naming scheme similar to other PAPI functions such as PAPIF_event_code_to_name.

Example code for PAPIF_flops_rate with the changes mentioned above:

#include "fpapi.h"    
      program main
          use iso_c_binding
          integer(c_int) EventCode, check, retval
          real(c_float) real_time, proc_time, mflops, nfact
          integer(c_long_long) flpops

          EventCode = PAPI_FP_OPS

          retval = PAPI_VER_CURRENT
          call PAPIf_library_init(retval)
          if ( retval.NE.PAPI_VER_CURRENT) then
            write(*,*) retval
          end if

          call PAPIF_flops_rate(EventCode, real_time, proc_time,
     & flpops, mflops, check) 
          if ( check.NE.PAPI_OK) then
            write(*,*) check
          end if

          ! do some arbitrary work
          do n = 1, 10000
              nfact = (1.1 + 100)/n
          end do

          call PAPIF_flops_rate(EventCode, real_time, proc_time,
     & flpops, mflops, check) 
          if ( check.NE.PAPI_OK) then
              write(*,*) check
          end if

      end program main

Possible output is from running the above script on Guyot:

Real Time: 3.79999983E-05
Proc Time: 3.70000016E-05
Flpops: 10000
Mflops:  270.270264    
Error Check: 0

Author Checklist

  • Description
    Why this PR exists. Reference all relevant information, including background, issues, test failures, etc
  • Commits
    Commits are self contained and only do one thing
    Commits have a header of the form: module: short description
    Commits have a body (whenever relevant) containing a detailed description of the addressed problem and its solution
  • Tests
    The PR needs to pass all the tests

…APIF_epc to use a int * instead of just int.
@Treece-Burgess Treece-Burgess added the type-bug Issues discussing bugs or PRs fixing bugs label Jan 29, 2024
@Treece-Burgess Treece-Burgess merged commit 2aa2e84 into icl-utk-edu:master Feb 9, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Issues discussing bugs or PRs fixing bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants