OpenMP* Run-time Library Routines
Execution Environment Routines
void omp_set_num_threads(int nthreads)
Sets the number of threads to use for subsequent parallel regions created by the calling thread.
Enables or disables dynamic adjustment of the number of threads used to execute a parallel region. If
TRUE, dynamic threads are enabled. If
FALSE, dynamic threads are disabled. Dynamic threads are disabled by default.
Enables or disables nested parallelism. If
TRUE, nested parallelism is enabled. If
FALSE, nested parallelism is disabled. Nested parallelism is disabled by default.
Returns the number of threads that are being used in the current parallel region.
This function does not necessarily return the value inherited by the calling thread from the
Returns the number of threads available to subsequent parallel regions created by the calling thread.
Returns the thread number of the calling thread, within the context of the current parallel region.
Returns the number of processors available to the program.
TRUEif called within the dynamic extent of a parallel region executing in parallel; otherwise returns
TRUEif called within a final task region; otherwise returns
TRUEif dynamic thread adjustment is enabled, otherwise returns
TRUEif nested parallelism is enabled, otherwise returns
Returns the maximum number of simultaneously executing threads in an OpenMP* program.
void omp_set_max_active_levels(int max_active_levels)
Limits the number of nested active parallel regions. The call is ignored if negative
Returns the maximum number of nested active parallel regions.
Returns the number of nested parallel regions (whether active or inactive) enclosing the task that contains the call, not including the implicit parallel region.
Returns the number of nested, active parallel regions enclosing the task that contains the call.
int omp_get_ancestor_thread_num(int level)
Returns the thread number of the ancestor at a given nest level of the current thread.
int omp_get_team_size(int level)
Returns the size of the thread team to which the ancestor
of the given level belongs.
void omp_set_schedule(omp_sched_t kind,int chunk_size)
Determines the schedule of a worksharing loop that is applied when '
runtime' is used as the schedule kind.
void omp_get_schedule(omp_sched_kind *kind,int *chunk_size)
Returns the schedule of a worksharing loop that is applied when the '
runtime' schedule is used.
Returns the currently active thread affinity policy, which is set by environment variable
This policy is used for subsequent nested parallel regions.
Returns the number of places available to the execution environment in the place list of the initial task, usually threads, cores, or sockets.
int omp_get_place_num_procs(int place_num)
Returns the number of processors associated with the place numbered
place_num. The routine returns zero when
place_numis negative or is greater than or equal to
void omp_get_place_proc_ids(int place_num, int *ids)
Returns the numerical identifiers of each processor associated with the place numbered place_num. The numerical identifiers are non-negative and their meaning is implementation defined. The numerical identifiers are returned in the array ids and their order in the array is implementation defined. ids must have at least
omp_get_place_num_procs(place_num)elements. The routine has no effect when
place_numis greater than or equal to
Returns the place number of the place to which the encountering thread is bound. The returned value is between 0 and
omp_get_num_places()- 1, inclusive. When the encountering thread is not bound to a place, the routine returns -1.
Returns the default device number.
void omp_set_default_device(int device_number);
Sets the default device number.
Gets the number of target devices.
Gets the number of teams in the current teams region.
Gets the team number of the calling thread.
TRUEif cancellation is enabled; otherwise,
This routine can be affected by the setting for environment variable
TRUEif the current task is running on the host device; otherwise,
Returns the device number of the host device. The value of the device number is implementation defined. If it is between 0 and
omp_get_num_devices()-1, then it is valid in all device constructs and routines; if it is outside that range, then it is only valid in the device memory routines and not in the
Returns the maximum value that can be specified in the
void * omp_target_alloc(size_t size, int device_num)
Returns a storage location's device address, where the size of the location is measured in bytes.
void omp_target_free(void *device_ptr, int device_num)
Frees device memory that was allocated by the
int omp_target_is_present(void *ptr, int device_num)
TRUEif the specified pointer is found on the device specified by
device_numby a map clause. Otherwise, it returns
int omp_target_memcpy(void *dst, void *src, size_t length, size_t dst_offset, size_t src_offset, int dst_device, int src_device)
This routine copies
lengthbytes of memory at offset
srcin the device data environment of device
dst, starting at offset
dst_offsetin the device data environment of the device specified by
dst_device_num. Returns zero on success and a non-zero value on failure. Use
omp_get_initial_deviceto return a the device number you can use to reference the host device and host device data environment. This routine includes a task scheduling point.
The effect of this routine is unspecified when it is called from within a target region.
int omp_target_memcpy_rect( void *dst, void *src,size_t element_size,int num_dims,const size_t *volume, const size_t *dst_offsets,const size_t *src_offsets, const size_t *dst_dimensions, const size_t *src_dimensions,int dst_device_num, int src_device_num)
This routine copies a rectangular subvolume of
src, in the device data environment of the device specified by
dst, in the device data environment of the device specified by
dst_device_num. Specify the volume in terms of the size of an element, the number of its dimensions, and constant arrays of length
num_dims. The maximum number of dimensions supported is three or more. The volume array specifies the length, in number of elements, to copy in each dimension from
src_offsetsparameters specify the number of elements from the origin of
src, in elements. The
src_dimensionsparameters specify the length of each dimension of
src. The routine returns zero if successful. If both
srcare NULL pointers, the routine returns the number of dimensions supported by the implementation for the specified device numbers. You can use the device number returned by
omp_get_initial_deviceto reference the host device and host device data environment. Otherwise, it returns a non-zero value. This routine contains a task scheduling point.
The effect of this routine is unspecified when called from within a target region.
int omp_target_associate_ptr(void *host_ptr, void *device_ptr, size_t size, size_t device_offset, int device_num)
Maps a device pointer, which might be returned by
omp_target_alloc, to a host pointer.
void omp_init_lock(omp_lock_t svar)
Initializes the lock associated with the simple lock variable svar for use in subsequent calls.
Initializes the lock associated with svar to the unlocked state, optionally choosing a specific lock implementation based on
void omp_destroy_lock(omp_lock_t svar)
Causes the lock specified by svar to become undefined or uninitialized.
void omp_set_lock(omp_lock_t svar)
Forces the executing thread to wait until the lock associated with svar is available. The thread is granted ownership of the lock when it becomes available.
void omp_unset_lock(omp_lock_t svar
Releases the executing thread from ownership of the lock associated with svar. The behavior is undefined if the executing thread does not own the lock associated with svar.
int omp_test_lock(omp_lock_t svar)
Attempts to set the lock associated with svar. If successful, returns
TRUE, otherwise returns
void omp_init_nest_lock(omp_nest_lock_t nvar)
Initializes the nested lock associated with the nested lock variable nvar for use in the subsequent calls.
Initializes the nested lock associated with nvar to the unlocked state, optionally choosing a specific lock implementation based on
hint. The nesting count for nvar is set to zero.
void omp_destroy_nest_lock(omp_nest_lock_t nvar)
Causes the nested lock associated with nvar to become undefined or uninitialized.
void omp_set_nest_lock(omp_nest_lock_t nvar)
Forces the executing thread to wait until the nested lock associated with nvar is available. If the thread already owns the lock, then the lock nesting count is incremented.
Releases the executing thread from ownership of the nested lock associated with nvar if the nesting count is zero; otherwise, the nesting count is decremented. Behavior is undefined if the executing thread does not own the nested lock associated with nvar.
Attempts to set the nested lock specified by nvar. If successful, returns the nesting count, otherwise returns zero.
Returns a double precision value equal to the elapsed wall clock time (in seconds) relative to an arbitrary reference time. The reference time does not change during program execution.
Returns a double precision value equal to the number of seconds between successive clock ticks.
integer (omp_lock_hint_kind), parameter :: omp_lock_hint_none = 0 integer (omp_lock_hint_kind), parameter :: omp_lock_hint_uncontended = 1 integer (omp_lock_hint_kind), parameter :: omp_lock_hint_contended = 2 integer (omp_lock_hint_kind), parameter :: omp_lock_hint_nonspeculative = 4 integer (omp_lock_hint_kind), parameter :: omp_lock_hint_speculative = 8