Barrelfish
Functions
omp.c File Reference

OpenMP API implementation as defined in OpenMP Version 4.0. More...

Functions

void omp_set_num_threads (int num_threads)
 Sets the number of threads to be used for parallel regions. More...
 
int omp_get_num_threads (void)
 returns the current number of threads used (innermost parallel region) More...
 
int omp_get_max_threads (void)
 the maximum number of threads that can be used for a new parallel task More...
 
int omp_get_thread_num (void)
 Returns the thread number of the calling thread within the current team. More...
 
int omp_get_num_procs (void)
 returns the number of available processors More...
 
int omp_in_parallel (void)
 checks if we are currently in a parallel region More...
 
void omp_set_dynamic (int dynamic_threads)
 enables / disables the dynamic behavior More...
 
int omp_get_dynamic (void)
 checks if the dynamic behavior is enabled for the current task More...
 
void omp_set_nested (int nested)
 Enables or disables nested parallelism, by setting the nest-var ICV. More...
 
int omp_get_nested (void)
 checks if the nested behavior is enabled More...
 
void omp_set_schedule (omp_sched_t kind, int modifier)
 sets the schedule to be used More...
 
void omp_get_schedule (omp_sched_t *kind, int *modifier)
 returns the current scheduler settings More...
 
int omp_get_thread_limit (void)
 obtains he maximum number of OpenMP threads available More...
 
void omp_set_max_active_levels (int max_active_levels)
 limits the nested depth More...
 
int omp_get_max_active_levels (void)
 returns the maximim nested depth More...
 
int omp_get_level (void)
 returns the level the task is runnig at More...
 
int omp_get_ancestor_thread_num (int level)
 returns the ancestor thread number of a thread at a given level More...
 
int omp_get_team_size (int level)
 returns the team size of a thread at a given level More...
 
int omp_get_active_level (void)
 returns the number of active, nested parallel regions More...
 
int omp_in_final (void)
 checks if thread is in the final task region More...
 
int omp_get_cancellation (void)
 returns the cancellation value More...
 
omp_proc_bind_t omp_get_proc_bind (void)
 returns the thread affinitiy policy More...
 
void omp_set_default_device (int device_num)
 controls the default target device More...
 
int omp_get_default_device (void)
 Returns the default target device. More...
 
int omp_get_num_devices (void)
 Returns the number of target devices. More...
 
int omp_get_num_teams (void)
 returns the number of teams in the current region More...
 
int omp_get_team_num (void)
 gets the team number of the calling thread More...
 
int omp_is_initial_device (void)
 checks if the task is executing as the host device More...
 
void omp_init_lock (omp_lock_t *arg)
 initializes and allocates a simple OpenMP lock More...
 
void omp_destroy_lock (omp_lock_t *arg)
 destroys a simple OpenMP lock More...
 
void omp_set_lock (omp_lock_t *arg)
 acquires a simple OpenMP lock More...
 
void omp_unset_lock (omp_lock_t *arg)
 Releases the simple OpenMP lock. More...
 
int omp_test_lock (omp_lock_t *arg)
 tries to acquire a simple openMP lock More...
 
void omp_init_nest_lock (omp_nest_lock_t *arg)
 initializes and allocates a nested OpenMP lock More...
 
void omp_destroy_nest_lock (omp_nest_lock_t *arg)
 destroys a Nested OpenMP lock More...
 
void omp_set_nest_lock (omp_nest_lock_t *arg)
 acquires a simple OpenMP lock More...
 
void omp_unset_nest_lock (omp_nest_lock_t *arg)
 Releases the simple OpenMP lock. More...
 
int omp_test_nest_lock (omp_nest_lock_t *arg)
 tries to acquire a simple openMP lock More...
 
double omp_get_wtime (void)
 returns elapsed wall clock time in seconds. More...
 
double omp_get_wtick (void)
 returns the precision of the timer used by omp_get_wtime. More...
 

Detailed Description

OpenMP API implementation as defined in OpenMP Version 4.0.

Source: http://www.openmp.org/mp-documents/OpenMP4.0.0.pdf

Function Documentation

void omp_destroy_lock ( omp_lock_t arg)

destroys a simple OpenMP lock

Parameters
argOpenMP lock to destroyed (set to zero)

The effect of these routines is to change the state of the lock to uninitialized.

void omp_destroy_nest_lock ( omp_nest_lock_t *  arg)

destroys a Nested OpenMP lock

Parameters
argOpenMP lock to destroyed (set to zero)

The effect of these routines is to change the state of the lock to uninitialized.

int omp_get_active_level ( void  )

returns the number of active, nested parallel regions

Returns
number of nested parallel regions *

The effect of the omp_get_active_level routine is to return the number of nested, active parallel regions enclosing the current task such that all of the parallel regions are enclosed by the outermost initial task region on the current device.

int omp_get_ancestor_thread_num ( int  level)

returns the ancestor thread number of a thread at a given level

Parameters
levelthe level of the ancestor
Returns
thread number of ancestor thread

