Problem with OMP (fortran 90, VS2013, XE14)

General OpenMP discussion

Problem with OMP (fortran 90, VS2013, XE14)

Postby Markou » Wed Feb 26, 2014 10:57 am

Hi everyone,

I have an issue with OMP which I am recently using so as to incorporate parallel processing in my in house algorithm.

As the title implies I am using Visual Studio 2013 with the latest XE14 Fortran compiler. The language that the software is written in, is Fortran 90.

Given that the number of executable lines is large and also due to the fact that I am new with OMP, I decided to take it step by step and compile the algorithm frequently so as to make sure that the applied changes do not affect the results that derive from the sequential execution of the software, thus solve a benchmark model every time and notice any changes in the results.

Now here is the funy thing about what I experienced so far: I activated the choice within the Project's properties for OMP to generate parallel code (Generate Parallel Code (/Qopenmp)-->Generate Parallel Code) and then added a simple command in order to initialize the threads (which works properly given that I get 4 threads).
!$OMP PARALLEL SHARED (threads)
threads = OMP_GET_NUM_THREADS()
!$OMP END PARALLEL
After compiling the code and running for the bench, the results were not the same while the algorithm was diverging (and when running with Disabled OMP, converting the OMP command to a comment, everything is fine again). I tried to debugging line by line so as to allocate the problem but got nothing. One of the observations that I made was that the initialization values of the newlly allocated varaibles were different from those of the sequntial compilation, but given that I use an initialization procedure (setting all newlly varaibles to zero) this should not be an issue. I was wondering if there is a chance that the OMP option tries to apply parallelization by default to loops or other command blocks (even without the presence of the!$OMP command) and some procedures get messed up.

Before doing anything I experimented a lot with simple loop commands by creating small programs that use !$OMP PARALLEL DO and !$OMP PARALLEL sections commands, whereas all went well. I managed to get all 4 cores working 100% at the same time so I verified that the commands were given in the proper manner. Regarding the above issue though I am running out of ideas.

Any suggestions would be highly appreciated.

Regards,

George
Markou
 
Posts: 3
Joined: Wed Feb 26, 2014 9:16 am

Re: Problem with OMP (fortran 90, VS2013, XE14)

Postby MarkB » Thu Feb 27, 2014 4:08 am

Hi George,

Markou wrote:One of the observations that I made was that the initialization values of the newlly allocated varaibles were different from those of the sequntial compilation, but given that I use an initialization procedure (setting all newlly varaibles to zero) this should not be an issue. I was wondering if there is a chance that the OMP option tries to apply parallelization by default to loops or other command blocks (even without the presence of the!$OMP command) and some procedures get messed up.


OpenMP does not attempt any auto-parallelisation. Enabling OpenMP has the effect of making all local variables in subroutines stack allocated (with OpenMP disabled the compiler can choose to allocate on the heap instead). This is probably why you see the different values in uninitialised variables: it would be worth a check to see that you haven't missed any initialisations. Another effect is that if you are assuming that values in local variables persist between subroutine calls without using the SAVE attribute, then compiling with OpenMP can cause the code to break. One final possibility is that it can cause stack overflows, but I would normally expect to see a segmentation fault if that were the case.

Hope that helps,
Mark.
MarkB
 
Posts: 481
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Problem with OMP (fortran 90, VS2013, XE14)

Postby Markou » Thu Feb 27, 2014 5:09 am

Thank you Mark for your informative comments. What you wrote makes absolute sense given that the "diagnosis" fits the symptoms.

Usually I use Interfaces but not every where. Do you believe that by introducing additional Interfaces this will solve the problem without the need of the SAVE attribute command?
Markou
 
Posts: 3
Joined: Wed Feb 26, 2014 9:16 am

Re: Problem with OMP (fortran 90, VS2013, XE14)

Postby MarkB » Thu Feb 27, 2014 6:42 am

Using interfaces of itself doesn't solve the problem, but if you mean pass all values up and down via the argument list instead of using the SAVE attribute, then yes, that will work, though it can get tedious with deep call trees. One problem with using SAVE is that the variables are then shared between threads by default, so you may need to declare them threadprivate.
MarkB
 
Posts: 481
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Problem with OMP (fortran 90, VS2013, XE14)

Postby Markou » Thu Feb 27, 2014 10:02 pm

I already pass all my variables by using IN and OUT attributes so as to distinguish between local and global variables.

Mark I will not spend more from your valuable time. I believe now that I know what to look for I will solve this quickly.

Thank you again for the information about OMP's different compilation behavior.

Regards,

George
Markou
 
Posts: 3
Joined: Wed Feb 26, 2014 9:16 am


Return to Using OpenMP

Who is online

Users browsing this forum: Majestic-12 [Bot], Yahoo [Bot] and 8 guests