[Omp] data outside parallel region affected by next parallel
region
Bronis R. de Supinski
bronis at llnl.gov
Wed Apr 20 09:13:07 PDT 2005
Neil:
I have not sorted through the logic of your first loop so
I don't know if this is the issue but one possibility is
that you could have a race condition on QERN. Since it is
shared data, if you are not assured that each element is
written by at most one thread then the behavior you are
seeing would not be surprising. Changing apparently unrelated
code will often change the timing, resulting in the bug emerging.
If you have access to it, you might try Intel's Thread Checker,
a tool that can identify this sort of error.
Anyway, if it isn't an issue like that, then we would need to
know more about the situation: what machine? what compiler? etc.
Bronis
On Tue, 19 Apr 2005, Neil Summers wrote:
> I have this problem in OpenMP and i cant seem
> to figure out why it is happening.
> If the second loop is not parallelised,
> the first loop in the example below is parallelised fine,
> the required array QERN is same as in a serial run.
> But if i then parallelise the second loop, QERN is wrong,
> even when it is printed out before the second loop is
> parallelised.
> This behaviour seems very wrong to me.
> Any help to why this is happening would be greatly appreciated.
>
>
> !$OMP PARALLEL DO
> !$OMP& FIRSTPRIVATE(VFRAG,VCORE,VOPT,WT,UK,A,B,P,Q,PLEG,
> !$OMP& SINRF,SINRC,SINRO,PQ2,AB2)
> !$OMP& PRIVATE(RR,VO,ABR,PQR,RRR,K,RCR2,R22,RCR,R2,
> !$OMP& VF,VC,VS,L1)
> DO 50 I=1,NN,MR
> RR = (I-1) * H
> VO = FFCI(RR*SINRO,VOPT,NLN)
> ABR = (A*RR)**2 + (B*R1)**2
> PQR = (P*RR)**2 + (Q*R1)**2
> RRR = R1*RR
> DO 31 K=1,NNT
> RCR2 = PQR + PQ2*RRR*UK(K)
> R22 = ABR + AB2*RRR*UK(K)
> RCR(K) = SQRT(ABS(RCR2)) * SINRC
> 31 R2(K) = SQRT(ABS(R22)) * SINRF
> DO 40 K=1,NNT
> VF = FFCI(R2(K),VFRAG,NLN)
> VC = FFCI(RCR(K),VCORE,NLN)
> VS(0) = (VF + VC - VO) * WT(K)
> DO 36 L1=KQ1M,KQ1
> QERN(I,L1,0)=QERN(I,L1,0) + VS(0) * PLEG(K,L1)
> 36 CONTINUE
> 40 CONTINUE
> 50 CONTINUE
>
> write(191,*)qern(1,1,0) ! if next loop is parallelised then this
> ! data becomes corrupt :( why ??????
> !$OMP PARALLEL DO
> !$OMP& PRIVATE(KNT,KNF,L1,RP,V,I)
> DO 60 IK=1,NK
> KNT = FPT(1,IK)
> KNF = FPT(2,IK)
> L1 = FPT(3,IK) + 1
> RP = 0.5 * R1 ** (QNF(9,KNT)+1 + QNF(9,KNF)+1) * RINTP
> V = RP * FORML(J,KNT) * FORML(J,KNF)
> V = V * SQRT(2.0 * (L1-1) + 1.0)
> DO 55 I=1,NN,MR
> FORMF(I,LOCF+IK) = FORMF(I,LOCF+IK) + V * QERN(I,L1,0)
> 55 CONTINUE
> 60 CONTINUE
>
>
> _______________________________________________
> Omp mailing list
> Omp at openmp.org
> http://openmp.org/mailman/listinfo/omp_openmp.org
>
More information about the Omp
mailing list