Skip to content

Modifying Harness Script for to measure other hardware events #13

@RafaeNoor

Description

@RafaeNoor

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions