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

PAPI's High Level API from version >6.0.0 has some problems depending on selected events #49

Open
SerodioJ opened this issue Feb 27, 2024 · 1 comment

Comments

@SerodioJ
Copy link
Contributor

Depending on available events at a given machine, and which events are selected, using papi_high.hl_region_begin and papi_high.hl_region_end pair from #37 may throw the following exceptions:

>>> from pypapi import papi_high
>>> papi_high.hl_region_begin("computation")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serodio/Documents/Open_Source/debug/pypapi/exceptions.py", line 197, in papi_error_wrapper
    raise object_()
pypapi.exceptions.PapiInvalidValueError: Invalid Argument. (PAPI_EINVAL)
>>> papi_high.hl_region_end("computation")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serodio/Documents/Open_Source/debug/pypapi/exceptions.py", line 197, in papi_error_wrapper
    raise object_()
pypapi.exceptions.PapiMiscellaneousError: Unknown error code. (PAPI_EMISC)

This happens if the selected events are not available on the current machine, in my example I previously set the PAPI_EVENTS environment variable with export PAPI_EVENTS="PAPI_TOT_CYC", but this preset event was not available at my machine. So it is important to check the events available at the PAPI installation that has been used to configure PyPAPI.

This can be done by running the auxiliary scripts papi_components_avail, papi_avail or papi_native_avail from the library USED with the Python Binding.

It is possible to use the Low Level API as well. However, it will list the preset events even though you might not have them available at your current machine.

from pypapi import papi_low

papi_low.library_init() # It is necessary to init the library before running functions from the Low Level API
papi_low.enum_cmp_event(0) # Component 0 is usually perf_event

Another important thing to point out is that some counters can't be read without superuser privileges, which may lead to incorrect event counts, which is the case for some energy counter used by the powercap component. To use them, it is possible to run the script as root or run it inside a Docker containers with the --privileged flag.

@SerodioJ
Copy link
Contributor Author

This is not a problem with the Python Binding but with how PAPI works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant