-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hey,
We wanted to use the harness script provided to measure other performance counters. Would it be easy to swap out the performance counters being measured? For context, I'm trying to measure the PERF_COUNT_HW_INSTRUCTIONS event as an example just to see if it's being measured correctly.
I've added the following code to harness.c:
struct perf_event_attr instruction_attr = {
.type = PERF_TYPE_HARDWARE,
.size = PERF_ATTR_SIZE_VER0,
.config = PERF_COUNT_HW_INSTRUCTIONS,
.sample_type = PERF_SAMPLE_READ,
.exclude_kernel = 1,
};
...
int count_inst = rdpmc_open_attr(&instruction_attr, &ctx, 0);
if(count_inst != 0){
LOG("unable to count instructions\n");
abort();
}
int instruction_idx = ctx.buf->index - 1;
LOG("Instruction IDX = %d\n", ctx.buf->index);
The next modifications are the ones I'm struggling with. I checked the run_test.nasm files and it looks like the pmc struct is being indexed in each iteration and the counters are being written to. Additionally it looks like certain registers are fixed for measurement of the performance counters. I tried extending the size of the pmc_counters struct and updating the size to 48 in run_test.nasm. Could you help with what other changes would be needed?