1

I'm using Open MP with Fortran 08 (compiled with GFortran) to create nested parallel regions (in my case, a 3-level nest). Before running my executable, I set some Linux environment variables to facilitate this nesting structure. In particular, I set OMP_NESTED=True, OMP_MAX_ACTIVE_LEVELS=3, OMP_NUM_THREADS=2,7,1, and OMP_STACKSIZE=4g.

My issue is that I think OMP_STACKSIZE sets the stack size of each thread, regardless of which level of the nested parallel region the thread is in. I have set the stack size high, since the first-level threads need a large amount of stack memory. However, the second- and third-level threads do not need nearly this much stack memory. Is there any way to set different stack sizes for different parallel regions? I haven't yet found a method using either Linux environment variables or the OMP libraries within Fortran.

3
  • 1
    Unused stack memory does not cost you anything. The stack size just reserves an address block from your virtual memory space. Commented Apr 3 at 19:39
  • 1
    Unused memory still costs some memory capacity. If it is in gigabytes per stack frame, it can be significant. However, I would rather think about fixing the code to not require such huge stack - most likely by using allocatable arrays. I also suggest taking the tour and reading How to Ask. Commented Apr 4 at 5:55
  • @VladimirFГероямслава while I agree with your suggestion towards using allocatables, I cannot agree with your statement regarding memory consumption. As long as the threads don't use the reserved stack space, the memory is not allocated and not consumed. The reservation consumes address space, but not memory space. And we typically have 2**48 byte of address space, while 4G are just 2**32. Commented Apr 4 at 17:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.