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
Getting and setting thread sleep time for the throughput execution mode
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.
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.
Note
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 |
---|---|
FUNCTION 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 via the KMP_SET_STACKSIZE_S routine, prior to the first parallel region or via the KMP_STACKSIZE environment variable. |
FUNCTION KMP_GET_STACKSIZE() |
This routine is provided for backwards compatibility only; use KMP_GET_STACKSIZE_S routine for compatibility across different families of Intel processors. |
SUBROUTINE 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. |
SUBROUTINE KMP_SET_STACKSIZE_S(size) |
This routine is provided for backward compatibility only; use KMP_SET_STACKSIZE_S(size) 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 |
---|---|
FUNCTION KMP_MALLOC(size) |
Allocate memory block of size bytes from thread-local heap. |
FUNCTION KMP_CALLOC(nelem,elsize) |
Allocate array of nelem elements of size elsize from thread-local heap. |
FUNCTION KMP_REALLOC(ptr, size) |
Reallocate memory block at address ptr and size bytes from thread-local heap. |
SUBROUTINE 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. |
In the throughput execution mode, threads wait for new parallel work at the ends of parallel regions, and then sleep, after a specified period of time. This time interval can be set by the KMP_BLOCKTIME environment variable or by the KMP_SET_BLOCKTIME() function.
Function |
Description |
---|---|
FUNCTION KMP_GET_BLOCKTIME() INTEGER KMP_GET_BLOCKTIME |
Returns the number of milliseconds that a thread should wait, after completing the execution of a parallel region, before sleeping, as set either by the KMP_BLOCKTIME environment variable or by kmp_set_blocktime(). |
FUNCTION KMP_SET_BLOCKTIME(msec) INTEGER msec |
Sets the number of milliseconds that a thread should wait, after completing the execution of a parallel region, before sleeping. In order for kmp_set_blocktime() to have an effect, it must be called before the beginning of the first (dynamically executed) parallel region. |