Title: | Kuck Associates Preprocessor Users |
Notice: | KAP V2.1 (f90,f77,C) SSB-kits - see note 2 |
Moderator: | HPCGRP::DEGREGORY |
Created: | Fri Nov 22 1991 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 390 |
Total number of notes: | 1440 |
The following [simplified ] code has to be parallelized with GUIDE and it fails. Does anybody know why ? /Joseph ----------------------------------------------------------- To proceed with the max-planck project I need to isolate a reference case where the serial code produces exactly the same numbers as the parallel one. One modification includes replacing the ran() function with an array that gets assigned prior to the || region. This should work like the attached simplified code which calculates 2 partial sums. Instead of using a do-loop I use a routine that increments the index. This is analogous to Maxplank as I don't know at the onset how many ran's are needed (data dependent ). The code herein does not produce repeatable data and it sometimes fails due to an exception (presumably because the array upper bound is exceeded) Can anybody see what's wrong with this ? real a(10) common /pointer/ jp c$par instance parallel /pointer/ integer ip,ul,ll do i=1,10 a(i)= i*0.1+i*i*0.001 end do c c serial s1=0.0 s2=0.0 do i=1,5 s1=s1+a(i) end do c do i=6,10 s2=s2+a(i) end do c do i=1,10 write(*,*)'i,a ',i,a(i) end do write(*,*) write(*,*)'serial s[1-5],s[6-10]',s1,s2 write(*,*) write(*,*) c c parallel sp =0.0 c$par parallel c$par& local(sp,ip,ul,ll) c$par& shared(a) if (mppnth() .ne. 2 ) then write(*,*)' this only works with 2 threads ' stop else if (mpptid() .eq. 0) then jp = 0 else jp = 5 end if ll = mpptid()*5+1 ul = ll+4 write(*,*)'setup-th ',mpptid(),' ll,ul,in-jp ',ll,ul,jp do while (jp .ge. ll .and. jp .le. ul) call increment sp=sp+a(jp) write(*,*)'s-loop-th',mpptid(),'jp,a',jp,a(jp) end do end if 5 write(*,*)' message from th ',mpptid(),'sum =',sp c$par end parallel end subroutine increment common /pointer/ jp c$par instance parallel /pointer/ jp=jp+1 return end rawhide.rto.dec.com> a.out serial s1,s2 1.555000 4.330000 setup-th 0ll,ul 1 5 s-loop-th 0jp,a 6 0.6360000 message from th 0sum = 0.6360000 setup-th 1ll,ul 6 10 s-loop-th 1jp,a 7 0.7490000 s-loop-th 1jp,a 8 0.8640000 s-loop-th 1jp,a 9 0.9810001 s-loop-th 1jp,a 10 1.100000 forrtl: error (65): floating invalid Abort process (core dumped) rawhide.rto.dec.com>
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
364.1 | Try printing sp inside the loop | WIBBIN::NOYCE | Pulling weeds, pickin' stones | Tue Feb 04 1997 08:28 | 9 |
> c > c parallel > sp =0.0 > c$par parallel > c$par& local(sp,ip,ul,ll) > c$par& shared(a) Don't you want to initialize (the local variable) sp *inside* the parallel region, so that each thread's copy starts at 0.0? | |||||
364.2 | Please Call KAI ... | HPCGRP::MANLEY | Tue Feb 04 1997 10:32 | 15 | |
Joseph, > The following [simplified ] code has to be parallelized with GUIDE > and it fails. Does anybody know why ? While it was very kind of Bill to offer a (quite likely correct) suggestion in .1, GUIDE is not a Digital Distributed product and is not supported by Digital. Please refer all further GUIDE questions directly to Kuck and Associates, Inc. Thanks. Best Regards, - Dwight - | |||||
364.3 | solution from KAI | RTOMS::PARETIJ | Tue Feb 04 1997 12:57 | 66 | |
The main problem in 364.0 is that the common /pointer/ gets declared but not allocated. (there are also a couple of bugs on the loop limits ) Here follows the correct one : Thanks for your help -------------------- real a(10) common /pointer/ jp c$par instance parallel /pointer/ integer ip,ul,ll do i=1,10 a(i)= i*0.1+i*i*0.001 end do c c serial s1=0.0 s2=0.0 do i=1,5 s1=s1+a(i) end do c do i=6,10 s2=s2+a(i) end do c do i=1,10 write(*,*)'i,a ',i,a(i) end do write(*,*) write(*,*)'serial s[1-5],s[6-10]',s1,s2 write(*,*) write(*,*) c c parallel sp =0.0 c$par parallel c$par& local(sp,ip,ul,ll) c$par& shared(a) C$PAR NEW /POINTER/ if (mppnth() .ne. 2 ) then write(*,*)' this only works with 2 threads ' stop else if (mpptid() .eq. 0) then jp = 0 else jp = 5 end if ll = mpptid()*5 ul = ll+4 write(*,*)'setup-th ',mpptid(),' ll,ul,in-jp ',ll,ul,jp do while (jp .ge. ll .and. jp .le. ul) call increment sp=sp+a(jp) write(*,*)'s-loop-th',mpptid(),'jp,a',jp,a(jp) end do end if 5 write(*,*)' message from th ',mpptid(),'sum =',sp c$par end parallel end subroutine increment common /pointer/ jp c$par instance parallel /pointer/ jp=jp+1 return end |