Problem with nested indexing !

General OpenMP discussion

Problem with nested indexing !

Postby kazempour » Mon Jul 30, 2012 2:49 am

I recently started OpenMP coding, and I want to implement this method on an available MPI code,
There are some loops like below, in code:

DO ind1=1,idatalength
indexglobal=displsfar(indp)+ind1
sxtomvtotal(indexglobal)=sxtomvbuffer(ind1)
ENDDO

And I don't know how to define variables (shared|private) and also how to implement this loop in OpenMP.
Note that my main problem is with "indexglobal" variable. Would you please help me to implement OpenMP on this loop?
I'm looking forward to hear from you.
Regards
kazempour
 
Posts: 13
Joined: Wed Jul 25, 2012 4:11 am

Re: Problem with nested indexing !

Postby MarkB » Mon Jul 30, 2012 7:16 am

indexglobal needs to be private to each thread, so (assuming this is the entire parallel loop) the code would look like this:

Code: Select all
!$OMP PARALLEL DO DEFAULT(NONE) SHARED (sxtomvtotal, sxtomvbuffer, idatalength, displsfar, indp) PRIVATE (indexglobal)
DO ind1=1,idatalength
indexglobal=displsfar(indp)+ind1
sxtomvtotal(indexglobal)=sxtomvbuffer(ind1)
ENDDO
MarkB
 
Posts: 450
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 5 guests