/*
* This file is part of the StarPU Handbook.
* Copyright (C) 2014 Inria
* See the file version.doxy for copying conditions.
*/
/*! \defgroup API_OpenMP_Runtime_Support OpenMP Runtime Support
@name Initialisation
\ingroup API_OpenMP_Runtime_Support
\def STARPU_OPENMP
\ingroup API_OpenMP_Runtime_Support
This macro is defined when StarPU has been installed with OpenMP Runtime
support. It should be used in your code to detect the availability of
the runtime support for OpenMP.
\fn int starpu_omp_init(void)
\ingroup API_OpenMP_Runtime_Support
Initializes StarPU and its OpenMP Runtime support.
\fn int starpu_omp_shutdown(void)
\ingroup API_OpenMP_Runtime_Support
Shutdown StarPU and its OpenMP Runtime support.
@name Parallel
\anchor ORS_Parallel
\ingroup API_OpenMP_Runtime_Support
\fn void starpu_omp_parallel_region(const struct starpu_omp_parallel_region_attr *attr)
\ingroup API_OpenMP_Runtime_Support
Generates and launch an OpenMP parallel region and return after its
completion. \p attr specifies the attributes for the generated parallel region.
If this function is called from inside another, generating, parallel region, the
generated parallel region is nested within the generating parallel region.
This function can be used to implement \#pragma omp parallel.
\fn void starpu_omp_master(void (*f)(void *arg), void *arg)
\ingroup API_OpenMP_Runtime_Support
Executes a function only on the master thread of the OpenMP
parallel region it is called from. When called from a thread that is not the
master of the parallel region it is called from, this function does nothing. \p
f is the function to be called. \p arg is an argument passed to function \p f.
This function can be used to implement \#pragma omp master.
\fn int starpu_omp_master_inline(void)
\ingroup API_OpenMP_Runtime_Support
Determines whether the calling thread is the master of the OpenMP parallel region
it is called from or not.
This function can be used to implement \#pragma omp master without code
outlining.
\return !0 if called by the region's master thread.
\return 0 if not called by the region's master thread.
@name Synchronization
\anchor ORS_Synchronization
\ingroup API_OpenMP_Runtime_Support
\fn void starpu_omp_barrier(void)
\ingroup API_OpenMP_Runtime_Support
Waits until each participating thread of the innermost OpenMP parallel region
has reached the barrier and each explicit OpenMP task bound to this region has
completed its execution.
This function can be used to implement \#pragma omp barrier.
\fn void starpu_omp_critical(void (*f)(void *arg), void *arg, const char *name)
\ingroup API_OpenMP_Runtime_Support
Waits until no other thread is executing within the context of the selected
critical section, then proceeds to the exclusive execution of a function within
the critical section. \p f is the function to be executed in the critical
section. \p arg is an argument passed to function \p f. \p name is the name of
the selected critical section. If name == NULL, the selected critical
section is the unique anonymous critical section.
This function can be used to implement \#pragma omp critical.
\fn void starpu_omp_critical_inline_begin(const char *name)
\ingroup API_OpenMP_Runtime_Support
Waits until execution can proceed exclusively within the context of the
selected critical section. \p name is the name of the selected critical
section. If name == NULL, the selected critical section is the unique
anonymous critical section.
This function together with #starpu_omp_critical_inline_end can be used to
implement \#pragma omp critical without code outlining.
\fn void starpu_omp_critical_inline_end(const char *name)
\ingroup API_OpenMP_Runtime_Support
Ends the exclusive execution within the context of the selected critical
section. \p name is the name of the selected critical section. If
name==NULL, the selected critical section is the unique anonymous
critical section.
This function together with #starpu_omp_critical_inline_begin can be used to
implement \#pragma omp critical without code outlining.
@name Worksharing
\anchor ORS_Worksharing
\ingroup API_OpenMP_Runtime_Support
\fn void starpu_omp_single(void (*f)(void *arg), void *arg, int nowait)
\ingroup API_OpenMP_Runtime_Support
Ensures that a single participating thread of the innermost OpenMP parallel
region executes a function. \p f is the function to be executed by a single
thread. \p arg is an argument passed to function \p f. \p nowait is a flag
indicating whether an implicit barrier is requested after the single section
(nowait==0) or not (nowait==!0).
This function can be used to implement \#pragma omp single.
\fn int starpu_omp_single_inline(void)
\ingroup API_OpenMP_Runtime_Support
Decides whether the current thread is elected to run the following single
section among the participating threads of the innermost OpenMP parallel
region.
This function can be used to implement \#pragma omp single without code
outlining.
\return !0 if the calling thread has won the election.
\return 0 if the calling thread has lost the election.
\fn void starpu_omp_for(void (*f)(unsigned long long _first_i, unsigned long long _nb_i, void *arg), void *arg, unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, int nowait)
\ingroup API_OpenMP_Runtime_Support
Executes a parallel loop together with the other threads participating to the
innermost parallel region. \p f is the function to be executed iteratively. \p
arg is an argument passed to function \p f. \p nb_iterations is the number of
iterations to be performed by the parallel loop. \p chunk is the number of
consecutive iterations that should be affected to the same thread when
scheduling the loop workshares, it follows the semantics of the \c modifier
argument in OpenMP \#pragma omp for specification. \p schedule is the
scheduling mode according to the OpenMP specification. \p ordered is a flag
indicating whether the loop region may contain an ordered section
(ordered==!0) or not (ordered==0). \p nowait is a flag
indicating whether an implicit barrier is requested after the for section
(nowait==0) or not (nowait==!0).
The function \p f will be called with arguments \p _first_i, the first iteration
to perform, \p _nb_i, the number of consecutive iterations to perform before
returning, \p arg, the free \p arg argument.
This function can be used to implement \#pragma omp for.
\fn int starpu_omp_for_inline_first(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_first_i, unsigned long long *_nb_i)
\ingroup API_OpenMP_Runtime_Support
Decides whether the current thread should start to execute a parallel loop
section. See #starpu_omp_for for the argument description.
This function together with #starpu_omp_for_inline_next can be used to
implement \#pragma omp for without code outlining.
\return !0 if the calling thread participates to the loop region and
should execute a first chunk of iterations. In that case, \p *_first_i will be
set to the first iteration of the chunk to perform and \p *_nb_i will be set to
the number of iterations of the chunk to perform.
\return 0 if the calling thread does not participate to the loop region
because all the available iterations have been affected to the other threads of
the parallel region.
\sa starpu_omp_for
\fn int starpu_omp_for_inline_next(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_first_i, unsigned long long *_nb_i)
\ingroup API_OpenMP_Runtime_Support
Decides whether the current thread should continue to execute a parallel loop
section. See #starpu_omp_for for the argument description.
This function together with #starpu_omp_for_inline_first can be used to
implement \#pragma omp for without code outlining.
\return !0 if the calling thread should execute a next chunk of
iterations. In that case, \p *_first_i will be set to the first iteration of the
chunk to perform and \p *_nb_i will be set to the number of iterations of the
chunk to perform.
\return 0 if the calling thread does not participate anymore to the loop
region because all the available iterations have been affected to the other
threads of the parallel region.
\sa starpu_omp_for
\fn void starpu_omp_for_alt(void (*f)(unsigned long long _begin_i, unsigned long long _end_i, void *arg), void *arg, unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, int nowait)
\ingroup API_OpenMP_Runtime_Support
Alternative implementation of a parallel loop. This function differs from
#starpu_omp_for in the expected arguments of the loop function \c f.
The function \p f will be called with arguments \p _begin_i, the first iteration
to perform, \p _end_i, the first iteration not to perform before
returning, \p arg, the free \p arg argument.
This function can be used to implement \#pragma omp for.
\sa starpu_omp_for
\fn int starpu_omp_for_inline_first_alt(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_begin_i, unsigned long long *_end_i)
\ingroup API_OpenMP_Runtime_Support
Inline version of the alternative implementation of a parallel loop.
This function together with #starpu_omp_for_inline_next_alt can be used to
implement \#pragma omp for without code outlining.
\sa starpu_omp_for
\sa starpu_omp_for_alt
\sa starpu_omp_for_inline_first
\fn int starpu_omp_for_inline_next_alt(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_begin_i, unsigned long long *_end_i)
\ingroup API_OpenMP_Runtime_Support
Inline version of the alternative implementation of a parallel loop.
This function together with #starpu_omp_for_inline_first_alt can be used to
implement \#pragma omp for without code outlining.
\sa starpu_omp_for
\sa starpu_omp_for_alt
\sa starpu_omp_for_inline_next
\fn void starpu_omp_ordered(void (*f)(void *arg), void *arg)
\ingroup API_OpenMP_Runtime_Support
Ensures that a function is sequentially executed once for each iteration in
order within a parallel loop, by the thread that own the iteration. \p f is the
function to be executed by the thread that own the current iteration. \p arg is
an argument passed to function \p f.
This function can be used to implement \#pragma omp ordered.
\fn void starpu_omp_ordered_inline_begin(void)
\ingroup API_OpenMP_Runtime_Support
Waits until all the iterations of a parallel loop below the iteration owned by
the current thread have been executed.
This function together with #starpu_omp_ordered_inline_end can be used to
implement \#pragma omp ordered without code code outlining.
\fn void starpu_omp_ordered_inline_end(void)
\ingroup API_OpenMP_Runtime_Support
Notifies that the ordered section for the current iteration has been completed.
This function together with #starpu_omp_ordered_inline_begin can be used to
implement \#pragma omp ordered without code code outlining.
\fn void starpu_omp_sections(unsigned long long nb_sections, void (**section_f)(void *arg), void **section_arg, int nowait)
\ingroup API_OpenMP_Runtime_Support
Ensures that each function of a given array of functions is executed by one and
only one thread. \p nb_sections is the number of functions in the array \p
section_f. \p section_f is the array of functions to be executed as sections. \p
section_arg is an array of arguments to be passed to the corresponding function.
\p nowait is a flag indicating whether an implicit barrier is requested after
the execution of all the sections (nowait==0) or not (nowait==!0).
This function can be used to implement \#pragma omp sections and \#pragma omp section.
\fn void starpu_omp_sections_combined(unsigned long long nb_sections, void (*section_f)(unsigned long long section_num, void *arg), void **section_arg, int nowait)
\ingroup API_OpenMP_Runtime_Support
Alternative implementation of sections. This function differs from
#starpu_omp_sections in that all the sections are combined within a single
function in this version. \p section_f is the function implementing the combined
sections.
The function \p section_f will be called with arguments \p section_num, the
section number to be executed, \p arg, the entry of \p section_arg corresponding
to this section.
This function can be used to implement \#pragma omp sections and \#pragma omp section.
\sa starpu_omp_sections
@name Task
\anchor ORS_Task
\ingroup API_OpenMP_Runtime_Support
\fn void starpu_omp_task_region(const struct starpu_omp_task_region_attr *attr)
\ingroup API_OpenMP_Runtime_Support
Generates an explicit child task. The execution of the generated task is
asynchronous with respect to the calling code unless specified otherwise.
\p attr specifies the attributes for the generated task region.
This function can be used to implement \#pragma omp task.
\fn void starpu_omp_taskwait(void)
\ingroup API_OpenMP_Runtime_Support
Waits for the completion of the tasks generated by the current task. This
function does not wait for the descendants of the tasks generated by the current
task.
This function can be used to implement \#pragma omp taskwait.
\fn void starpu_omp_taskgroup(void (*f)(void *arg), void *arg)
\ingroup API_OpenMP_Runtime_Support
Launches a function and wait for the completion of every descendant task
generated during the execution of the function.
This function can be used to implement \#pragma omp taskgroup.
@name API
\anchor ORS_API
\ingroup API_OpenMP_Runtime_Support
\fn void starpu_omp_set_num_threads(int threads)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_num_threads()
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_thread_num()
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_max_threads()
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_num_procs (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_in_parallel (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_set_dynamic (int dynamic_threads)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_dynamic (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_set_nested (int nested)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_nested (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_cancellation(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_set_schedule (enum starpu_omp_sched_value kind, int modifier)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_get_schedule (enum starpu_omp_sched_value *kind, int *modifier)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_thread_limit (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_set_max_active_levels (int max_levels)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_max_active_levels (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_level (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_ancestor_thread_num (int level)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_team_size (int level)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_active_level (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_in_final(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn enum starpu_omp_proc_bind_value starpu_omp_get_proc_bind(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_set_default_device(int device_num)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_default_device(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_num_devices(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_num_teams(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_get_team_num(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_is_initial_device(void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_init_lock (starpu_omp_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_destroy_lock (starpu_omp_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_set_lock (starpu_omp_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_unset_lock (starpu_omp_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_test_lock (starpu_omp_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_init_nest_lock (starpu_omp_nest_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_destroy_nest_lock (starpu_omp_nest_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_set_nest_lock (starpu_omp_nest_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn void starpu_omp_unset_nest_lock (starpu_omp_nest_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn int starpu_omp_test_nest_lock (starpu_omp_nest_lock_t *lock)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn double starpu_omp_get_wtime (void)
\ingroup API_OpenMP_Runtime_Support
This function .
\fn double starpu_omp_get_wtick (void)
\ingroup API_OpenMP_Runtime_Support
This function .
*/