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

Document Information

Preface

1.  Introducing the OpenMP API

2.  Compiling and Running OpenMP Programs

2.1 Compiler Options To Use

2.2 OpenMP Environment Variables

2.2.1 Common OpenMP Environment Variables

2.2.2 Solaris Studio Specific Environment Variables

2.3 Processor Binding

2.3.1 Virtual Processor IDs

2.3.2 Logical IDs

2.3.3 Interpreting the Value Specified for SUNW_MP_PROCBIND

2.3.4 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

B.  Converting to OpenMP

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.

In general, the default main stack size is 8 megabytes. 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 calls in loops. (See the Fortran User’s Guide for a discussion of the -stackvar flag.) However, this may lead to stack overflow if not enough memory is allocated for the stack.

Use the limit C-shell command, or the ulimit ksh/sh command, to display or set the size of the main stack.

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          <-Same, using Bourne/Korn shell
demo$ export OMP_STACKSIZE

Finding the best stack size might have to be determined by trial and error. If the stack size is too small for a thread to run it may cause silent data corruption, or segmentation faults. If you are unsure about stack overflows, compile your Fortran, C, or C++ programs with the -xcheck=stkovf compiler option to force a segmentation fault on stack overflow. This stops the program before any data corruption can occur.