PRun*: use reduction(+:mllh) instead of deprecated reduction(-:mllh)
OpenMP 5.2 deprecates the '-' reduction operator (-Wdeprecated-openmp) because it is functionally identical to '+': the private reduction copy is initialised to 0 and partial results are combined by addition in both cases. All affected loops accumulate with 'mllh += ...', so switching to reduction(+:mllh) is results-identical and silences the warning. Fixes the pragma in PRunMuMinus.cpp and the two in PRunSingleHisto.cpp, and corrects the now-inaccurate "for subtraction" doc comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -383,7 +383,7 @@ Double_t PRunMuMinus::CalcMaxLikelihood(const std::vector<Double_t>& par)
|
||||
Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs();
|
||||
if (chunk < 10)
|
||||
chunk = 10;
|
||||
#pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh)
|
||||
#pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(+:mllh)
|
||||
#endif
|
||||
for (i=fStartTimeBin; i < fEndTimeBin; ++i) {
|
||||
time = fData.GetDataTimeStart() + static_cast<Double_t>(i)*fData.GetDataTimeStep();
|
||||
|
||||
@@ -439,7 +439,7 @@ Double_t PRunSingleHisto::CalcChiSquareExpected(const std::vector<Double_t>& par
|
||||
* <b>OpenMP Parallelization:</b>
|
||||
* - Dynamic scheduling with chunk size = (N_bins / N_processors), minimum 10
|
||||
* - Private variables per thread: i, time, theo, data
|
||||
* - Reduction performed on mllh sum (note: reduction(-:mllh) for subtraction)
|
||||
* - Reduction performed on mllh sum (reduction(+:mllh))
|
||||
*
|
||||
* <b>When to Use Maximum Likelihood vs. χ²:</b>
|
||||
* - <b>Use likelihood:</b> Low count rates (< 100 counts/bin), asymmetric errors
|
||||
@@ -515,7 +515,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector<Double_t>& par)
|
||||
Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs();
|
||||
if (chunk < 10)
|
||||
chunk = 10;
|
||||
#pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh)
|
||||
#pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(+:mllh)
|
||||
#endif
|
||||
for (i=fStartTimeBin; i<fEndTimeBin; ++i) {
|
||||
time = fData.GetDataTimeStart() + static_cast<Double_t>(i)*fData.GetDataTimeStep();
|
||||
@@ -650,7 +650,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector<Double_t>&
|
||||
Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs();
|
||||
if (chunk < 10)
|
||||
chunk = 10;
|
||||
#pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh)
|
||||
#pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(+:mllh)
|
||||
#endif
|
||||
for (i=fStartTimeBin; i<fEndTimeBin; ++i) {
|
||||
time = fData.GetDataTimeStart() + static_cast<Double_t>(i)*fData.GetDataTimeStep();
|
||||
|
||||
Reference in New Issue
Block a user