Linux memory layout
Linux memory layout for OpemMP programs
128 TB --------------------------------- Top of memory | thread 0 (master) stack | local variables \ / / \ | | heap (allocate/malloc) ~44 TB --------------------------------- | thread N stack | \ / | thread N-1 stack | \ / ... | thread 1 stack | \ / / \ | code + static data | (common blocks + some main program arrays) | 000 ---------------------------------- Bottom of memory
FORTRAN program used:
program omp_test integer bigmachin(1024*1024*384) integer, pointer, dimension(:) :: a integer b integer*8 result(-1:100) common /zzz/ia(1) common //ib(1) result=-1 !$OMP parallel call toto(result) !$OMP end parallel ! result(-1)=result(0) do i=100,0,-1 if(result(i).gt.0)print 100,'thread stack',result(i),result(i),' stack= ',i,' delta=',result(i)-result(i-1) enddo ! allocate(a(1024*1024*256)) print 100,'program scalar',loc(b),loc(b) print 100,'program array',loc(result),loc(result) print 100,'program array(big)',loc(bigmachin),loc(bigmachin) print 100,'Heap high',loc(a(1024*1024*256)),loc(a(1024*1024*256)) print 100,'Heap low',loc(a(1)),loc(a(1)) print 100,'named common',loc(ia(1)),loc(ia(1)) print 100,'blank common',loc(ib(1)),loc(ib(1)) print 100,'subroutine',loc(toto),loc(toto) 100 format(a,T20,z16.16,i18,a,i2,a,z16.16) stop end subroutine toto(arg) integer *8 arg(-1:100) integer value, value2, omp_get_stack_size external omp_get_stack_size integer omp_get_thread_num external omp_get_thread_num integer auto(100) auto=2 do i=1,100 result=result+auto(i) enddo value2=omp_get_thread_num() arg(value2)=loc(auto) return end