OpenMP® Forum

Discussion on the OpenMP specification run by the OpenMP ARB. OpenMP and the OpenMP logo are registered trademarks of the OpenMP Architecture Review Board in the United States and other countries. All rights reserved.http://forum.openmp.org/forum/

Re: help with OMP fortran

Thanks for your reply. I've used your suggestions(!$OMP PARALLEL DO &!$OMP PRIVATE(Sol, Rhs, Ped, D, v, Asub, m, n,K,I,J)) but still the program crashes. This is the output:

4483144 animals in the pedigree second reading : 4483144 animals in the pedigree Commencing Colleau calculations for sub-matrix : Number of animals in the subset matrix of A is : 2388*** glibc detected *** ./collaeuSegmentation fault (core dumped)

I have included l in the privite section but still the result is the same. I really need to make this work because in reality the number of animals in the submatrix is about 30,000.I will really appreciate your help. Thanks again.

Kon

Re: help with OMP fortran

Posted: Thu Jun 07, 2012 11:42 am

by MarkB

Hi Kon,

You are clearly a bit confused about which variables should be shared and which private!

n,m, Ped, D, and indx1 are all read-only inside the parallel loop: these variables should be shared, since making them private creates uninitialised copies on each thread (as Fernando pointed out).

Asub should also be shared as it is required after the loop: there is no race condition since different threads access different parts of it.

i, j, and k are automatically private since they are loop indices (but declaring them private does no harm).

Rhs, Sol and v should be private: they are temporary arrays which are overwritten on each k iteration.

Re: help with OMP fortran

Maybe this is a minor detail, but I would not use both compiler options

-openmp -lpthread

Why do you use both?

Fernando.

Re: help with OMP fortran

Posted: Thu Jun 07, 2012 4:31 pm

by kon

Dear all,

Thank you very much for your help. Let me briefly explain what I am trying to do. I have a huge matrix of size 4,483,144 x 4,483,144, from which I want to extract a sub-matrix with dimensions 2,388 x 2,388. Yes, as Mark pointed out, I am a bit confused about which variables should be shared and which private. His notes however made the picture clearer. I’ve made the changes as suggested and the result is the same:

4483144 animals in the pedigree second reading : 4483144 animals in the pedigree Commencing Colleau calculations for sub-matrix : Number of animals in the subset matrix of A is : 2388 Segmentation fault (core dumped)

Also I got rid of –lpthread from the compilation. Note also that in my code I’ve commented out the line !WRITE(2,FMT='(2i10,f15.5)') k, j, v(indx1(j)This line was written just to see what is happening and it is not important for the computations. Note also that the program crashes with and without declaration of shared variables.

Kon

Re: help with OMP fortran

Posted: Fri Jun 08, 2012 2:26 am

by MarkB

Can you test your code for correctness on a (much) smaller dataset first?

You may be running out of stack space, since you are creating some quite large private arrays. You can set the stack size for the master thread by using ulimit -s (on Unix/Linux), and the stack size for other OpenMP threads by setting the OMP_STACKSIZE environment variable (you may need to do both: say 200MB should be enough).

Re: help with OMP fortran

Posted: Fri Jun 08, 2012 3:57 am

by ftinetti

Hi Kon,

Besides of what MarkB suggests: what is the line in which the program crashes? is it always the same?