@@ -3264,10 +3264,11 @@ PCM::ErrorCode PCM::programCoreCounters(const int i /* core */,
3264
3264
}
3265
3265
}
3266
3266
EventSelectRegister reg;
3267
- setEvent (reg, eventSel, umask);
3267
+ reg.fields .event_select = eventSel;
3268
+ reg.fields .umask = umask;
3268
3269
perf_event_attr e = PCM_init_perf_event_attr ();
3269
3270
e.type = PERF_TYPE_RAW;
3270
- e.config = ( 1ULL << 63ULL ) + reg.value ;
3271
+ e.config = reg.value ;
3271
3272
// std::cerr << "Programming perf event " << std::hex << e.config << "\n";
3272
3273
if (programPerfEvent (e, event.second , std::string (" event " ) + event.first + " " + eventDesc) == false )
3273
3274
{
@@ -4288,6 +4289,7 @@ void PCM::readPerfData(uint32 core, std::vector<uint64> & outData)
4288
4289
}
4289
4290
uint64 data[1 + PERF_MAX_COUNTERS];
4290
4291
const int32 bytes2read = sizeof (uint64) * (1 + num_counters);
4292
+ assert (num_counters <= PERF_MAX_COUNTERS);
4291
4293
int result = ::read (perfEventHandle[core][leader], data, bytes2read);
4292
4294
// data layout: nr counters; counter 0, counter 1, counter 2,...
4293
4295
if (result != bytes2read)
@@ -4300,7 +4302,17 @@ void PCM::readPerfData(uint32 core, std::vector<uint64> & outData)
4300
4302
std::cerr << " Number of counters read from perf is wrong. Elements read: " << data[0 ] << " \n " ;
4301
4303
}
4302
4304
else
4303
- { // copy all counters, they start from position 1 in data
4305
+ {
4306
+ /*
4307
+ if (core == 0)
4308
+ {
4309
+ std::unique_lock<std::mutex> _(instanceCreationMutex);
4310
+ std::cerr << "DEBUG: perf raw: " << std::dec;
4311
+ for (uint32 p=0; p < (1 + num_counters) ; ++p) std::cerr << data[p] << " ";
4312
+ std::cerr << "\n";
4313
+ }
4314
+ */
4315
+ // copy all counters, they start from position 1 in data
4304
4316
std::copy ((data + 1 ), (data + 1 ) + data[0 ], outData.begin ());
4305
4317
}
4306
4318
};
@@ -4385,7 +4397,7 @@ void BasicCounterState::readAndAggregate(std::shared_ptr<SafeMsrHandle> msr)
4385
4397
cBackendBoundSlots = perfData[m->perfTopDownPos [PCM::PERF_TOPDOWN_BACKEND_POS]];
4386
4398
cRetiringSlots = perfData[m->perfTopDownPos [PCM::PERF_TOPDOWN_RETIRING_POS]];
4387
4399
cAllSlotsRaw = perfData[m->perfTopDownPos [PCM::PERF_TOPDOWN_SLOTS_POS]];
4388
- // if (core_id == 0) std::cout << "DEBUG: "<< cAllSlotsRaw << " " << cFrontendBoundSlots << " " << cBadSpeculationSlots << " " << cBackendBoundSlots << " " << cRetiringSlots << std::endl;
4400
+ // if (core_id == 0) std::cout << "DEBUG: All: "<< cAllSlotsRaw << " FE: " << cFrontendBoundSlots << " BAD-SP: " << cBadSpeculationSlots << " BE: " << cBackendBoundSlots << " RET: " << cRetiringSlots << std::endl;
4389
4401
}
4390
4402
}
4391
4403
else
0 commit comments