Linux memory layout

Un article de Informaticiens département des sciences de la Terre et l'atmosphère
Version depuis le 21 de novembre 2011 à 14:52 par Michel (Discuter | changes)
(diff) ←Version avant | Version courante (diff) | Version après→ (diff)
Aller à: navigation, charcher

Linux memory layout for OpemMP programs
(The OMP_STACKSIZE environment variable controls thread (>0) stack size)

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