From 1f21b6a082458607f9c4fcc5e313df544692d37d Mon Sep 17 00:00:00 2001 From: "Mulas, Giacomo" <gmulas@oa-cagliari.inaf.it> Date: Mon, 3 Jun 2024 20:41:44 +0200 Subject: [PATCH] Correct some bugs in parallelised scr2 --- src/libnptm/clu_subs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libnptm/clu_subs.cpp b/src/libnptm/clu_subs.cpp index 3760cd8c..b08da3d6 100644 --- a/src/libnptm/clu_subs.cpp +++ b/src/libnptm/clu_subs.cpp @@ -2109,6 +2109,7 @@ void scr2( double cfsq = 4.0 / (pi4sq * ccs * ccs); cph = uim * exri * vkarg; int ls = (c4->li < c4->le) ? c4->li : c4->le; + int kmax = (ls+1)*(ls+1)-1; c3->tsas[0][0] = cc0; c3->tsas[1][0] = cc0; c3->tsas[0][1] = cc0; @@ -2119,7 +2120,7 @@ void scr2( #ifdef USE_NVTX nvtxRangePush("scr2 outer loop 1"); #endif -#pragma omp parallel for + //#pragma omp parallel for for (int i14 = 1; i14 <= c4->nsph; i14++) { int i = i14 - 1; int iogi = c1->iog[i14 - 1]; @@ -2137,7 +2138,6 @@ void scr2( // but if it results im = 0, then we set l10 = l10-1 and im10 = 2*l10+1 // furthermore if it results im10 > 2*l10+1, then we set // im10 = im10 -(2*l10+1) and l10 = l10+1 (there was a rounding error in a nearly exact root) - int kmax = (ls+1)*(ls+1)-1; #ifdef USE_NVTX nvtxRangePush("scr2 inner loop 1"); #endif @@ -2190,7 +2190,7 @@ void scr2( c1->sas[i][1][1] = s22 * csam; } // label 12 - phas = cexp(cph * (duk[0] * c1->rxx[i] + duk[1] * c1->ryy[i] + duk[2] * c1->rzz[i])); + dcomplex phas = cexp(cph * (duk[0] * c1->rxx[i] + duk[1] * c1->ryy[i] + duk[2] * c1->rzz[i])); c3->tsas[0][0] += (c1->sas[iogi - 1][0][0] * phas); c3->tsas[1][0] += (c1->sas[iogi - 1][1][0] * phas); c3->tsas[0][1] += (c1->sas[iogi - 1][0][1] * phas); @@ -2211,7 +2211,7 @@ void scr2( #ifdef USE_NVTX nvtxRangePush("scr2 inner loop 2"); #endif -#pragma omp target parallel for collapse(4) +#pragma omp target teams distribute parallel for simd collapse(4) for (int ipo1 = 1; ipo1 <=2; ipo1++) { for (int jpo1 = 1; jpo1 <= 2; jpo1++) { // cc = dconjg(c1->sas[i24 - 1][jpo1 - 1][ipo1 - 1]); -- GitLab