The omp_get_ancestor_thread_num routine returns the thread number of the ancestor at a given nest level of the current thread or the thread number of the current thread. If the requested nest level is outside the range of 0 and the nest level of the current thread, as returned by the omp_get_level routine, the routine returns -1.

int omp_get_cancellation ( void  )

returns the cancellation value

Returns
cancellation value

Returns the value of the cancel-var ICV, which controls the behavior of cancel construct and cancellation points.

int omp_get_default_device ( void  )

Returns the default target device.

Returns
device number of default target device

The omp_get_default_device routine returns the value of the default-device-var ICV of the current task. When called from within a target region the effect of this routine is unspecified.

int omp_get_dynamic ( void  )

checks if the dynamic behavior is enabled for the current task

Returns
TRUE if dynamic behavior enabled FALSE if disabled

This routine returns the value of the dyn-var ICV, which is true if dynamic adjustment of the number of threads is enabled for the current task.

int omp_get_level ( void  )

returns the level the task is runnig at

Parameters
numberenclosing nested parallel regions

For the enclosing device region, returns the levels-vars ICV, which is the number of nested parallel regions that enclose the task containing the call.

int omp_get_max_active_levels ( void  )

returns the maximim nested depth

Returns
maximum nested level

Returns the value of max-active-levels-var ICV, which determines the maximum number of nested active parallel regions.

int omp_get_max_threads ( void  )

the maximum number of threads that can be used for a new parallel task

Returns
number of usable threads

Returns an upper bound on the number of threads that could be used to form a new team if a parallel construct without a num_threads clause were encountered after execution returns from this routine.

The value returned by omp_get_max_threads is the value of the first element of the nthreads-var ICV of the current task. This value is also an upper bound on the number of threads that could be used to form a new team if a parallel region without a num_threads clause were encountered after execution returns from this routine.

int omp_get_nested ( void  )

checks if the nested behavior is enabled

Returns
TRUE if nested behavior is enabled FALSE if disabled

Returns the value of the nest-var ICV, which indicates if nested parallelism is enabled or disabled.

int omp_get_num_devices ( void  )

Returns the number of target devices.

Returns
number of target devices

The omp_get_num_devices routine returns the number of available target devices. When called from within a target region the effect of this routine is unspecified.

int omp_get_num_procs ( void  )

returns the number of available processors

Returns
available processor count

Returns the number of processors that are available to the device at the time the routine is called.

int omp_get_num_teams ( void  )

returns the number of teams in the current region

Returns
number of teams

The effect of this routine is to return the number of teams in the current teams region. The routine returns 1 if it is called from outside of a teams region.

int omp_get_num_threads ( void  )

returns the current number of threads used (innermost parallel region)

Returns
number of used threads

Returns the number of threads in the current team. The binding region for an omp_get_num_threads region is the innermost enclosing parallel region. If called from the sequential part of a program, this routine returns 1.

if we are nested return 1

omp_proc_bind_t omp_get_proc_bind ( void  )

returns the thread affinitiy policy

Returns
OpenMP thread policy value

Returns the thread affinity policy to be used for the subsequent nested parallel regions that do not specify a proc_bind clause.

void omp_get_schedule ( omp_sched_t kind,
int *  modifier 
)

returns the current scheduler settings

Parameters
kindreturns the current scheduler setting (one of OMP_SCHED_*)
modifierreturns the modifier of the scheduler

Returns the value of run-sched-var ICV, which is the schedule applied when runtime schedule is used.

int omp_get_team_num ( void  )

gets the team number of the calling thread

Returns
team number

Returns the team number of calling thread. The team number is an integer between 0 and one less than the value returned by omp_get_num_teams, inclusive.

int omp_get_team_size ( int  level)

returns the team size of a thread at a given level

Parameters
levelthe level to consider
Returns
number of threads in the team *

The omp_get_team_size routine returns the size of the thread team to which the ancestor or the current thread belongs. If the requested nested level is outside the range of 0 and the nested level of the current thread, as returned by the omp_get_level routine, the routine returns -1. Inactive parallel regions are regarded like active parallel regions executed with one thread.

int omp_get_thread_limit ( void  )

obtains he maximum number of OpenMP threads available

Returns
number of available threads

Returns the value of the thread-limit-var ICV, which is the maximum number of OpenMP threads available.

The binding thread set for an omp_get_thread_limit region is all threads on the device. The effect of executing this routine is not related to any specific region corresponding to any construct or API routine.

int omp_get_thread_num ( void  )

Returns the thread number of the calling thread within the current team.

Returns
ThreadID
double omp_get_wtick ( void  )

returns the precision of the timer used by omp_get_wtime.

Returns
the timer precision

The omp_get_wtick routine returns a value equal to the number of seconds between successive clock ticks of the timer used by omp_get_wtime.

double omp_get_wtime ( void  )

returns elapsed wall clock time in seconds.

Returns
call clock time

The omp_get_wtime routine returns a value equal to the elapsed wall clock time in seconds since some “time in the past”. The actual “time in the past” is arbitrary, but it is guaranteed not to change during the execution of the application program. The time returned is a “per-thread time”, so it is not required to be globally consistent across all the threads participating in an application.

