Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29274 Discussions

forrt1: severe (170): Program Exception - stack overflow

ymahmoudi
Beginner
3,730 Views
I run a code to solve the heat equation by OPEN MP got the following error msg.

forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
console2.exe 005174E5 Unknown Unknown Unknown
console2.exe 0045BC32 Unknown Unknown Unknown
console2.exe 00530145 Unknown Unknown Unknown
kernel32.dll 005179B0 Unknown Unknown Unknown
ntdll.dll.dll 77CBE489 Unknown Unknown Unknown

When I did some search, it seemed like I had to increase the stach size. So I did it call KMP_SET_STACKSIZE_S (8000000).
and it still gives the same error msg.
I have Intel Fortran 7.1 and am running it on Visual Studio .net. on Windows xp.
My system is core 2Duo with 4G RAM.

Some parts of my code is as follow:
!-----------------------------------------------------
integer imax, kmax, itmax
parameter (imax=401, kmax=401)
parameter (itmax=1000)
! iteration
do it=1,itmax
!$OMP PARALLEL PRIVATE(i,k,dphi), SHARED(phi, phin, dx2i, dy2i, dt, dphimax)
!$OMP DO
do k=1,kmax-1
do i=1,imax-1
dphi =(phi(i+1,k)+phi(i-1,k)-2.0*phi(i,k))*dy2i+(phi(i,k+1)+phi(i,k-1)-2.0*phi (i,k))*dx2i
phin(i,k)=phi(i,k)+dphi
enddo
enddo
!$OMP END DO
!$OMP END PARALLEL

!-----------------------------------------------------
It works safely for (imax=301, kmax=301), but for (imax=401 , kmax=401) and more i got the stack overflow error.
i searched around this problem but nothing could helped me with this
May any one please tell me what to do.

My email: ymahmoudi@yahoo.com
Regards, Mahmoudi
0 Kudos
8 Replies
Michel
Beginner
3,730 Views
Quoting - ymahmoudi
I run a code to solve the heat equation by OPEN MP got the following error msg.

forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
console2.exe 005174E5 Unknown Unknown Unknown
console2.exe 0045BC32 Unknown Unknown Unknown
console2.exe 00530145 Unknown Unknown Unknown
kernel32.dll 005179B0 Unknown Unknown Unknown
ntdll.dll.dll 77CBE489 Unknown Unknown Unknown

When I did some search, it seemed like I had to increase the stach size. So I did it call KMP_SET_STACKSIZE_S (8000000).
and it still gives the same error msg.
I have Intel Fortran 7.1 and am running it on Visual Studio .net. on Windows xp.
My system is core 2Duo with 4G RAM.

Some parts of my code is as follow:
!-----------------------------------------------------
integer imax, kmax, itmax
parameter (imax=401, kmax=401)
parameter (itmax=1000)
! iteration
do it=1,itmax
!$OMP PARALLEL PRIVATE(i,k,dphi), SHARED(phi, phin, dx2i, dy2i, dt, dphimax)
!$OMP DO
do k=1,kmax-1
do i=1,imax-1
dphi =(phi(i+1,k)+phi(i-1,k)-2.0*phi(i,k))*dy2i+(phi(i,k+1)+phi(i,k-1)-2.0*phi (i,k))*dx2i
phin(i,k)=phi(i,k)+dphi
enddo
enddo
!$OMP END DO
!$OMP END PARALLEL

!-----------------------------------------------------
It works safely for (imax=301, kmax=301), but for (imax=401 , kmax=401) and more i got the stack overflow error.
i searched around this problem but nothing could helped me with this
May any one please tell me what to do.

My email: ymahmoudi@yahoo.com
Regards, Mahmoudi

You can link with this switch
/stack:8000000

Michel.
0 Kudos
ymahmoudi
Beginner
3,730 Views
Quoting - Michel

You can link with this switch
/stack:8000000

Michel.

