Sections directive

General OpenMP discussion

Sections directive

Postby rpillai » Fri Jan 10, 2014 8:04 am

wish you all a happy new year!

I have a DO loop inside a sections directive (FORTRAN) with the index variable varying according to the ID of the thread. This is to share the task in the SECTIONS directive over various threads. I cannot use a PARALLEL DO loop as the set of commands (function calls and some variables) to be looped need to stay consisent over all threads. So it goes something like this,

!$OMP SECTIONS

f=id(Max/num)+1
U=(id+1)*(L/num)

do i=f,U
task to be performed
enddo

!$OMP END SECTIONS

I then use WRITE to output the variables in ASCII format.

Problem:
Using 2 threads I observe that I get results only for thread 1 and not for the MASTER or thread 0. The ASCII files hold results only for half of the intended array. With more than 2 threads I get the result for any one random thread.

Another issue is that I keep getting different results everytime I run the executable.

The platform is Windows Server 2003 64-Bit and I am using MinGW suite.

Any help is appreciated.

Thank you,
Regards,
Rishi
rpillai
 
Posts: 1
Joined: Thu Dec 12, 2013 2:38 am

Re: Sections directive

Postby MarkB » Tue Jan 14, 2014 3:30 am

Hi Rishi,

It looks like you are expecting all the threads to execute the code inside the SECTIONS construct, but this is not what happens: without any enclosed SECTION directives, the whole body of the SECTIONS construct will be executed by one thread only.

I cannot use a PARALLEL DO loop as the set of commands (function calls and some variables) to be looped need to stay consisent over all threads.


I don't quite understand this - perhaps if you could explain a bit more I might be able to suggest a solution - I suspect that using SECTIONS is not necessary.

Hope that helps,
Mark.
MarkB
 
Posts: 422
Joined: Thu Jan 08, 2009 10:12 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 8 guests