1#ifndef CS_EXECUTION_CONTEXT_H
2#define CS_EXECUTION_CONTEXT_H
79 bool retval = (_comm_n_ranks > 1) ?
true :
false;
88 bool retval = (_comm_rank < 1) ?
true :
false;
97 if (_comm != MPI_COMM_NULL)
98 MPI_Comm_free(&(this->_comm));
99 this->_comm = MPI_COMM_NULL;
115 MPI_Comm_rank(this->_comm, &(this->_comm_rank));
116 MPI_Comm_size(this->_comm, &(this->_comm_n_ranks));
133 MPI_Comm _comm = MPI_COMM_NULL;
137 int _comm_n_ranks = 0;
227template<
exec_type _EXEC_,
class F,
class... Args>
232 _ctx.parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
242template <
class F,
class... Args>
246 _ctx.parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
256template <
class F,
class... Args>
259 ctx.
parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
269template <
class F,
class... Args>
272 ctx.
parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
284template <
exec_type _EXEC_,
class M,
class F,
class... Args>
290 _ctx.parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
301template <
class M,
class F,
class... Args>
306 _ctx.parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
316template <
class M,
class F,
class... Args>
320 ctx.
parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
330template <
class M,
class F,
class... Args>
334 ctx.
parallel_for(n,
static_cast<F&&
>(f),
static_cast<Args&&
>(args)...);
345template <
exec_type _EXEC_,
class T,
class F,
class... Args>
355 _ctx.parallel_for_reduce_sum(n,
358 static_cast<Args&&
>(args)...);
369template <
class T,
class F,
class... Args>
378 _ctx.parallel_for_reduce_sum(n,
381 static_cast<Args&&
>(args)...);
392template <
class T,
class F,
class... Args>
404 static_cast<Args&&
>(args)...);
415template <
class T,
class F,
class... Args>
427 static_cast<Args&&
>(args)...);
440template <
exec_type _EXEC_,
class T,
class R,
class F,
class... Args>
451 _ctx.parallel_for_reduce(n,
455 static_cast<Args&&
>(args)...);
466template <
class T,
class R,
class F,
class... Args>
476 _ctx.parallel_for_reduce(n,
480 static_cast<Args&&
>(args)...);
491template <
class T,
class R,
class F,
class... Args>
505 static_cast<Args&&
>(args)...);
516template <
class T,
class R,
class F,
class... Args>
530 static_cast<Args&&
>(args)...);
557template<
class... Args>
573template<
class... Args>
590template<
class... Args>
Definition: cs_execution_context.h:140
cs_dispatch_context * ctx
Definition: cs_execution_context.h:159
environment()
Definition: cs_execution_context.h:143
~environment()
Definition: cs_execution_context.h:149
mpi_wrapper * mpi
Definition: cs_execution_context.h:158
Definition: cs_execution_context.h:46
CS_F_HOST mpi_wrapper()
Definition: cs_execution_context.h:51
CS_F_HOST_DEVICE int n_ranks() const
Definition: cs_execution_context.h:69
CS_F_HOST void set_comm(MPI_Comm comm)
Definition: cs_execution_context.h:107
CS_F_HOST MPI_Comm comm() const
Definition: cs_execution_context.h:123
CS_F_HOST_DEVICE bool is_root() const
Definition: cs_execution_context.h:86
CS_F_HOST ~mpi_wrapper()
Definition: cs_execution_context.h:55
CS_F_HOST void free()
Definition: cs_execution_context.h:94
CS_F_HOST_DEVICE int rank() const
Definition: cs_execution_context.h:61
CS_F_HOST_DEVICE bool active() const
Definition: cs_execution_context.h:77
auto parallel_for_reduce_sum(cs_lnum_t n, T &sum, F &&f, Args &&... args)
Definition: cs_dispatch.h:2169
auto parallel_for_reduce(cs_lnum_t n, T &result, R &reducer, F &&f, Args &&... args)
Definition: cs_dispatch.h:2195
auto parallel_for(cs_lnum_t n, F &&f, Args &&... args)
Definition: cs_dispatch.h:2146
void wait(void)
Wait (synchronize) until launched computations have finished.
Definition: cs_dispatch.h:2211
Definition: cs_dispatch.h:2288
Definition: cs_dispatch.h:215
bool parallel_for(cs_lnum_t n, F &&f, Args &&... args)
Iterate using a plain omp parallel for.
Definition: cs_dispatch.h:310
bool parallel_for_reduce_sum(cs_lnum_t n, T &sum, F &&f, Args &&... args)
Plain OpenMP parallel reduction with simple sum.
Definition: cs_dispatch.h:369
bool wait(void)
Wait upon completion.
Definition: cs_dispatch.h:488
bool parallel_for_reduce(cs_lnum_t n, T &result, R &reducer, F &&f, Args &&... args)
OpenMP parallel reduction with general reducer.
Definition: cs_dispatch.h:431
static bool _initialized
Definition: cs_boundary_conditions_type.cpp:69
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:555
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
#define CS_F_HOST
Definition: cs_defs.h:553
void cs_execution_default_env_init(void)
Initialize the global execution context.
Definition: cs_execution_context.cpp:88
void cs_execution_default_env_init_context(void)
Initialize context (CPU/GPU)
Definition: cs_execution_context.cpp:102
void cs_execution_default_env_finalize()
Free the global execution context pointer.
Definition: cs_execution_context.cpp:112
cs_host_context & default_h_context(void)
Definition: cs_execution_context.cpp:72
const environment * default_env(void)
Definition: cs_execution_context.cpp:52
cs_dispatch_context & default_context(void)
Definition: cs_execution_context.cpp:62
mpi_wrapper & default_mpi(void)
Definition: cs_execution_context.cpp:78
static void sum(const cs_mpi_wrapper &mpi_w, T &first, Vals &... values)
Sum values of a given datatype over a given communicator.
Definition: cs_parall.h:893
Definition: cs_algorithm.h:51
bool parallel_for_reduce_sum(cs_lnum_t n, T &sum, F &&f, Args &&... args)
parallel_for_reduce_sum construct using a dispatch context based on template parameter (enum) "exec_t...
Definition: cs_execution_context.h:347
bool parallel_for_i_faces(const M *m, F &&f, Args &&... args)
parallel_for_i_faces construct using a dispatch context based on template parameter (enum) "exec_type...
Definition: cs_execution_context.h:286
exec_type
Definition: cs_execution_context.h:214
bool wait(void)
wait construct using a dispatch context based on template parameter of exec_type (enum)
Definition: cs_execution_context.h:543
bool parallel_for_reduce(cs_lnum_t n, T &result, R &reducer, F &&f, Args &&... args)
parallel_for_reduce construct using a dispatch context based on template parameter (enum) "exec_type"
Definition: cs_execution_context.h:442
bool parallel_for(cs_lnum_t n, F &&f, Args &&... args)
parallel_for construct using a dispatch context based on template parameter (enum) "exec_type"
Definition: cs_execution_context.h:229