Skip to content

Commit

Permalink
Added names to omp critical statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Niklas Bohnensack committed May 2, 2024
1 parent 1dba43e commit 70c634d
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions include/crpropa/Referenced.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Candidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/module/HDF5Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<HDF5Output*>(this)->candidatesSinceFlush++;
Output::process(candidate);
Expand Down
6 changes: 3 additions & 3 deletions src/module/OutputShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/module/ParticleCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/module/PhotoPionProduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/PhotonOutput1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/TextOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/module/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 70c634d

Please sign in to comment.