On Apr 29, 7:08 am, Charles Coldwell <coldw...@[EMAIL PROTECTED]
> wrote:
> jomarbue...@[EMAIL PROTECTED]
writes:
> > On Apr 27, 5:14 pm, Charles Coldwell <coldw...@[EMAIL PROTECTED]
> wrote:
>
> >> IIUC, the problem was in a section of code that looks something like
> >> this:
>
> >> !$omp parallel do private(wk, i2, i1) shared(x, z)
> >> do i2 = 1, N2
> >> do i1 = 1, N1
> >> wk(i1) = x(i1, i2)
> >> end do
> >> call <NetLibSubroutine>(wk, z, <other stuff>)
> >> do i1 = 1, N1
> >> x(i1, i2) = wk(i1)
> >> end do
> >> !$omp end parallel do
>
> >> The problem here is most likely coming in the second DO loop.
> >> Although wk is private, x is shared, and all the threads are
executing
> >> the same iterations over i1, and therefore clobbering each other's
> >> lvalues.
>
> > Thank you for your answer. I am a bit puzzled about your explanation
> > that the threads are clobbering each other's lvalues in the second
> > loop. I might be missing something in the way that OpenMP works. As I
> > understand, the parallel do directive before the outer loop will make
> > sure that different threads use different non-overlaping sets of
> > values of i2. Thus I'd expect that at a given time each thread is
> > working on a different column of x, thus the memory location x(i1, i2)
> > written too in the second inner loop is different for each thread
> > (that is, even though all threads write to the same set of rows, they
> > are writing different columns). Am I correct in this assumption or am
> > I missing something fundamental about OpenMP?
>
> No, you are correct. Sorry for the red herring. However, "z" is
> shared in the example above. So if several threads are calling
> "<NetLibSubroutine>(wk, z, <other stuff>)" simultaneously, could that
> be the problem?
>
> Chip
>
> --
> Charles M. "Chip" Coldwell
> "Turn on, log in, tune out"
> GPG Key ID: 852E052F
> GPG Key Fingerprint: 77E5 2B51 4907 F08A 7E92 DE80 AFA9 9A8F 852E 052F
Hi Chip,
Thank you for your response.
I also considered the possibility of the array z causing the problem.
Since the array is not too large, I made it into a 2D array z(M,0:*)
and tried three approaches. 1) In serial ****tion I initialize z(:,0)
and copy it to z(:,it), it = 1, 2, ... Nt-1 (Nt is the number of
threads in the team). 2) In the parallel section, a single thread
initializes z(:,0) and copies it to z(:,it), it = 1, ..., Nt-1. Then
the rest of the threads work with it. 3) In the parallel section
thread it initializes z(:,it), even though all initializations are the
same. Neither of the three approaches worked. Sometimes random
results come back from the Netlib subroutine, other times the program
hangs after entering the Netlib subroutine. I know that the Netlib
subroutines have been thoroughly tested and are very robust in serial
programs, so I know the problem is not the Netlib subroutine itself
but the way OpenMP is handling variables local to the subroutines.
Thanks again for your response
Jomar


|