int omp_in_final ( void  )

checks if thread is in the final task region

Returns
TRUE if thread is in the final task region FALSE otherwise

Returns true if the routine is executed in a final task region; otherwise, it returns false.

int omp_in_parallel ( void  )

checks if we are currently in a parallel region

Returns
TRUE active threads is greater than 1 FALSE active threads is 1 (main thread)

Returns true if the active-levels-var ICV is greater than zero; otherwise it returns false. The effect of the omp_in_parallel routine is to return true if the current task is enclosed by an active parallel region, and the parallel region is enclosed by the outermost initial task region on the device; otherwise it returns false.

void omp_init_lock ( omp_lock_t arg)

initializes and allocates a simple OpenMP lock

Parameters
argreturned pointer to the lock

The effect of these routines is to initialize the lock to the unlocked state; that is, no task owns the lock.

void omp_init_nest_lock ( omp_nest_lock_t *  arg)

initializes and allocates a nested OpenMP lock

Parameters
argreturned pointer to the lock

The effect of these routines is to initialize the lock to the unlocked state; that is, no task owns the lock. In addition, the nesting count for a nestable lock is set to zero.

int omp_is_initial_device ( void  )

checks if the task is executing as the host device

Returns
TRUE if task is host device FALSE otherwise Returns true if the current task is executing on the host device; otherwise, it returns false.
void omp_set_default_device ( int  device_num)

controls the default target device

Parameters
device_numdevice number of the target device

The effect of this routine is to set the value of the default-device-var ICV of the current task to the value specified in the argument. When called from within a target region the effect of this routine is unspecified.

void omp_set_dynamic ( int  dynamic_threads)

enables / disables the dynamic behavior

Parameters
dynamic_threadszero to disable dynamic behavior non-zero to enable dynamic behavior

Returns the value of the dyn-var ICV, which indicates if dynamic adjustment of the number of threads is enabled or disabled.

void omp_set_lock ( omp_lock_t arg)

acquires a simple OpenMP lock

Parameters
argThe lock to acquire

Each of these routines causes suspension of the task executing the routine until the specified lock is available and then sets the lock.

void omp_set_max_active_levels ( int  max_active_levels)

limits the nested depth

Parameters
max_active_levelsmaximum nested level

Limits the number of nested active parallel regions, by setting max-active-levels-var ICV.

void omp_set_nest_lock ( omp_nest_lock_t *  arg)

acquires a simple OpenMP lock

Parameters
argThe lock to acquire

Each of these routines causes suspension of the task executing the routine until the specified lock is available and then sets the lock.

A nestable lock is available if it is unlocked or if it is already owned by the task executing the routine. The task executing the routine is granted, or retains, ownership of the lock, and the nesting count for the lock is incremented.

void omp_set_nested ( int  nested)

Enables or disables nested parallelism, by setting the nest-var ICV.

Parameters
nestedTRUE: enable nested behavior FALSE: disable nested behavior
void omp_set_num_threads ( int  num_threads)

Sets the number of threads to be used for parallel regions.

Parameters
num_threadsthe number of threads

Affects the number of threads used for subsequent parallel regions not specifying a num_threads clause, by setting the value of the first element of the nthreads-var ICV of the current task to num_threads.

void omp_set_schedule ( omp_sched_t  kind,
int  modifier 
)

sets the schedule to be used

Parameters
kindwhich schedule to be used (one of OMP_SCHED_*)
modifiermodifier to tweak the scheduler (depends on kind)

The omp_set_schedule routine affects the schedule that is applied when runtime is used as schedule kind, by setting the value of the run-sched-var ICV.

int omp_test_lock ( omp_lock_t arg)

tries to acquire a simple openMP lock

Parameters
argThe OpenMP lock to acquire
Returns
TRUE if lock is acquired successfully FALSE if lock is already held by other thread

These routines attempt to set a lock in the same manner as omp_set_lock and omp_set_nest_lock, except that they do not suspend execution of the task executing the routine. For a simple lock, the omp_test_lock routine returns true if the lock is successfully set; otherwise, it returns false.

int omp_test_nest_lock ( omp_nest_lock_t *  arg)

tries to acquire a simple openMP lock

Parameters
argThe OpenMP lock to acquire
Returns
TRUE if lock is acquired successfully FALSE if lock is already held by other thread

These routines attempt to set a lock in the same manner as omp_set_lock and omp_set_nest_lock, except that they do not suspend execution of the task executing the routine. For a nestable lock, the omp_test_nest_lock routine returns the new nesting count if the lock is successfully set; otherwise, it returns zero.

void omp_unset_lock ( omp_lock_t arg)

Releases the simple OpenMP lock.

Parameters
argThe lock to be released

For a simple lock, the omp_unset_lock routine causes the lock to become unlocked.

void omp_unset_nest_lock ( omp_nest_lock_t *  arg)

Releases the simple OpenMP lock.

Parameters
argThe lock to be released

For a nestable lock, the omp_unset_nest_lock routine decrements the nesting count, and causes the lock to become unlocked if the resulting nesting count is zero.