Loading...
Searching...
No Matches
openmp_runtime_support.h
Go to the documentation of this file.
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2014-2025 University of Bordeaux, CNRS (LaBRI UMR 5800), Inria
*
* StarPU is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* StarPU is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
*/
#ifndef __OPENMP_RUNTIME_SUPPORT_H__
#define __OPENMP_RUNTIME_SUPPORT_H__
#include <starpu.h>
#ifdef STARPU_OPENMP
#include <common/list.h>
#include <common/starpu_spinlock.h>
#include <common/uthash.h>
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <ucontext.h>
#pragma GCC visibility push(hidden)
extern starpu_pthread_key_t omp_thread_key;
extern starpu_pthread_key_t omp_task_key;
#define STARPU_OMP_MAX_ACTIVE_LEVELS 1
enum starpu_omp_place_name
{
starpu_omp_place_undefined = 0,
starpu_omp_place_threads = 1,
starpu_omp_place_cores = 2,
starpu_omp_place_sockets = 3,
starpu_omp_place_numerical = 4
};
struct starpu_omp_numeric_place
{
int excluded_place;
int *included_numeric_items;
int nb_included_numeric_items;
int *excluded_numeric_items;
int nb_excluded_numeric_items;
};
struct starpu_omp_place
{
int abstract_name;
int abstract_excluded;
int abstract_length;
struct starpu_omp_numeric_place *numeric_places;
int nb_numeric_places;
};
struct starpu_omp_data_environment_icvs
{
int dyn_var;
int nest_var;
int *nthreads_var;
int thread_limit_var;
int active_levels_var;
int levels_var;
int *bind_var;
int run_sched_var;
unsigned long long run_sched_chunk_var;
int default_device_var;
int max_task_priority_var;
};
struct starpu_omp_device_icvs
{
int max_active_levels_var;
int def_sched_var;
unsigned long long def_sched_chunk_var;
int stacksize_var;
int wait_policy_var;
};
struct starpu_omp_implicit_task_icvs
{
int place_partition_var;
};
struct starpu_omp_global_icvs
{
int cancel_var;
};
struct starpu_omp_initial_icv_values
{
int dyn_var;
int nest_var;
int *nthreads_var;
int run_sched_var;
unsigned long long run_sched_chunk_var;
int def_sched_var;
unsigned long long def_sched_chunk_var;
int *bind_var;
int stacksize_var;
int wait_policy_var;
int thread_limit_var;
int max_active_levels_var;
int active_levels_var;
int levels_var;
int place_partition_var;
int cancel_var;
int default_device_var;
int max_task_priority_var;
struct starpu_omp_place places;
};
struct starpu_omp_task_group
{
int descendent_task_count;
struct starpu_omp_task *leader_task;
struct starpu_omp_task_group *p_previous_task_group;
};
struct starpu_omp_task_link
{
struct starpu_omp_task *task;
struct starpu_omp_task_link *next;
};
struct starpu_omp_condition
{
struct starpu_omp_task_link *contention_list_head;
};
struct starpu_omp_critical
{
UT_hash_handle hh;
struct _starpu_spinlock lock;
unsigned state;
struct starpu_omp_task_link *contention_list_head;
const char *name;
};
enum starpu_omp_task_state
{
starpu_omp_task_state_clear = 0,
starpu_omp_task_state_preempted = 1,
starpu_omp_task_state_terminated = 2,
starpu_omp_task_state_zombie = 3,
starpu_omp_task_state_target = 4,
};
enum starpu_omp_task_wait_on
{
starpu_omp_task_wait_on_task_childs = 1 << 0,
starpu_omp_task_wait_on_region_tasks = 1 << 1,
starpu_omp_task_wait_on_barrier = 1 << 2,
starpu_omp_task_wait_on_group = 1 << 3,
starpu_omp_task_wait_on_critical = 1 << 4,
starpu_omp_task_wait_on_ordered = 1 << 5,
starpu_omp_task_wait_on_lock = 1 << 6,
starpu_omp_task_wait_on_nest_lock = 1 << 7,
};
enum starpu_omp_task_flags
{
STARPU_OMP_TASK_FLAGS_IMPLICIT = 1 << 0,
STARPU_OMP_TASK_FLAGS_UNDEFERRED = 1 << 1,
STARPU_OMP_TASK_FLAGS_FINAL = 1 << 2,
STARPU_OMP_TASK_FLAGS_UNTIED = 1 << 3,
};
LIST_TYPE(starpu_omp_task,
struct starpu_omp_implicit_task_icvs icvs;
struct starpu_omp_task *parent_task;
struct starpu_omp_thread *owner_thread;
struct starpu_omp_region *owner_region;
struct starpu_omp_region *nested_region;
int rank;
int child_task_count;
struct starpu_omp_task_group *task_group;
struct _starpu_spinlock lock;
int transaction_pending;
int wait_on;
int barrier_count;
int single_id;
int single_first;
int loop_id;
unsigned long long ordered_first_i;
unsigned long long ordered_nb_i;
int sections_id;
struct starpu_omp_data_environment_icvs data_env_icvs;
struct starpu_omp_implicit_task_icvs implicit_task_icvs;
struct handle_entry *registered_handles;
struct starpu_task *starpu_task;
struct starpu_codelet cl;
void **starpu_buffers;
void *starpu_cl_arg;
/* Driver porters: adding your driver here is very optional. */
void (*cpu_f)(void **starpu_buffers, void *starpu_cl_arg);
void (*cuda_f)(void **starpu_buffers, void *starpu_cl_arg);
void (*opencl_f)(void **starpu_buffers, void *starpu_cl_arg);
enum starpu_omp_task_state state;
enum starpu_omp_task_flags flags;
/*
* context to store the processing state of the task
* in case of blocking/recursive task operation
*/
ucontext_t ctx;
/*
* stack to execute the task over, to be able to switch
* in case blocking/recursive task operation
*/
void *stack;
/*
* Valgrind stack id
*/
int stack_vg_id;
size_t stacksize;
/*
* taskloop attribute
* */
int is_loop;
unsigned long long nb_iterations;
unsigned long long grainsize;
unsigned long long chunk;
unsigned long long begin_i;
unsigned long long end_i;
)
LIST_TYPE(starpu_omp_thread,
UT_hash_handle hh;
struct starpu_omp_task *current_task;
struct starpu_omp_region *owner_region;
/*
* stack to execute the initial thread over
* when preempting the initial task
* note: should not be used for other threads
*/
void *initial_thread_stack;
/*
* Valgrind stack id
*/
int initial_thread_stack_vg_id;
/*
* context to store the 'scheduler' state of the thread,
* to which the execution of thread comes back upon a
* blocking/recursive task operation
*/
ucontext_t ctx;
struct starpu_driver starpu_driver;
struct _starpu_worker *worker;
)
struct _starpu_omp_lock_internal
{
struct _starpu_spinlock lock;
struct starpu_omp_condition cond;
unsigned state;
};
struct _starpu_omp_nest_lock_internal
{
struct _starpu_spinlock lock;
struct starpu_omp_condition cond;
unsigned state;
struct starpu_omp_task *owner_task;
unsigned nesting;
};
struct starpu_omp_loop
{
int id;
unsigned long long next_iteration;
int nb_completed_threads;
struct starpu_omp_loop *next_loop;
struct _starpu_spinlock ordered_lock;
struct starpu_omp_condition ordered_cond;
unsigned long long ordered_iteration;
};
struct starpu_omp_sections
{
int id;
unsigned long long next_section_num;
int nb_completed_threads;
struct starpu_omp_sections *next_sections;
};
struct starpu_omp_region
{
struct starpu_omp_data_environment_icvs icvs;
struct starpu_omp_region *parent_region;
struct starpu_omp_device *owner_device;
struct starpu_omp_thread *master_thread;
struct starpu_omp_thread_list thread_list;
struct starpu_omp_task **implicit_task_array;
int nb_threads;
struct _starpu_spinlock lock;
struct starpu_omp_task *waiting_task;
int barrier_count;
int bound_explicit_task_count;
int single_id;
void *copy_private_data;
int level;
struct starpu_omp_loop *loop_list;
struct starpu_omp_sections *sections_list;
struct starpu_task *continuation_starpu_task;
struct handle_entry *registered_handles;
struct _starpu_spinlock registered_handles_lock;
};
struct starpu_omp_device
{
struct starpu_omp_device_icvs icvs;
struct _starpu_spinlock atomic_lock;
};
struct starpu_omp_global
{
struct starpu_omp_global_icvs icvs;
struct starpu_omp_task *initial_task;
struct starpu_omp_thread *initial_thread;
struct starpu_omp_region *initial_region;
struct starpu_omp_device *initial_device;
struct starpu_omp_critical *default_critical;
struct starpu_omp_critical *named_criticals;
struct _starpu_spinlock named_criticals_lock;
struct starpu_omp_thread *hash_workers;
struct _starpu_spinlock hash_workers_lock;
struct starpu_arbiter *default_arbiter;
unsigned nb_starpu_cpu_workers;
int *starpu_cpu_worker_ids;
int environment_valid;
};
/*
* internal global variables
*/
extern struct starpu_omp_initial_icv_values *_starpu_omp_initial_icv_values;
extern struct starpu_omp_global *_starpu_omp_global_state;
extern starpu_pthread_key_t _starpu_omp_thread_key;
extern starpu_pthread_key_t _starpu_omp_task_key;
extern double _starpu_omp_clock_ref;
/*
* internal API
*/
void _starpu_omp_environment_init(void);
void _starpu_omp_environment_exit(void);
int _starpu_omp_environment_check(void);
struct starpu_omp_thread *_starpu_omp_get_thread(void);
struct starpu_omp_region *_starpu_omp_get_region_at_level(int level) STARPU_ATTRIBUTE_VISIBILITY_DEFAULT;
struct starpu_omp_task *_starpu_omp_get_task(void);
int _starpu_omp_get_region_thread_num(const struct starpu_omp_region *const region) STARPU_ATTRIBUTE_VISIBILITY_DEFAULT;
void _starpu_omp_dummy_init(void);
void _starpu_omp_dummy_shutdown(void);
#endif // STARPU_OPENMP
#pragma GCC visibility pop
#endif // __OPENMP_RUNTIME_SUPPORT_H__
starpu_driver
Definition starpu_driver.h:49
list.h
starpu_omp_device_icvs::def_sched_var
int def_sched_var
Definition openmp_runtime_support.h:113
starpu_omp_data_environment_icvs::run_sched_var
int run_sched_var
Definition openmp_runtime_support.h:99
starpu_omp_place_name
starpu_omp_place_name
Definition openmp_runtime_support.h:53
starpu_omp_data_environment_icvs::thread_limit_var
int thread_limit_var
Definition openmp_runtime_support.h:92
starpu_omp_implicit_task_icvs::place_partition_var
int place_partition_var
Definition openmp_runtime_support.h:124
starpu_omp_device_icvs::max_active_levels_var
int max_active_levels_var
Definition openmp_runtime_support.h:110
starpu_omp_device_icvs::stacksize_var
int stacksize_var
Definition openmp_runtime_support.h:117
starpu_omp_task_state
starpu_omp_task_state
Definition openmp_runtime_support.h:186
starpu_omp_task_state_target
@ starpu_omp_task_state_target
Definition openmp_runtime_support.h:193
starpu_omp_initial_icv_values::places
struct starpu_omp_place places
Definition openmp_runtime_support.h:155
starpu_omp_data_environment_icvs::dyn_var
int dyn_var
Definition openmp_runtime_support.h:89
starpu_omp_data_environment_icvs::default_device_var
int default_device_var
Definition openmp_runtime_support.h:103
starpu_omp_global_icvs::cancel_var
int cancel_var
Definition openmp_runtime_support.h:130
starpu_omp_condition
Definition openmp_runtime_support.h:172
starpu_omp_critical
Definition openmp_runtime_support.h:177
starpu_omp_data_environment_icvs
Definition openmp_runtime_support.h:87
starpu_omp_device_icvs
Definition openmp_runtime_support.h:108
starpu_omp_global_icvs
Definition openmp_runtime_support.h:128
starpu_omp_implicit_task_icvs
Definition openmp_runtime_support.h:122
starpu_omp_initial_icv_values
Definition openmp_runtime_support.h:134
starpu_omp_numeric_place
Definition openmp_runtime_support.h:62
starpu_omp_place
Definition openmp_runtime_support.h:74
starpu_omp_task_group
Definition openmp_runtime_support.h:159
starpu_omp_task_link
Definition openmp_runtime_support.h:166
starpu_spinlock.h
_starpu_spinlock
Definition starpu_spinlock.h:82
_starpu_worker
Definition workers.h:155
uthash.h
UT_hash_handle
Definition uthash.h:1017