List of OpenMP* Runtime Library Routines

The following table specifies the interface to OpenMP* runtime library routines. The names for the routines are in user name space. The omp.h header file is provided in the include directory of your compiler installation. There are definitions for two different locks, omp_lock_t and omp_nest_lock_t, which are used by the functions in the table.

Function

Description

SUBROUTINE omp_set_num_threads(num_threads)

Sets the number of threads to use for subsequent parallel regions.

INTEGER FUNCTION omp_get_num_threads()

Returns the number of threads that are being used in the current parallel region.

INTEGER FUNCTION omp_get_max_threads()

Returns the maximum number of threads that are available for parallel execution.

INTEGER FUNCTION omp_get_thread_num()

Determines the unique thread number of the thread currently executing this section of code.

INTEGER FUNCTION omp_get_num_procs()

Determines the number of processors on the current machine.

LOGICAL FUNCTION omp_in_parallel()

Returns .TRUE. if called within the dynamic extent of a parallel region executing in parallel, otherwise returns .FALSE. .

SUBROUTINE omp_set_dynamic(dynamic_threads) INTEGER dynamic_threads

Enables or disables dynamic adjustment of the number of threads used to execute a parallel region. If dynamic_threads is non-zero, dynamic threads are enabled. If dynamic_threads is zero, dynamic threads are disabled.

LOGICAL FUNCTION omp_get_dynamic()

Returns .TRUE. if dynamic thread adjustment is enabled, otherwise returns .FALSE. .

SUBROUTINE omp_set_nested(nested)
INTEGER nested

Enables or disables nested parallelism. If parameter is non-zero, enable. Default is disabled.

LOGICAL FUNCTION omp_get_nested()

Determines whether nested parallelism is currently enabled or disabled. Function returns non-zero if nested parallelism is supported, zero otherwise. Always returns .FALSE. in the current version of compiler.

SUBROUTINE omp_init_lock(lock) INTEGER lock

Initializes a unique lock and set lock to its value.

SUBROUTINE omp_destroy_lock(lock)
INTEGER lock

 Disassociates lock from any locks.

SUBROUTINE omp_set_lock(lock)
INTEGER lock

Forces the executing thread to wait until the lock associated with lock is available. The thread is granted ownership of the lock when it becomes available.

SUBROUTINE omp_unset_lock(lock)
INTEGER lock

Releases executing thread from ownership of lock associated with lock. The lock argument must be initialized via omp_init_lock(), and behavior undefined if executing thread does not own the lock associated with lock.

INTEGER omp_test_lock(lock)

Attempts to set lock associated with lock. If successful, returns non-zero. lock must be initialized via omp_init_lock(lock).

SUBROUTINE omp_init_nest_lock(lock)
INTEGER lock

 Initializes a unique nested lock and set lock to its value.

SUBROUTINE omp_destroy_nest_lock(lock)
INTEGER lock

Disassociates the nested lock "lock" from any locks.

SUBROUTINE omp_set_nest_lock(lock)
INTEGER lock

Forces the executing thread to wait until the lock associated with lock is available. The thread is granted ownership of the lock when it becomes available.

SUBROUTINE omp_unset_nest_lock(lock)
INTEGER lock

Releases executing thread from ownership of lock associated with lock if count is zero. lock must be initialized via omp_init_nest_lock(). Behavior is undefined if executing thread does not own the lock associated with lock.

INTEGER omp_test_nest_lock(lock)

Attempts to set lock associated with lock. If successful, returns nesting count, otherwise returns zero. lock must be initialized via omp_init_lock().