OpenMP problem

View: New views
6 Messages — Rating Filter:   Alert me  

OpenMP problem

by Carlos Alberto Bulant :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm using cygwin, gfortran-4 compiler, in NetBeans IDE. My pc has WinXP SP3.

I'm trying to introduce parallel processing to my project, i've been
reading about OpenMP, so i make this litle code to test it:

//-------------------------------------------------------------------------------------------------
    PROGRAM HELLO
!$      USE omp_lib

       INTEGER n, i
       PARAMETER (n=505150)
       REAL X(n)


!$      call omp_set_num_threads(2)
       write(6, "(a, i3)") " OpenMP max threads: ",
    +        OMP_GET_MAX_THREADS()

!$OMP PARALLEL
       write(6, "(2(a,i3))") " OpenMP: N_threads = ",
    +      OMP_GET_NUM_THREADS(), " thread = ", OMP_GET_THREAD_NUM()
!$OMP END PARALLEL


!$OMP   PARALLEL DO
!$OMP+  SHARED(X)
!$OMP+  PRIVATE(i)
             DO i = 1, n
                X(i) = i
!$              !write(*, *) "  From Thread = ", OMP_GET_THREAD_NUM(), " i= ",i
             END DO
!$OMP   END PARALLEL DO

     END PROGRAM
//-------------------------------------------------------------------------------------------------

The program runs ok with n<= 505150
with 505150 > n >= 505170 The output is from one thread only
with n > 505170 i get a runtime error, the cause is stack overflow.

i set windows environment variables
OMP_STACKSIZE=10000
GOMP_STACKSIZE=10000

but i get the same behaviour...

any ideas???


I intent to use openMP in a project with big multidemensional arrays,
but it seams the stack size limitation of the omp threads is going to
impede it...

i don't understand why they need a big stack, are they (the threads)
copiyng the share array into each stack? isn't enough with a pointer to
them?...

carlitos

Re: OpenMP problem

by Steve Kargl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 30, 2009 at 11:24:21PM -0300, Carlos Alberto Bulant wrote:

> The program runs ok with n<= 505150
> with 505150 > n >= 505170 The output is from one thread only
> with n > 505170 i get a runtime error, the cause is stack overflow.
>
> i set windows environment variables
> OMP_STACKSIZE=10000
> GOMP_STACKSIZE=10000
>
> but i get the same behaviour...
>
> any ideas???

Don't use windows. :-)

> I intent to use openMP in a project with big multidemensional arrays,
> but it seams the stack size limitation of the omp threads is going to
> impede it...
>
> i don't understand why they need a big stack, are they (the threads)
> copiyng the share array into each stack? isn't enough with a pointer to
> them?...

Yesi and no.

--
Steve

Parent Message unknown RE: OpenMP problem

by Carlos Alberto Bulant :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

