- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
program md
implicit none
integer n
integer m
parameter(n=300,m=500)
real*8 array2d(n,m)
integer i
integer j
do i=1,n
do j=1,m
array2d(i,j) = i + j
enddo
enddo
end
This program works correct, but after compilation with /Qopenmp parameter it causes stack overflow exception. I suppose this is connected with size of array because decreasing quantity of elements in it allows avoiding this error. I've tried to change KMP_STACKSIZE but it doesn't help.
Also I've tested this source code with Linux FORTRAN Compiler and get the same result.
Have anyone faced with this kind of problem? Could You help me?
Thanks in advance.
- Marcas:
- Intel® Fortran Compiler
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
When you use /Qopenmp, one of the side effects of that is to imply /auto - that is, all local variables, even arrays, are allocated on the stack (other than those with SAVE semantics). This means that an OpenMP application almost always needs a larger than default stack allocation. You can set it at link time or use EDITBIN as Tim suggests to change the value in an EXE, but there is no process-level control over this.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
iterator,
In your program is your intention to have array2d shared amongst threads or seperate copies for each thread?
If shared then try something like
module md_data
integer, parameter :: n = 300
integer, parameter :: m = 500
real(8) :: array2d(n,m)
end module md_data
program md
use md_data
implicit none
integer i
integer j
!$omp parallel do private(i,j)
do i=1,n
do j=1,m
array2d(i,j) = i + j
enddo
enddo
!$omp end parallel do
end
Jim Dempsey
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Thank you for good explanation. It was very helpful.
JimDempseyAtTheCove,
Yes, now I'm modifying my program in this way. But mentioned problem arose before any code modification with adding OpenMP directives (that source code was just for instance). Now the problem is solved. Thanks to all.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Iterater,
Hint for you.
You will find that Stack pressure increases with number of threads. As you have experienced, code that used to work fine in single threaded environment may run into problems in multi-threaded environments. Shared items can be moved from the stack into module space (or COMMON) as you have indicated you are in the process of doing.
Another area of concern is some subroutines require the use of temporary arrays. You can specify that the local arrays are to be allocated on the heap but this may add unnecessary overhead (performing allocate and deallocate). To eliminate this overhead I use ThreadPrivate storage to contain a pointer to a user defined structure that contains the list of temporary arrays. Upon entry to the subroutine I get the thread private pointer to the list of temporary arrays then query the size of the array of interest to see if it is large enough to perform the current operation. If not large enough (or not allocated in the case of first time) the current array is deallocated and a new one is allocated. In this manner each thread's temporary array (for the subroutine) gets sized and resized as necessary. The overhead to de-reference the ThreadPrivate pointer is much less than the allocation/deallocation.
Jim Dempsey
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
PS: Under Windows everything works ok (I use /STACK linker option)

- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora