david-grs / geiger

C++ micro benchmark library
MIT License
88 stars 6 forks source link

papi issue #2

Open eddelbuettel opened 7 years ago

eddelbuettel commented 7 years ago

On a very standard Ubuntu 16.10 box I am seeing:

edd@brad:~/git/geiger/build(master)$ examples/walk 
Test                Time (ns)       L1 DCM       L2 DCM       L3 TCM
--------------------------------------------------------------------
terminate called after throwing an instance of 'std::runtime_error'
  what():  PAPI_start_counters failed with events: PAPI_L1_DCM PAPI_L2_DCM PAPI_L3_TCM : Event does not exist
Aborted (core dumped)
edd@brad:~/git/geiger/build(master)$ 

Same with other examples and some tests. Is that expected?

david-grs commented 7 years ago

Hi, Yes, it is expected if one event of the set is not available. It depends more on the CPU model than the Linux distribution, even if it is true that very old Linux kernels do not support some hardware counters - but Ubuntu 16.10 isn't that old, and these events are pretty standard. In order to list the hardware events available on your machine, you can run papi_avail -a. Cheers David

eddelbuettel commented 7 years ago

I see. Quite a difference between the laptop (where I noodled with your code on a commute to work) and my workstation. On the laptop (with an i5) I have no 'PAPI Preset Events' which would explain what we see above.

Might this be worth catching on your end and warning about?

eddelbuettel commented 7 years ago

There is another issue in the example (and documentation) because instantiating

suite<cache_profiler> s;

require geiger::cache_profiler which (currently) exists only if USE_PAPI is on. One could wrap #ifdef around, nice approach would maybe be for cache_profiler to just become a no-op (with a possible warning).