Dear Michel
Would you explain more about this issue?
how can i link to the switch whichyou mentioned?
0 Kudos
TimP
Honored Contributor III
3,730 Views
It's entirely possible you may require both increased thread stack size (KMP_STACKSIZE for ifort OpenMP) and overall stack size (microsoft link option /link /stack:xxxxxxxx, or adjustment by editbin). You should find both of these described in the ifort help file.
Particularly on 32-bit Windows, you wouldn't want to request increases far beyond what is needed.
0 Kudos
rafadix08
Beginner
3,730 Views
I am also having a program exception problem with my OpenMP parallelized code. The serial code is working properly.
I have tried many of the suggestions I found in this forum and elsewhere, but I am still not able to solve the issue.

I set the heap arrays option to a very high value, as well as the Stack reserve. I also set KMP_STACKSIZE to a high value.

In my code I have the following lines for the parallelization:

Call KMP_SET_STACKSIZE_S(2000000000)

Call omp_set_num_threads(2)

!$omp parallel do
do s = 0, NSECTORS
Call EmpCoef(ChoiceInput,ExperInput,CohortWgt,s,gammaSim(s,:))
end do
!$omp end parallel do

The function EmpCoef locally creates two other dynamic arrays. One of the arrays cannot be created. When the code executes the line:

allocate(XEmp(1:SizeEmp,1:(15+2*NSECTORS)),STAT=status)

I get status = 41, which means I was not able to allocate XEmp.
Curious thing is that the Xemp dimension is not that big: it's (500000, 20)

Many thanks,
Rafael
0 Kudos
Lorri_M_Intel
Employee
3,730 Views
Quoting - rafadix08
I set the heap arrays option to a very high value, as well as the Stack reserve. I also set KMP_STACKSIZE to a high value.

No, set your heap_arrays option to a small number, or don't use any number at all. The number indicates that you want arrays bigger than "N" to be put on the heap.

- Lorri
0 Kudos
rafadix08
Beginner
3,730 Views

No, set your heap_arrays option to a small number, or don't use any number at all. The number indicates that you want arrays bigger than "N" to be put on the heap.

- Lorri

Thanks Lorri, but with no number at all it doesn't work either.
0 Kudos
Steven_L_Intel1
Employee
3,730 Views
Use 0 as the setting in Visual Studio.
0 Kudos
wolf01
Beginner
3,730 Views
Quoting - ymahmoudi
I run a code to solve the heat equation by OPEN MP got the following error msg.

forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
console2.exe 005174E5 Unknown Unknown Unknown
console2.exe 0045BC32 Unknown Unknown Unknown
console2.exe 00530145 Unknown Unknown Unknown
kernel32.dll 005179B0 Unknown Unknown Unknown
ntdll.dll.dll 77CBE489 Unknown Unknown Unknown

When I did some search, it seemed like I had to increase the stach size. So I did it call KMP_SET_STACKSIZE_S (8000000).
and it still gives the same error msg.
I have Intel Fortran 7.1 and am running it on Visual Studio .net. on Windows xp.
My system is core 2Duo with 4G RAM.

Some parts of my code is as follow:
!-----------------------------------------------------
integer imax, kmax, itmax
parameter (imax=401, kmax=401)
parameter (itmax=1000)
! iteration
do it=1,itmax
!$OMP PARALLEL PRIVATE(i,k,dphi), SHARED(phi, phin, dx2i, dy2i, dt, dphimax)
!$OMP DO
do k=1,kmax-1
do i=1,imax-1
dphi =(phi(i+1,k)+phi(i-1,k)-2.0*phi(i,k))*dy2i+(phi(i,k+1)+phi(i,k-1)-2.0*phi (i,k))*dx2i
phin(i,k)=phi(i,k)+dphi
enddo
enddo
!$OMP END DO
!$OMP END PARALLEL

!-----------------------------------------------------
It works safely for (imax=301, kmax=301), but for (imax=401 , kmax=401) and more i got the stack overflow error.
i searched around this problem but nothing could helped me with this
May any one please tell me what to do.

My email: ymahmoudi@yahoo.com
Regards, Mahmoudi

Try this way: On your workplace select Project->settings->Link->Category->Output->Stack allocations->Reserve->8000000, you'll see the Project Options: /stack:0x7a1200. Click OK button return to your workplace and then rebuild your project. This worked for me and I hope it works for you, too.
0 Kudos
Reply