PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

-Mconcur problems in pgf90

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Russell



Joined: 20 Aug 2004
Posts: 4

PostPosted: Fri Aug 20, 2004 4:18 am    Post subject: -Mconcur problems in pgf90 Reply with quote

I am getting incorrect results from a long Fortran 90 program, so I boiled it down to the basic form shown below.

I compile using "pgf90 -o basic -fastsse -Mconcur -Minfo basic.f90".
-Minfo says (for the "do ix .." line) "parallel code for non-innermost
loop generated; block distribution"

When run, it prints the wrong answers for a() - a mix of 3.0, 4.0, 6.0
(should all be 6.0).

Deleting the -fastsee makes no difference.

It does give the correct answer, 6.0 for all a(), if compiled without the
-Mconcur switch.

Also, it gives the correct answer, with -Mconcur, if the commented "if"
statement is uncommented, in which case info reports no parallel code
generated.

Also, it gives the correct answer, with -Mconcur, if I compile with
-Mbounds (no bounds violations reported), in which case info reports no
parallel code generated.

My machine is a dual processor AMD Opteron, 64-bit Redhat Linux
system. PGI work station compiler version 5.2.

The environment variable NCPUS is 2.

No doubt I am doing something wrong, but I can't see what. It looks to
me like the parallel code generated using -Mconcur is not working
properly.

-----------------------------------------------------------------------------------
program basic

implicit none

integer :: ix
integer :: iy

real :: sum
integer :: ns

real, dimension(10, 10) :: a, b

a = 6.0

do ix = 1, 10
do iy = 1, 10

ns = 1
sum = a(ix,iy)

if(ix-1 >= 1) then
sum = sum + a(ix-1,iy)
ns = ns + 1
end if

if(ix+1 <= 10) then
sum = sum + a(ix+1,iy)
ns = ns + 1
end if

if(iy-1 >= 1) then
sum = sum + a(ix,iy-1)
ns = ns + 1
end if

if(iy+1 <= 10) then
sum = sum + a(ix,iy+1)
ns = ns + 1
end if

! if(ix == 5 .and. iy == 5) write(6,*) sum, ns

b(ix,iy) = sum/float(ns)

end do
end do

a = b

write(6,*) a

end program basic
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Fri Aug 20, 2004 12:07 pm    Post subject: Looks like a bug with -Mconcur Reply with quote

Hi Russell,

Thanks for a very good write-up! It appears to me like this is a bug with "-Mconcur". The code fails at 1 thread so its most likely a problem with the generated assembly code. It works if only one of the if statements is used. So its somehow getting confused on the second if statement. I'll go ahead and submit a TPR, and we'll see if we can determine exactly what's going on.

As a work around, we can use OpenMP to parallelize the loop. Before the ix do loop add:

Code:
!$OMP PARALLEL
!$OMP DO PRIVATE (sum, ns)

and add the following after the second end do
Code:
!$OMP END DO
!$OMP END PARALLEL


Compile the code using "-mp" and the set "NCPUS".

I'll try and keep you posted with any progress, but for now hopefully using OpenMP will get you on track.

- Mat
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Fri Aug 20, 2004 1:22 pm    Post subject: TPR 3332 Reply with quote

FYI, I added TPR3332.

-Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group