Getting weird output when using OpenACC parallelization


There is a loop in my code which is structured as such:

 !$acc parallel loop gang vector collapse(3) &
    !$acc& private(prim_n,g_td,tau_wall_ewm,tau_xy,tau_yz,coeff1,coeff2,dyn_visc_nj,kin_visc_nj) default(present)
    do b = 1,nblocks
       do k = 1,nkmax
          do i = 1,nimax
             if ((i .le. (ni(b))) .and. (k .le. nk(b))) then

                !$acc loop seq
                do l = 1,10000000

The code runs fine, does not crash, and seems to give a pretty close answer to what I need, but when outputting one of the output variables of the loop, I see something weird. For comparison, I will attach what is outputted when running this loop only on the host: Imgur: The magic of the Internet

When parallelized, I get something like this: Imgur: The magic of the Internet

I am not sure why this is. I tried making a bunch of different variables needed in the loop private, but this did not seem to work. I am compiling the code with -minfo=accel and I do not see any alert telling me I need to privatize some other variable.

Does anyone know why this may be happening? My code is rather large so I would be happy to provide it over email for further inspection. Thanks in advance.

I just found where the issue was. There was a scalar that I thought was private by default but I actually had to make private manually. The compiler did not tell me this so I am wondering if it is an outstanding issue.

Hi Natan,

Scalars are private by default, but there are exceptions. Mostly when the scalar has or potentially has a global reference such as being a module variable, or passed into a device subroutine (Fortran uses pass by reference unless the “value” attribute is added to the variables declaration in the subroutine). Also, if the scalar is put in a data clause, including a “declare” directive, then it becomes shared and not private by default.

Are any of these cases applicable to this scalar?


1 Like

Hi Mat,

Yes, they were global scalars. So I guess that’s the reason. Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.