The IntelŪ compiler implements the following group of routines as an extensions to the OpenMP* run-time library:
Getting and setting stack size for parallel threads
Memory allocation
The Intel extension routines described in this section can be used for low-level debugging to verify that the library code and application are functioning as intended. It is recommended to use these routines with caution because using them requires the use of the -openmp-stubs (Linux*) or /Qopenmp-stubs (Windows*) command-line option to execute the program sequentially. These routines are also generally not recognized by other vendor's OpenMP-compliant compilers, which may cause the link stage to fail for these other compilers.
The following functions require the pre-processor directive #include <omp.h>.
In most cases, environment variables can be used in place of the extension library routines. For example, the stack size of the parallel threads may be set using the KMP_STACKSIZE environment variable rather than the KMP_SET_STACKSIZE() or KMP_SET_STACKSIZE_S() library routine.
A run-time call to an Intel extension routine takes precedence over the corresponding environment variable setting.
The routines KMP_SET_STACKSIZE() and KMP_GET_STACKSIZE() take a 32-bit argument only. The routines KMP_SET_STACKSIZE_S() and KMP_GET_STACKSIZE_S() take a SIZE_T argument, which can hold 64-bit integers.
On ItaniumŪ-based systems, it is recommended to always use KMP_SET_STACKSIZE_S() and KMP_GET_STACKSIZE_S(). These _S() variants must be used if you need to set a stack size ≥ 2**32 bytes (4 gigabytes).
Function |
Description |
---|---|
kmp_get_stacksize_s() |
Returns the number of bytes that will be allocated for each parallel thread to use as its private stack. This value can be changed with kmp_set_stacksize_s() prior to the first parallel region or with the KMP_STACKSIZE environment variable. |
kmp_get_stacksize() |
This function is provided for backwards compatibility only. Use kmp_get_stacksize_s() for compatibility across different families of Intel processors. |
kmp_set_stacksize_s(size) |
Sets to size the number of bytes that will be allocated for each parallel thread to use as its private stack. This value can also be set via the KMP_STACKSIZE environment variable. In order for kmp_set_stacksize_s() to have an effect, it must be called before the beginning of the first (dynamically executed) parallel region in the program. |
kmp_set_stacksize(size) |
This function is provided for backward compatibility only; use kmp_set_stacksize_s() for compatibility across different families of Intel processors. |
The IntelŪ compiler implements a group of memory allocation routines as an extension to the OpenMP* run-time library to enable threads to allocate memory from a heap local to each thread. These routines are: KMP_MALLOC, KMP_CALLOC, and KMP_REALLOC.
The memory allocated by these routines must also be freed by the KMP_FREE routine. While it is legal for the memory to be allocated by one thread and freed (using KMP_FREE) by a different thread, this mode of operation has a slight performance penalty.
Function |
Description |
---|---|
kmp_malloc(size) |
Allocate memory block of size bytes from thread-local heap. |
kmp_calloc(nelem, elsize) |
Allocate array of nelem elements of size elsize from thread-local heap. |
kmp_realloc(ptr, size) |
Reallocate memory block at address ptr and size bytes from thread-local heap. |
kmp_free(ptr) |
Free memory block at address ptr from thread-local heap. Memory must have been previously allocated with kmp_malloc(), kmp_calloc(), or kmp_realloc(). |