I have an use-case where I was already using PAPI_flops and now need to simultaneously also monitor other counters e.g. cache. The problem is that PAPI_flops and PAPI_add_events seem not to work along well together.
My use-case is detailed in the snippet below. I would like to be able to monitor all these events while at the same time enjoy the comfort of using PAPI_flops. If I do that all my events come out zero. Is there a way to make these two work together or do I have to renounce to use PAPI_flops?
How can I do that?
UPDATE: sorry missed looking at the error output, I get "PAPI_create_eventset error (-1): PAPI_EINVAL" is there a way around this and have the two work together?
Many TIA,
Best regards,
Giovanni
- Code: Select all
// first two are set implicitly
const int PAPI_L1_DCA_INDEX = 2;
const int PAPI_L1_DCM_INDEX = 3;
const int PAPI_L2_DCA_INDEX = 4;
const int PAPI_L2_DCM_INDEX = 5;
const int NUM_EVENTS = 6;
long long values[NUM_EVENTS] = {0, 0, 0, 0, 0, 0};
int event_set = PAPI_NULL;
int extra_events[NUM_EVENTS] = {PAPI_L1_DCA, PAPI_L1_DCM, PAPI_L2_DCA, PAPI_L2_DCM};
int error_code;
char error_string[PAPI_MAX_STR_LEN + 1];
// initialize PAPI
error_code = PAPI_flops(&real_time, &cpu_time, &fp_ins, &mflops);
if (error_code != PAPI_OK) {
PAPI_perror(error_code, error_string, PAPI_MAX_STR_LEN);
fprintf(stderr, "PAPI_flops error (%d): %s\n", error_code, error_string);
}
// try adding new extra events
error_code = PAPI_create_eventset(&event_set);
if (error_code != PAPI_OK) {
PAPI_perror(error_code, error_string, PAPI_MAX_STR_LEN);
fprintf(stderr, "PAPI_create_eventset error (%d): %s\n", error_code, error_string);
}
error_code = PAPI_add_events(event_set, extra_events, NUM_EVENTS - 2);
if (error_code != PAPI_OK) {
PAPI_perror(error_code, error_string, PAPI_MAX_STR_LEN);
fprintf(stderr, "PAPI_add_events(...) error (%d): %s\n", error_code, error_string);
}
// ...
