serial construct in openacc, Fortran

OpenACC and CUDA Fortran
afiguer
Posts: 8
Joined: Mar 23 2020

serial construct in openacc, Fortran

Post by afiguer » Mon Mar 23, 2020 8:16 am

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,

Code: Select all

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,

Code: Select all

            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:

Code: Select all

             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:

Code: Select all

  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?
Last edited by afiguer on Mon Mar 23, 2020 9:42 am, edited 1 time in total.

mkcolg
Posts: 8319
Joined: Jun 30 2004

Re: serial construct in openacc, Fortran

Post by mkcolg » Mon Mar 23, 2020 8:34 am

Hi afiguer,

I'm assuming the issue here is that you're expecting different results before and after. Unfortunately, there's not enough information here to determine what's wrong. Are you able to provide a full reproducing example?

If not, please post the compiler feedback messages (-Minfo=accel) so I can see how the compiler is offloading this code. Also, how are you handling data movement? Are you using data regions or are relying on the compiler to implicitly copy the data when reaching the serial compute region?

-Mat

afiguer
Posts: 8
Joined: Mar 23 2020

Re: serial construct in openacc, Fortran

Post by afiguer » Mon Mar 23, 2020 8:39 am

Hi Mat,

I accidentally press the submit button before the post was ready to be submitted. I initiated another post
with the correct issue.

Best,
Alejandro

mkcolg
Posts: 8319
Joined: Jun 30 2004

Re: serial construct in openacc, Fortran

Post by mkcolg » Mon Mar 23, 2020 9:30 am

Hi Alejandro,

Since you're a new poster, you default to the moderated queue which I first need to approve the posts (this protects against Spam and I've since moved you to be a registered user so unmoderated). I saw the second post but deleted it since I thought it was a duplicate. Sorry.

Though, I did see your post over on StackOverflow (https://stackoverflow.com/questions/608 ... cc-fortran) which included the compiler feedback.

Still not enough information to determine the issue so if you could provide a reproducing example that would be helpful. Also, do you have any higher level data regions? If so, are you copying "unkno" back from the device or using an "update self(unkno)" directive?

-Mat

afiguer
Posts: 8
Joined: Mar 23 2020

Re: serial construct in openacc, Fortran

Post by afiguer » Mon Mar 23, 2020 9:49 am

Hi Matt,

I updated the post, so now is a bit more clear. My idea is to run this part of the code in the device, so there is not transfer between the host and device. Unkno is already in the device and the arrays bppnr, bppni and lppas are updated from the host to the device before entering into the subrutine.

I know that before going inside the subrutine with the code that I shared, the values of all the arrays are the correct ones. I will try to generate a reproducible example soon.

Alejandro

Post Reply