Commit b6541a12c8ef48baff96469576b3f593124f6f95

Authored by Josh Cardenzana
Committed by Jürgen Knödlseder
1 parent 61d51c13

Parallelize ctfindvar with OpenMP (#2713)

Showing 1 changed file with 17 additions and 14 deletions
src/ctfindvar/ctfindvar.cpp
... ... @@ -302,7 +302,6 @@ void ctfindvar::run(void)
302 302 }
303 303  
304 304 //preparing the histogram with significance evolution for the source center and the highest sig-pix
305   - GNdarray pixSig(nbins), pixSigMax(nbins); //Storing the significance for each GTI of the pixels
306 305 m_pixsigsrc = GNdarray(srcInxPix.size(), nbins);
307 306 m_pixsigmax = GNdarray(1,nbins);
308 307  
... ... @@ -311,8 +310,10 @@ void ctfindvar::run(void)
311 310 GSkyDir max_sig_dir;
312 311  
313 312 //looping over all the pixels in the cube
  313 + #pragma omp parallel for
314 314 for (int pix_number=0; pix_number<m_counts.npix(); pix_number++)
315 315 {
  316 + GNdarray pixSig(nbins);
316 317 double total_counts=0;
317 318 for (int k=0;k<m_counts.nmaps();k++)
318 319 {
... ... @@ -363,19 +364,21 @@ void ctfindvar::run(void)
363 364 }
364 365  
365 366 // Getting the evolution for the pix with highest significance
366   - if (max(pixSig) > max_sig)
  367 + #pragma omp critical(ctfind_run)
367 368 {
368   - max_sig = max(pixSig);
369   - // Store information for pixel with the maximum significance
370   - for (int i=0; i<nbins; i++) {
371   - m_pixsigmax(0,i) = pixSig(i);
372   - }
  369 + if (max(pixSig) > max_sig)
  370 + {
  371 + max_sig = max(pixSig);
  372 + // Store information for pixel with the maximum significance
  373 + for (int i=0; i<nbins; i++) {
  374 + m_pixsigmax(0,i) = pixSig(i);
  375 + }
373 376  
374   - // Update the pixel position with the maximum sigma
375   - max_sig = max(pixSig);
376   - max_sig_dir = m_counts.inx2dir(pix_number);
  377 + // Update the pixel position with the maximum sigma
  378 + max_sig = max(pixSig);
  379 + max_sig_dir = m_counts.inx2dir(pix_number);
  380 + }
377 381 }
378   -
379 382 //storing sig in skymap
380 383 m_peaksigmap(pix_number) = max(pixSig);
381 384 }
... ... @@ -627,10 +630,10 @@ void ctfindvar::get_parameters(void)
627 630 // Get the desired source position from user
628 631 (*this)["xsrc"].real();
629 632 (*this)["ysrc"].real();
630   -
631   - // Get the file format for the output source histograms
632   - (*this)["histtype"].string();
633 633 }
  634 +
  635 + // Get the file format for the output source histograms
  636 + (*this)["histtype"].string();
634 637 }
635 638  
636 639 // Write parameters into logger
... ...