In the following serial part of a Fortran code I am trying to copy sequentially the value of unkno(iva,jpoin)+bppnr to unkno(iva,ipoin). The code used is,
c$acc serial
nppn1=0
c
do 1200 ippas=1,50
c
nppn0=nppn1+1
nppn1=lppas(ippas)
c
c -----did we complete the passes ?
c
if(nppn1.eq.0) goto 1201
c
c -----do we have any ?
c
if(nppn0.gt.nppn1) goto 1199
c
c -----loop over the receiving points
c
c$acc loop seq
do 1400 ippne=nppn0,nppn1
c
c -----points
c
ipoin=bppni(1,ippne)
jpoin=bppni(2,ippne)
c
c -----variables 1-nunkp
c
c$acc loop seq
do 1410 iva=1,nunkp
unkno(iva,ipoin)=unkno(iva,jpoin)+bppnr(iva,ippne)
1410 continue
c
c ----end of loop over the receiving points
c
1400 continue
c
c
c ----end of loop over the passes
c
1199 continue
1200 continue
1201 continue
c$acc end serial
The result obtained using the PGI compiler with the OpenACC directives deactivated and bppnr=0 looks like,
ipoin jpoin unkno(iva,ipoin) unkno(iva,jpoin)
before loop 160215 160165 100.3518075025082 100.3517910648527
after loop 160215 160165 100.3517910648527 100.3517910648527
before loop 160165 157415 100.3517910648527 100.3517910648527
after loop 160165 157415 100.3517910648527 100.3517910648527
The result obtained using the PGI compiler with the OpenACC directives deactivated is:
ipoin jpoin unkno(iva,ipoin) unkno(iva,jpoin)
before loop 160215 160165 100.3518075025082 100.3517910648527
after loop 160215 160165 100.3518075025082 100.3517910648527
When compiling, the PGI compiler says the following:
2552, Accelerator serial kernel generated
Generating Tesla code
2556, !$acc do seq
2588, !$acc do seq
2603, !$acc do seq
2552, Generating implicit copyin(bppnr(:nunkp,:),bppni(:2,:),lppas(:))
Generating implicit copy(unkno(:nunkp,:))
So, I don’t know what is happening here and why the values of unkno are not correctly updated. Any ideas?