JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: OpenMP API User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information

Preface

1.  Introducing the OpenMP API

2.  Compiling and Running OpenMP Programs

2.1 Compiler Options

2.2 OpenMP Environment Variables

2.2.1 OpenMP Environment Variables Defaults

2.2.2 Oracle Solaris Studio Environment Variables

2.2.2.1 PARALLEL

2.2.2.2 SUNW_MP_WARN

2.2.2.3 SUNW_MP_THR_IDLE

2.2.2.4 SUNW_MP_PROCBIND

2.2.2.5 SUNW_MP_MAX_POOL_THREADS

2.2.2.6 SUNW_MP_MAX_NESTED_LEVELS

2.2.2.7 STACKSIZE

2.2.2.8 SUNW_MP_GUIDED_WEIGHT

2.2.2.9 SUNW_MP_WAIT_POLICY

2.3 Processor Binding

2.3.1 Virtual and Logical Processor IDs

2.3.2 Interpreting the Value Specified for SUNW_MP_PROCBIND

2.3.3 Interaction With OS Processor Sets

2.4 Stacks and Stack Sizes

2.5 Checking and Analyzing OpenMP Programs

3.  Implementation-Defined Behaviors

4.  Nested Parallelism

5.  Tasking

6.  Automatic Scoping of Variables

7.  Scope Checking

8.  Performance Considerations

A.  Placement of Clauses on Directives

Index

2.4 Stacks and Stack Sizes

The executing program maintains a main stack for the initial (or main) thread executing the program, as well as distinct stacks for each slave thread. Stacks are temporary memory address spaces used to hold arguments and automatic variables during invocation of a subprogram or function reference. Stack overflow might occur if the size of a thread's stack is too small, causing silent data corruption or a segmentation fault.

Compiling Fortran programs with the f95 -stackvar option forces the allocation of local variables and arrays on the stack as if they were automatic variables. Use of -stackvar with OpenMP programs is implied with explicitly parallelized programs because it improves the optimizer’s ability to parallelize loops with calls. (See the Fortran User’s Guide for a discussion of the -stackvar flag.) However, this usage could lead to stack overflow if not enough memory is allocated for the stack.

Use the limit C-shell command or the ulimit Bourne or Korn shell command to display or set the stack size for the initial (or main) thread. In general, the default stack size for the initial thread is 8 Megabytes.

Each slave thread of an OpenMP program has its own thread stack. This stack mimics the initial (or main) thread stack but is unique to the thread. The thread’s PRIVATE arrays and variables (local to the thread) are allocated on the thread stack. The default size is 4 Megabytes on 32-bit SPARC V8 and x86 platforms, and 8 Megabytes on 64-bit SPARC V9 and x86 platforms. The size of the slave thread stack is set with the OMP_STACKSIZE environment variable.

demo% setenv OMP_STACKSIZE 16384   <-Set thread stack size to 16 Mb (C shell)

demo$ OMP_STACKSIZE=16384   <-Set thread stack size to 16 Mb (Bourne/Korn shell)
demo$ export OMP_STACKSIZE

To detect stack overflows, compile your Fortran, C, or C++ programs with the -xcheck=stkovf compiler option to force a segmentation fault on stack overflow, thereby stopping the program before any data corruption can occur.