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

196 Potential race condition in read-modify-write PDF vectors in parallel loop in onesource::generatePDF() #206

Closed
24 changes: 12 additions & 12 deletions src/lib/onesource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ void onesource::generatePDF(vector<SED *> &fulllib, const vector<size_t> &va,
// Catch the name of the local thread in the parallelisation
thread_id = omp_get_thread_num();
#pragma omp for schedule(static, 10000) reduction( \
+ : PDFzloc, PDFzqloc, PDFmassloc, PDFSFRloc, PDFsSFRloc, PDFAgeloc) \
nowait
+ : PDFzloc, PDFzqloc, PDFmassloc, PDFSFRloc, PDFsSFRloc, PDFAgeloc, \
PDFLdustloc, PDFcol1loc, PDFcol2loc, PDFmrefloc) nowait
#endif
// Loop over all SEDs, which is parallelized
for (size_t i = 0; i < va.size(); i++) {
Expand Down Expand Up @@ -1048,16 +1048,16 @@ void onesource::generatePDF(vector<SED *> &fulllib, const vector<size_t> &va,
// 0:["MASS"] / 1:["SFR"] / 2:["SSFR"] / 3:["LDUST"] / 4:["LIR"] / 5:["AGE"] /
// 6:["COL1"] / 7:["COL2"] / 8:["MREF"]/ 9:["MIN_ZG"] / 10:["MIN_ZQ"] /
// 11:["BAY_ZG"] / 12:["BAY_ZQ"] Put back 1 dimension array into PDF objects
pdfbayzg.vPDF.assign((PDFzloc), (PDFzloc+pdfbayzg.size()));
pdfbayzq.vPDF.assign((PDFzqloc), (PDFzqloc+pdfbayzq.size()));
pdfmass.vPDF.assign((PDFmassloc), (PDFmassloc+pdfmass.size()));
pdfsfr.vPDF.assign((PDFSFRloc), (PDFSFRloc+pdfsfr.size()));
pdfssfr.vPDF.assign((PDFsSFRloc), (PDFsSFRloc+pdfssfr.size()));
pdfage.vPDF.assign((PDFAgeloc), (PDFAgeloc+pdfage.size()));
pdfldust.vPDF.assign((PDFLdustloc), (PDFLdustloc+pdfldust.size()));
pdfcol1.vPDF.assign((PDFcol1loc), (PDFcol1loc+pdfcol1.size()));
pdfcol2.vPDF.assign((PDFcol2loc), (PDFcol2loc+pdfcol2.size()));
pdfmref.vPDF.assign((PDFmrefloc), (PDFmrefloc+pdfmref.size()));
pdfbayzg.vPDF.assign((PDFzloc), (PDFzloc + pdfbayzg.size()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a coding style change unrelated to the pull request, should it have a different commit ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is done automatically by pre-commit, and comes from a previous merge from you that I forced, so I think we can get it through here now.

pdfbayzq.vPDF.assign((PDFzqloc), (PDFzqloc + pdfbayzq.size()));
pdfmass.vPDF.assign((PDFmassloc), (PDFmassloc + pdfmass.size()));
pdfsfr.vPDF.assign((PDFSFRloc), (PDFSFRloc + pdfsfr.size()));
pdfssfr.vPDF.assign((PDFsSFRloc), (PDFsSFRloc + pdfssfr.size()));
pdfage.vPDF.assign((PDFAgeloc), (PDFAgeloc + pdfage.size()));
pdfldust.vPDF.assign((PDFLdustloc), (PDFLdustloc + pdfldust.size()));
pdfcol1.vPDF.assign((PDFcol1loc), (PDFcol1loc + pdfcol1.size()));
pdfcol2.vPDF.assign((PDFcol2loc), (PDFcol2loc + pdfcol2.size()));
pdfmref.vPDF.assign((PDFmrefloc), (PDFmrefloc + pdfmref.size()));

// Normalize the PDF

Expand Down