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:
+10
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user