Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push 2024 07 12 #786

Merged
merged 11 commits into from
Jul 14, 2024
1 change: 1 addition & 0 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,7 @@ PCM::PCM() :
#ifdef PCM_USE_PERF
canUsePerf = true;
perfEventHandle.resize(num_cores, std::vector<int>(PERF_MAX_COUNTERS, -1));
std::fill(perfTopDownPos.begin(), perfTopDownPos.end(), 0);
#endif

for (int32 i = 0; i < num_cores; ++i)
Expand Down
5 changes: 4 additions & 1 deletion src/pcm-accel-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,16 @@ void readAccelCounters(SystemCounterState& sycs_)
}

AcceleratorCounterState* AcceleratorCounterState::instance = NULL;

std::mutex instanceCreationMutexForAcceleratorCounterState{};

AcceleratorCounterState * AcceleratorCounterState::getInstance()
{
// lock-free read
// cppcheck-suppress identicalConditionAfterEarlyExit
if (instance) return instance;

std::unique_lock<std::mutex> instanceCreationMutex;
std::unique_lock<std::mutex> _(instanceCreationMutexForAcceleratorCounterState);
// cppcheck-suppress identicalConditionAfterEarlyExit
if (instance) return instance;

Expand Down
Loading