From 70c634dfb075c3254cd9f5aeaf0f7ad3d4e170df Mon Sep 17 00:00:00 2001 From: Jan-Niklas Bohnensack Date: Thu, 2 May 2024 15:21:42 +0200 Subject: [PATCH] Added names to omp critical statements --- include/crpropa/Referenced.h | 4 ++-- src/Candidate.cpp | 4 ++-- src/module/HDF5Output.cpp | 4 ++-- src/module/OutputShell.cpp | 6 +++--- src/module/ParticleCollector.cpp | 2 +- src/module/PhotoPionProduction.cpp | 2 +- src/module/PhotonOutput1D.cpp | 2 +- src/module/TextOutput.cpp | 2 +- src/module/Tools.cpp | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/crpropa/Referenced.h b/include/crpropa/Referenced.h index 4bede8331..e8f80ca78 100644 --- a/include/crpropa/Referenced.h +++ b/include/crpropa/Referenced.h @@ -47,7 +47,7 @@ class Referenced { #elif defined(__GNUC__) newRef = __sync_add_and_fetch(&_referenceCount, 1); #else - #pragma omp critical + #pragma omp critical(newRef) {newRef = _referenceCount++;} #endif return newRef; @@ -67,7 +67,7 @@ class Referenced { #elif defined(__GNUC__) newRef = __sync_sub_and_fetch(&_referenceCount, 1); #else - #pragma omp critical + #pragma omp critical(newRef) {newRef = _referenceCount--;} #endif diff --git a/src/Candidate.cpp b/src/Candidate.cpp index 8028d66a2..038805a38 100644 --- a/src/Candidate.cpp +++ b/src/Candidate.cpp @@ -20,7 +20,7 @@ Candidate::Candidate(int id, double E, Vector3d pos, Vector3d dir, double z, dou #elif defined(__GNUC__) {serialNumber = __sync_add_and_fetch(&nextSerialNumber, 1);} #else - #pragma omp critical + #pragma omp critical(serialNumber) {serialNumber = nextSerialNumber++;} #endif @@ -35,7 +35,7 @@ Candidate::Candidate(const ParticleState &state) : #elif defined(__GNUC__) {serialNumber = __sync_add_and_fetch(&nextSerialNumber, 1);} #else - #pragma omp critical + #pragma omp critical(serialNumber) {serialNumber = nextSerialNumber++;} #endif diff --git a/src/module/HDF5Output.cpp b/src/module/HDF5Output.cpp index 5dcc5768f..632fa1371 100644 --- a/src/module/HDF5Output.cpp +++ b/src/module/HDF5Output.cpp @@ -248,7 +248,7 @@ void HDF5Output::close() { } void HDF5Output::process(Candidate* candidate) const { - #pragma omp critical + #pragma omp critical(HDF5Output_access_file) { if (file == -1) // This is ugly, but necesary as otherwise the user has to manually open the @@ -316,7 +316,7 @@ void HDF5Output::process(Candidate* candidate) const { pos += v.copyToBuffer(&r.propertyBuffer[pos]); } - #pragma omp critical + #pragma omp critical(HDF5Output_access_file) { const_cast(this)->candidatesSinceFlush++; Output::process(candidate); diff --git a/src/module/OutputShell.cpp b/src/module/OutputShell.cpp index 87b67f8c9..5db27d7c1 100644 --- a/src/module/OutputShell.cpp +++ b/src/module/OutputShell.cpp @@ -6,7 +6,7 @@ namespace crpropa { void ShellOutput::process(Candidate* c) const { -#pragma omp critical +#pragma omp critical(ShellOutput) { std::cout << std::fixed << std::showpoint << std::setprecision(3) << std::setw(6); @@ -25,7 +25,7 @@ std::string ShellOutput::getDescription() const { } void ShellOutput1D::process(Candidate* c) const { -#pragma omp critical +#pragma omp critical(ShellOutput) { std::cout << std::fixed << std::showpoint << std::setprecision(3) << std::setw(6); @@ -43,7 +43,7 @@ std::string ShellOutput1D::getDescription() const { void ShellPropertyOutput::process(Candidate* c) const { Candidate::PropertyMap::const_iterator i = c->properties.begin(); -#pragma omp critical +#pragma omp critical(ShellOutput) { for ( ; i != c->properties.end(); i++) { std::cout << " " << i->first << ", " << i->second << std::endl; diff --git a/src/module/ParticleCollector.cpp b/src/module/ParticleCollector.cpp index e6f48d806..74e820680 100644 --- a/src/module/ParticleCollector.cpp +++ b/src/module/ParticleCollector.cpp @@ -21,7 +21,7 @@ ParticleCollector::ParticleCollector(const std::size_t nBuffer, const bool clone } void ParticleCollector::process(Candidate *c) const { -#pragma omp critical +#pragma omp critical(ModifiyContainer) { if(clone) container.push_back(c->clone(recursive)); diff --git a/src/module/PhotoPionProduction.cpp b/src/module/PhotoPionProduction.cpp index b8f6a7db2..aa48bfe3e 100644 --- a/src/module/PhotoPionProduction.cpp +++ b/src/module/PhotoPionProduction.cpp @@ -231,7 +231,7 @@ void PhotoPionProduction::performInteraction(Candidate *candidate, bool onProton int outPartID[2000]; int nParticles; -#pragma omp critical +#pragma omp critical(SophiaEvent) { sophiaevent_(nature, Ein, eps, outputEnergy, outPartID, nParticles); } diff --git a/src/module/PhotonOutput1D.cpp b/src/module/PhotonOutput1D.cpp index ec886aa4f..67a4b74aa 100644 --- a/src/module/PhotonOutput1D.cpp +++ b/src/module/PhotonOutput1D.cpp @@ -63,7 +63,7 @@ void PhotonOutput1D::process(Candidate *candidate) const { p += std::sprintf(buffer + p, "%8.4f\t", candidate->source.getEnergy() / EeV); p += std::sprintf(buffer + p, "%8.4f\n", candidate->source.getPosition().getR() / Mpc); -#pragma omp critical +#pragma omp critical(FileOutput) { out->write(buffer, p); } diff --git a/src/module/TextOutput.cpp b/src/module/TextOutput.cpp index 07bd5ea3c..e979c85dc 100644 --- a/src/module/TextOutput.cpp +++ b/src/module/TextOutput.cpp @@ -271,7 +271,7 @@ void TextOutput::process(Candidate *c) const { std::locale::global(old_locale); -#pragma omp critical +#pragma omp critical(FileOutput) { if (count == 0) printHeader(); diff --git a/src/module/Tools.cpp b/src/module/Tools.cpp index 852e4abc3..6abc4e378 100644 --- a/src/module/Tools.cpp +++ b/src/module/Tools.cpp @@ -40,7 +40,7 @@ void PerformanceModule::process(Candidate *candidate) const { times[i] = end - start; } -#pragma omp critical +#pragma omp critical(PerformanceModule) { for (size_t i = 0; i < modules.size(); i++) { _module_info &m = modules[i]; @@ -109,7 +109,7 @@ void EmissionMapFiller::setEmissionMap(EmissionMap *emissionMap) { void EmissionMapFiller::process(Candidate* candidate) const { if (emissionMap) { - #pragma omp critical + #pragma omp critical(EmissionMap) { emissionMap->fillMap(candidate->source); }