Possible bug in reading the values of performance counters
We [register](https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2023/03/21/performancecounters/apple_arm_events.h#L932) for events in the following [order](https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2023/03/21/performancecounters/apple_arm_events.h#L827)
```
cycles
instructions
branches
branch-misses
```
The index mapping from event -> counter seems to be in the order events are registered to be read
```
https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2023/03/21/performancecounters/apple_arm_events.h#L531
```
The order of counters in the `performance_counters` struct is
```
struct performance_counters {
double cycles;
double branches;
double missed_branches;
double instructions;
performance_counters(uint64_t c, uint64_t b, uint64_t m, uint64_t i)
: cycles(c), branches(b), missed_branches(m), instructions(i) {}
```
In [line 1003](https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2023/03/21/performancecounters/apple_arm_events.h#L1003) the order of reading the performance counters however seem to be mixed up for branches and branch misses
```
return performance_counters{
counters_0[counter_map[0]], counters_0[counter_map[3]],
counters_0[counter_map[2]], counters_0[counter_map[1]]};
}
```
branches and missed_branches must be counter_map[2] and counter_map[3] respectively, however, they seem to be swapped
Am I missing something, or does it seem like this is a bug ?
关闭于 2024-01-31 1 条评论