Implemented OpenMP parallelization of the independent-transform loops in both files, following the existing #ifdef HAVE_GOMP / #pragma omp parallel for pattern already used elsewhere in the codebase:

- src/musrFT.cpp: the timed Transform() loop over all PFourier objects is now parallelized. Added OpenMP::OpenMP_CXX linkage to the musrFT CMake target (it wasn't linked before).
  - src/classes/PMusrCanvas.cpp (HandleFourier() and HandleDifferenceFourier()): split each loop into three phases — serial PFourier construction (FFTW plan creation isn't thread-safe), a parallel Transform()
    loop (pure FFTW compute, safe to parallelize), and serial ROOT histogram creation/styling (ROOT globals aren't thread-safe). PMusr already links OpenMP, so only the #include <omp.h> and the pragma were
    needed.
This commit is contained in:
2026-08-25 10:00:41 +02:00
parent 66472c979a
commit 40769be238
4 changed files with 101 additions and 44 deletions
+10 -1
View File
@@ -31,6 +31,8 @@
#include "config.h"
#endif
#include <omp.h>
#include <sys/time.h>
#include <iostream>
@@ -1463,7 +1465,14 @@ Int_t main(Int_t argc, Char_t *argv[])
apodTag = F_APODIZATION_STRONG;
Double_t start = millitime();
for (UInt_t i=0; i<fourier.size(); i++) {
Int_t noOfFourier = static_cast<Int_t>(fourier.size());
#ifdef HAVE_GOMP
Int_t chunk = noOfFourier/omp_get_num_procs();
if (chunk < 1)
chunk = 1;
#pragma omp parallel for default(shared) schedule(dynamic,chunk)
#endif
for (Int_t i=0; i<noOfFourier; i++) {
fourier[i]->Transform(apodTag);
}
Double_t end = millitime();