segmentation error as loop becomes large

General OpenMP discussion

segmentation error as loop becomes large

Postby tomguest » Thu Jun 05, 2008 4:05 am

Hi

The code below seems to work when the value of 'num' is small (<5000). When the value of num is increased to say 20,000 the program compiles but gives a segmentation fault at runtime.

I'm only writing to the TEST array to make sure I get the correct answer and if i take it out it has no effect. TEST is defined as a real*4 array, size (num,121,2). If I compile without the openmp flag all is fine.

Any help would be great.

Thanks

Tom



!$OMP PARALLEL SHARED(NTHREADS,CHUNK,testa,offsetloop) PRIVATE(TID)
TID = OMP_GET_THREAD_NUM()
IF (TID .EQ. 0) THEN
NTHREADS = OMP_GET_NUM_THREADS()
PRINT *, 'Number of threads =', NTHREADS
END IF
PRINT *, 'Thread',TID,' starting...'
!$OMP DO SCHEDULE(DYNAMIC,CHUNK) PRIVATE(offsetloop,I,MODELVAL,RC)
DO OFFSETLOOP=1,121
DO I=1,num
C calculate model parameter value
MODELVAL=(ran(idum)*(M(2)-M(1)))+(M(1))
OFFSET=((OFFSETLOOP-1.)/200.)*5000.
CALL CALCRC(MODELVAL,OFFSET,RC,idum)
TEST(I,OFFSETLOOP,1)=MODELVAL
TEST(I,OFFSETLOOP,2)=RC
ENDDO
ENDDO
!$OMP END DO
!$OMP END PARALLEL
tomguest
 
Posts: 2
Joined: Sun May 11, 2008 9:20 am

Re: segmentation error as loop becomes large

Postby ejd » Thu Jun 05, 2008 5:01 am

You didn't say what compiler or OS you were using - which would help me give more information.

I would look to make sure that you are not stepping outside the boundary of an array. For example, from your code segment, I don't know if "ran" is an array or how big it is (or if it is some function call). A lot of compilers have some option to check and see whether or not an array is going out of bounds.

The other thing to check, is whether you have enough stack space. Again, depending on the compiler and runtime you are using, there are certain defaults being used for the stack size of the outlined parallel routine. That means that an array can get too big to fit in that space and the stack size will need to be increased (for the master and slave threads). Usually the master thread's size is controlled by some OS level command (in UNIX , depending on the shell, something like "limit -stacksize"). The slave threads are usually controlled by some environment variable specific to the runtime (in OpenMP Version 3 this is standardized to OMP_STACKSIZE).

I also see that you have a race condition with "offset".
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: segmentation error as loop becomes large

Postby tomguest » Thu Jun 05, 2008 5:04 am

I'm using Scientific Linux with the intel fortan compiler.

I have managed to get it working by increasing the stack size.

Thanks for you help
tomguest
 
Posts: 2
Joined: Sun May 11, 2008 9:20 am


Return to Using OpenMP

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests

cron