I'm watching this Introduction to OpenMP series of videos, and the presenter keeps repeating that "heap is shared, stack is private". It is also mentioned that data and text areas are shared. However he gives examples where stack variables of the parent thread are obviously shared and he keeps referring to those variables as being "on the heap". Here's an example:
https://youtu.be/dlrbD0mMMcQ?t=2m57s
He claims that variables index
and count
are "on the heap". Isn't index
on the stack of the parent thread? Isn't count
a static variable, and so part of the data area? In my own OMP programs, if I print the address of such variables they appear to be on the stack and data area, respectively. This is not the only place so far that he has referred to variables as "on the heap" that from what I can tell, are shared, but not on the heap. I just want to make sure I'm not missing something about the way OMP works.
Reading the specification, the clearest statement I could find of this for "implicit sharing" of stack variables outside the parallel region:
For constructs other than task generating constructs or target constructs, if no default clause is present, these variables reference the variables with the same names that exist in the enclosing context
OpenMP 4.5 Specification p.182