i found that using -fno-automatic, the code worked just find, i could
make x array grow up to 1.5GB...
(obviously, i don't need the envairoment variables any more...)

something interesting is that compiling the fortran code us a static
library, i don't need to use -fno-automatic.
And i can use the subroutine from C++ linking it with -lgfortran
-lgomp. and it works ok.

Now i will try to introduce my real fortran project with openmp, and
see what happen...

thanks a lot

carlitos

Re: OpenMP problem

by Jerry DeLisle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Carlos Alberto Bulant wrote:

> Hello,
>
> I'm using cygwin, gfortran-4 compiler, in NetBeans IDE. My pc has WinXP SP3.
>
> I'm trying to introduce parallel processing to my project, i've been
> reading about OpenMP, so i make this litle code to test it:
>
> //-------------------------------------------------------------------------------------------------
>     PROGRAM HELLO
> !$      USE omp_lib
>
>        INTEGER n, i
>        PARAMETER (n=505150)
>        REAL X(n)
>
>
> !$      call omp_set_num_threads(2)
>        write(6, "(a, i3)") " OpenMP max threads: ",
>     +        OMP_GET_MAX_THREADS()
>
> !$OMP PARALLEL
>        write(6, "(2(a,i3))") " OpenMP: N_threads = ",
>     +      OMP_GET_NUM_THREADS(), " thread = ", OMP_GET_THREAD_NUM()
> !$OMP END PARALLEL
>
>
> !$OMP   PARALLEL DO
> !$OMP+  SHARED(X)
> !$OMP+  PRIVATE(i)
>              DO i = 1, n
>                 X(i) = i
> !$              !write(*, *) "  From Thread = ", OMP_GET_THREAD_NUM(), " i= ",i
>              END DO
> !$OMP   END PARALLEL DO
>
>      END PROGRAM
> //-------------------------------------------------------------------------------------------------
>
> The program runs ok with n<= 505150
> with 505150 > n >= 505170 The output is from one thread only
> with n > 505170 i get a runtime error, the cause is stack overflow.
>
> i set windows environment variables
> OMP_STACKSIZE=10000
> GOMP_STACKSIZE=10000
>
> but i get the same behaviour...
>
> any ideas???

It could be you are just too big for your machine.  Also, when you set
environment variables, they do not always 'take' to cygwin terminals that are
already open, so you may want to close and reopen everything after setting
environment variables.

Although I do build a gfortran binary for Cygwin and I use Cygwin on occasion
for real work, I am not a big fan of using windows for serious work.  At the
Cygwin web site there are discussions about non-Cygwin apps that do things that
interfere called BLODA I think. Flip side, Cygwin actually works pretty damn
good most of the time.

Also, check your question at comp.lang.fortran news list.  Those folks have a
lot of combined experience.

Jerry

Re: OpenMP problem

by Tim Prince-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jerry DeLisle wrote:

> Carlos Alberto Bulant wrote:
>> Hello,
>>
>> I'm using cygwin, gfortran-4 compiler, in NetBeans IDE. My pc has
>> WinXP SP3.
>>
>> I'm trying to introduce parallel processing to my project, i've been
>> reading about OpenMP, so i make this litle code to test it:
>>
>> //-------------------------------------------------------------------------------------------------
>>
>>     PROGRAM HELLO
>> !$      USE omp_lib
>>
>>        INTEGER n, i
>>        PARAMETER (n=505150)
>>        REAL X(n)
>>
>>
>> !$      call omp_set_num_threads(2)
>>        write(6, "(a, i3)") " OpenMP max threads: ",
>>     +        OMP_GET_MAX_THREADS()
>>
>> !$OMP PARALLEL
>>        write(6, "(2(a,i3))") " OpenMP: N_threads = ",
>>     +      OMP_GET_NUM_THREADS(), " thread = ", OMP_GET_THREAD_NUM()
>> !$OMP END PARALLEL
>>
>>
>> !$OMP   PARALLEL DO
>> !$OMP+  SHARED(X)
>> !$OMP+  PRIVATE(i)
>>              DO i = 1, n
>>                 X(i) = i
>> !$              !write(*, *) "  From Thread = ", OMP_GET_THREAD_NUM(),
>> " i= ",i
>>              END DO
>> !$OMP   END PARALLEL DO
>>
>>      END PROGRAM
>> //-------------------------------------------------------------------------------------------------
>>
>>
>> The program runs ok with n<= 505150
>> with 505150 > n >= 505170 The output is from one thread only
>> with n > 505170 i get a runtime error, the cause is stack overflow.
>>
>> i set windows environment variables
>> OMP_STACKSIZE=10000
>> GOMP_STACKSIZE=10000
>>
>> but i get the same behaviour...
>>
>> any ideas???
>
> It could be you are just too big for your machine.  Also, when you set
> environment variables, they do not always 'take' to cygwin terminals
> that are already open, so you may want to close and reopen everything
> after setting environment variables.
>
> Although I do build a gfortran binary for Cygwin and I use Cygwin on
> occasion for real work, I am not a big fan of using windows for serious
> work.  At the Cygwin web site there are discussions about non-Cygwin
> apps that do things that interfere called BLODA I think. Flip side,
> Cygwin actually works pretty damn good most of the time.
>
> Also, check your question at comp.lang.fortran news list.  Those folks
> have a lot of combined experience.
>
> Jerry
I haven't had any real success with gomp on Windows, including cygwin,
even for tests just large enough to show OpenMP performance which run
fine on my laptop under linux, and with ifort on Windows.
It seems to be too heavy a load for gcc developers to handle Windows
along with the more amenable systems.  I try nearly every week to make a
new build of gcc/g++/gfortran on cygwin, but the last successful one
(excellent, apart from gomp) was 6 weeks ago.  It takes several days to
build and test, compared with a couple hours on linux, and the test
suite is perhaps unacceptably unreliable on Windows.
I kept persevering with cygwin in the so far mistaken idea that the
market might consolidate on a good Windows version.  It seemed almost
about to happen with Windows 2000.  Now Windows 7 x64 and 2008 R2 x64
are the next candidates, but cygwin is sure not to catch up soon even if
those do come into wide use.
Even the braggarts with axes to grind fall down when asked to
demonstrate their claim that Windows is easier to use than linux.  It
still takes weeks for the experts from Microsoft to set up a moderately
large Windows MPI cluster, which can be done in a day by a linux
sysadmin.  Then the job submission scripts for Windows contain double
the obscurity of linux equivalents, which are bad enough.
I do expect to be presiding over a 32 core single motherboard Windows
demonstration at SC09, in case you think I'm too prejudiced against
Windows. Don't know if anyone tried cygwin yet on that machine.l
Tim

Re: OpenMP problem

by Danny Smith :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


----- Original Message -----
From: "Carlos Alberto Bulant" <carlos.alberto.bulant@...>
To: <fortran@...>
Sent: Saturday, October 31, 2009 3:24 PM
Subject: OpenMP problem


> Hello,
>
> I'm using cygwin, gfortran-4 compiler, in NetBeans IDE. My pc has WinXP
> SP3.
>
> I'm trying to introduce parallel processing to my project, i've been
> reading about OpenMP, so i make this litle code to test it:
>
> //-------------------------------------------------------------------------------------------------
>    PROGRAM HELLO
> !$      USE omp_lib
>
>       INTEGER n, i
>       PARAMETER (n=505150)
>       REAL X(n)
>
>
> !$      call omp_set_num_threads(2)
>       write(6, "(a, i3)") " OpenMP max threads: ",
>    +        OMP_GET_MAX_THREADS()
>
> !$OMP PARALLEL
>       write(6, "(2(a,i3))") " OpenMP: N_threads = ",
>    +      OMP_GET_NUM_THREADS(), " thread = ", OMP_GET_THREAD_NUM()
> !$OMP END PARALLEL
>
>
> !$OMP   PARALLEL DO
> !$OMP+  SHARED(X)
> !$OMP+  PRIVATE(i)
>             DO i = 1, n
>                X(i) = i
> !$              !write(*, *) "  From Thread = ", OMP_GET_THREAD_NUM(), "
> i= ",i
>             END DO
> !$OMP   END PARALLEL DO
>
>     END PROGRAM
> //-------------------------------------------------------------------------------------------------
>
> The program runs ok with n<= 505150
> with 505150 > n >= 505170 The output is from one thread only
> with n > 505170 i get a runtime error, the cause is stack overflow.
>
> i set windows environment variables
> OMP_STACKSIZE=10000
> GOMP_STACKSIZE=10000
>
> but i get the same behaviour...
>
> any ideas???
>
To increase the stack size on MS windows targets you need to issue the
linker option
-Wl,--stack=0x2000000 (for example) in your build. The default stack size is
2 MB.

Danny