Use these built-in functions to obtain information about the parallel environment.Function definitions for the omp_ functions can be found in the omp.h header file.
Function Prototype | Description |
---|---|
int __parthds(void) |
This function returns the value of the parthds run-time
option. If the parthds option is not explicitly set by the user, the
function returns the default value set by the run-time library. If the -qsmp compiler option was not specified during program compilation, this function returns 1 regardless of run-time options selected. |
int __usrthds(void) |
This function returns the value of the usrthds run-time
option. If the usrthds option is not explicitly set by the user, or the -qsmp compiler option was not specified during program compilation, this function returns 0 regardless of run-time options selected. |
int omp_get_num_threads(void); |
This function returns the number of threads currently in the team executing the parallel region from which it is called. |
int omp_get_max_threads(void); |
This function returns the maximum value that can be returned by calls to omp_get_num_threads. |
int omp_get_thread_num(void); |
This function returns the thread number, within its team, of the thread executing the function. The thread number lies between 0 and omp_get_num_threads()-1, inclusive. The master thread of the team is thread 0. |
int omp_get_num_procs(void); |
This function returns the maximum number of processors that could be assigned to the program. |
int omp_in_parallel(void); |
This function returns non-zero if it is called within the dynamic extent of a parallel region executing in parallel; otherwise, it returns 0. |
void omp_set_dynamic(int dynamic_threads); |
This function enables or disables dynamic adjustment of the number of threads available for execution of parallel regions. |
int omp_get_dynamic(void); |
This function returns non-zero if dynamic thread adjustments enabled and returns 0 otherwise. |
void omp_set_nested(int nested); |
This function enables or disables nested parallelism. |
int omp_get_nested(void); |
This function returns non-zero if nested parallelism is enabled and 0 if it is disabled. |
void omp_init_lock(omp_lock_t *lock); void omp_init_nest_lock(omp_nest_lock_t *lock); |
These functions provide the only means of initializing a lock. Each function initializes the lock associated with the parameter lock for use in subsequent calls. |
void omp_destroy_lock(omp_lock_t *lock); void omp_destroy_nest_lock(omp_nest_lock_t *lock); |
These functions ensure that the pointed to lock variable lock is uninitialized. |
void omp_set_lock(omp_lock_t *lock); void omp_set_nest_lock(omp_nest_lock_t *lock); |
Each of these functions blocks the thread executing the function until the specified lock is available and then sets the lock. A simple lock is available if it is unlocked. A nestable lock is available if it is unlocked or if it is already owned by the thread executing the function. |
void omp_unset_lock(omp_lock_t *lock); void omp_unset_nest_lock(omp_nest_lock_t *lock); |
These functions provide the means of releasing ownership of a lock. |
int omp_test_lock(omp_lock_t *lock); int omp_test_nest_lock(omp_nest_lock_t *lock); |
These functions attempt to set a lock but do not block execution of the thread. |
Note:
In the current implementation, nested parallel regions are always serialized. As a result,
omp_set_nested does not have any effect, and omp_get_nested
always returns 0.
For complete information about OpenMP runtime library functions, refer to the OpenMP C/C++ Application Program Interface specification.
Program Parallelization
Shared and Private Variables in a Parallel Environment
Countable Loops
#pragma Preprocessor Directives for Parallel Processing
IBM Run-time Options for Parallel Processing
OpenMP Run-time Options for Parallel Processing
smp Compiler Option
OpenMP Specifications