88 MPI_Allreduce(MPI_IN_PLACE, cpt, n,
CS_MPI_GNUM, MPI_SUM,
116 MPI_Allreduce(MPI_IN_PLACE, cpt, n,
CS_MPI_LNUM, MPI_MAX,
452 const float g_array[],
552#if defined(HAVE_OPENMP)
553 int n_t = omp_get_max_threads();
554 int n_t_l = n_elements / min_thread_elements;
588#if defined(HAVE_OPENMP)
589 const int t_id = omp_get_thread_num();
590 const int n_t = omp_get_num_threads();
591 const cs_lnum_t t_n = (n + n_t - 1) / n_t;
595 *e_id = (t_id+1) * t_n;
598 if (*e_id > n) *e_id = n;
633#if defined(HAVE_OPENMP)
634 const int t_id = omp_get_thread_num();
635 const double n_t = omp_get_num_threads();
638 double r0 = (double)t_id / (
double)n_t;
639 double r1 = (double)(t_id+1) / (double)n_t;
651 if (*e_id > n) *e_id = n;
674 return (n % block_size) ? n/block_size + 1 : n/block_size;
681#if defined(__cplusplus)
702 [[maybe_unused]]
const int n)
706 if (mpi_w.active()) {
707 MPI_Allreduce(MPI_IN_PLACE, cpt, n,
CS_MPI_GNUM, MPI_SUM,
729 [[maybe_unused]]
const int n
734 if (mpi_w.active()) {
735 MPI_Allreduce(MPI_IN_PLACE, cpt, n,
CS_MPI_LNUM, MPI_MAX,
757 [[maybe_unused]]
int n,
759 [[maybe_unused]]
void *val
764 if (mpi_w.active()) {
765 MPI_Allreduce(MPI_IN_PLACE, val, n,
789 [[maybe_unused]]
int n,
791 [[maybe_unused]]
void *val
796 if (mpi_w.active()) {
797 MPI_Allreduce(MPI_IN_PLACE, val, n,
821 [[maybe_unused]]
int n,
823 [[maybe_unused]]
void *val
828 if (mpi_w.active()) {
829 MPI_Allreduce(MPI_IN_PLACE, val, n,
862 const cs_lnum_t t_n = (n + n_t - 1) / n_t;
866 *e_id = (t_id+1) * t_n;
869 if (*s_id > n) *s_id = n;
870 if (*e_id > n) *e_id = n;
890 typename std::enable_if<!std::is_array<T>::value,
int>::type = 0>
905 constexpr int n_vals =
sizeof...(Vals);
915 T *_values[] = {&values ...};
919 for (
int i = 0; i < n_vals; i++)
920 w[i+1] = *(_values[i]);
925 for (
int i = 0; i < n_vals; i++)
926 *(_values[i]) = w[i+1];
943 typename std::enable_if<!std::is_array<T>::value,
int>::type = 0>
951 sum<T>(mpi_w, first, values...);
966template <
int Stride,
typename T,
typename... Vals>
981 constexpr int n_vals =
sizeof...(Vals);
991 T *_values[] = {values ...};
993 constexpr int work_size = (n_vals + 1) * Stride;
996 for (
int i = 0; i < Stride; i++)
999 for (
int i = 0; i < n_vals; i++) {
1000 for (
int j = 0; j < Stride; j++)
1001 w[(i+1)*Stride + j] = _values[i][j];
1006 for (
int i = 0; i < Stride; i++)
1009 for (
int i = 0; i < n_vals; i++) {
1010 for (
int j = 0; j < Stride; j++)
1011 _values[i][j] = w[(i+1)*Stride + j];
1028template <
int Stride,
typename T,
typename... Vals>
1036#if defined(HAVE_MPI)
1038 sum<Stride, T>(mpi_w, first, values...);
1055template <
typename T,
int N,
typename... Vals>
1064 sum<N>(first, std::forward<Vals>(values)...);
1078template <
typename T,
int N,
typename... Vals>
1087 sum<N>(mpi_w, first, std::forward<Vals>(values)...);
1099template <
typename T,
typename... Vals>
1108#if defined(HAVE_MPI)
1111 constexpr int n_vals =
sizeof...(Vals);
1122 T *_values[] = {&values ...};
1126 for (
int i = 0; i < n_vals; i++)
1127 w[i+1] = *(_values[i]);
1132 for (
int i = 0; i < n_vals; i++)
1133 *(_values[i]) = w[i+1];
1148template <
typename T,
typename... Vals>
1156#if defined(HAVE_MPI)
1158 max(mpi_w, first, values...);
1174template <
int Stride,
typename T,
typename... Vals>
1183#if defined(HAVE_MPI)
1189 constexpr int n_vals =
sizeof...(Vals);
1199 T *_values[] = {values ...};
1201 constexpr int work_size = (n_vals + 1) * Stride;
1204 for (
int i = 0; i < Stride; i++)
1207 for (
int i = 0; i < n_vals; i++)
1208 for (
int j = 0; j < Stride; j++)
1209 w[(i+1)*Stride + j] = _values[i][j];
1213 for (
int i = 0; i < Stride; i++)
1216 for (
int i = 0; i < n_vals; i++)
1217 for (
int j = 0; j < Stride; j++)
1218 _values[i][j] = w[(i+1)*Stride + j];
1233template <
int Stride,
typename T,
typename... Vals>
1241#if defined(HAVE_MPI)
1243 max<Stride>(mpi_w, first, values...);
1258template <
typename T,
typename... Vals>
1267#if defined(HAVE_MPI)
1273 constexpr int n_vals =
sizeof...(Vals);
1285 T *_values[] = {&values ...};
1289 for (
int i = 0; i < n_vals; i++)
1290 w[i + 1] = *(_values[i]);
1295 for (
int i = 0; i < n_vals; i++)
1296 *(_values[i]) = w[i + 1];
1311template <
typename T,
typename... Vals>
1319#if defined(HAVE_MPI)
1321 min(mpi_w, first, values...);
1337template <
int Stride,
typename T,
typename... Vals>
1346#if defined(HAVE_MPI)
1352 constexpr int n_vals =
sizeof...(Vals);
1362 T *_values[] = {values ...};
1364 constexpr int work_size = (n_vals + 1) * Stride;
1367 for (
int i = 0; i < Stride; i++)
1370 for (
int i = 0; i < n_vals; i++)
1371 for (
int j = 0; j < Stride; j++)
1372 w[(i+1)*Stride + j] = _values[i][j];
1376 for (
int i = 0; i < Stride; i++)
1379 for (
int i = 0; i < n_vals; i++)
1380 for (
int j = 0; j < Stride; j++)
1381 _values[i][j] = w[(i+1)*Stride + j];
1397template <
int Stride,
typename T,
typename... Vals>
1405#if defined(HAVE_MPI)
1407 min<Stride>(mpi_w, first, values...);
1424template <
typename T,
typename... Vals>
1432#if defined(HAVE_MPI)
1438 constexpr size_t n_vals =
sizeof...(Vals);
1448 T *_values[] = {&values ...};
1452 for (
size_t i = 0; i < n_vals; i++)
1453 w[i+1] = *(_values[i]);
1458 for (
size_t i = 0; i < n_vals; i++)
1459 *(_values[i]) = w[i+1];
1473template <
typename T,
typename... Vals>
1482#if defined(HAVE_MPI)
1485 constexpr size_t n_vals =
sizeof...(Vals);
1495 T *_values[] = {&values ...};
1499 for (
size_t i = 0; i < n_vals; i++)
1500 w[i+1] = *(_values[i]);
1505 for (
size_t i = 0; i < n_vals; i++)
1506 *(_values[i]) = w[i+1];
1521template <
int Stride,
typename T,
typename... Vals>
1530#if defined(HAVE_MPI)
1535 constexpr size_t n_vals =
sizeof...(Vals);
1545 T *_values[] = {values ...};
1547 constexpr size_t work_size = (n_vals + 1) * Stride;
1550 for (
int i = 0; i < Stride; i++)
1553 for (
size_t i = 0; i < n_vals; i++)
1554 for (
int j = 0; j < Stride; j++)
1555 w[(i+1)*Stride + j] = _values[i][j];
1559 for (
int i = 0; i < Stride; i++)
1562 for (
size_t i = 0; i < n_vals; i++) {
1563 for (
int j = 0; j < Stride; j++)
1564 _values[i][j] = w[(i+1)*Stride + j];
1581template <
int Stride,
typename T,
typename... Vals>
1589#if defined(HAVE_MPI)
1595 constexpr size_t n_vals =
sizeof...(Vals);
1605 T *_values[] = {values ...};
1607 constexpr size_t work_size = (n_vals + 1) * Stride;
1610 for (
int i = 0; i < Stride; i++)
1613 for (
int i = 0; i < n_vals; i++) {
1614 for (
int j = 0; j < Stride; j++)
1615 w[(i+1)*Stride + j] = _values[i][j];
1620 for (
int i = 0; i < Stride; i++)
1623 for (
size_t i = 0; i < n_vals; i++) {
1624 for (
int j = 0; j < Stride; j++)
1625 _values[i][j] = w[(i+1)*Stride + j];
1641template <
typename T,
typename... Vals>
1649#if defined(HAVE_MPI)
1655 constexpr size_t n_vals =
sizeof...(Vals);
1666 T *_values[] = {&values ...};
1670 for (
size_t i = 0; i < n_vals; i++)
1671 w[i+1] = *(_values[i]);
1676 for (
size_t i = 0; i < n_vals; i++)
1677 *(_values[i]) = w[i+1];
1691template <
typename T,
typename... Vals>
1700#if defined(HAVE_MPI)
1703 constexpr size_t n_vals =
sizeof...(Vals);
1714 T *_values[] = {&values ...};
1718 for (
size_t i = 0; i < n_vals; i++)
1719 w[i+1] = *(_values[i]);
1724 for (
size_t i = 0; i < n_vals; i++)
1725 *(_values[i]) = w[i+1];
1741template <
int Stride,
typename T,
typename... Vals>
1749#if defined(HAVE_MPI)
1755 constexpr size_t n_vals =
sizeof...(Vals);
1765 T *_values[] = {values ...};
1767 constexpr size_t work_size = (n_vals + 1) * Stride;
1770 for (
int i = 0; i < Stride; i++)
1773 for (
size_t i = 0; i < n_vals; i++)
1774 for (
int j = 0; j < Stride; j++)
1775 w[(i+1)*Stride + j] = _values[i][j];
1779 for (
int i = 0; i < Stride; i++)
1782 for (
size_t i = 0; i < n_vals; i++)
1783 for (
int j = 0; j < Stride; j++)
1784 _values[i][j] = w[(i+1)*Stride + j];
1799template <
int Stride,
typename T,
typename... Vals>
1808#if defined(HAVE_MPI)
1811 constexpr size_t n_vals =
sizeof...(Vals);
1821 T *_values[] = {values ...};
1823 constexpr size_t work_size = (n_vals + 1) * Stride;
1826 for (
int i = 0; i < Stride; i++)
1829 for (
size_t i = 0; i < n_vals; i++)
1830 for (
int j = 0; j < Stride; j++)
1831 w[(i+1)*Stride + j] = _values[i][j];
1835 for (
int i = 0; i < Stride; i++)
1838 for (
size_t i = 0; i < n_vals; i++)
1839 for (
int j = 0; j < Stride; j++)
1840 _values[i][j] = w[(i+1)*Stride + j];
1855template <
typename T,
typename... Vals>
1863#if defined(HAVE_MPI)
1869 constexpr size_t n_vals =
sizeof...(Vals);
1881 T *_values[] = {&values ...};
1885 for (
size_t i = 0; i < n_vals; i++)
1886 w[i + 1] = *(_values[i]);
1891 for (
size_t i = 0; i < n_vals; i++)
1892 *(_values[i]) = w[i + 1];
1906template <
typename T,
typename... Vals>
1915#if defined(HAVE_MPI)
1918 constexpr size_t n_vals =
sizeof...(Vals);
1930 T *_values[] = {&values ...};
1934 for (
size_t i = 0; i < n_vals; i++)
1935 w[i + 1] = *(_values[i]);
1940 for (
size_t i = 0; i < n_vals; i++)
1941 *(_values[i]) = w[i + 1];
1957template <
int Stride,
typename T,
typename... Vals>
1965#if defined(HAVE_MPI)
1971 constexpr size_t n_vals =
sizeof...(Vals);
1981 T *_values[] = {values ...};
1983 constexpr size_t work_size = (n_vals + 1) * Stride;
1986 for (
int i = 0; i < Stride; i++)
1989 for (
size_t i = 0; i < n_vals; i++)
1990 for (
int j = 0; j < Stride; j++)
1991 w[(i+1)*Stride + j] = _values[i][j];
1995 for (
int i = 0; i < Stride; i++)
1998 for (
size_t i = 0; i < n_vals; i++)
1999 for (
int j = 0; j < Stride; j++)
2000 _values[i][j] = w[(i+1)*Stride + j];
2015template <
int Stride,
typename T,
typename... Vals>
2024#if defined(HAVE_MPI)
2027 constexpr size_t n_vals =
sizeof...(Vals);
2038 T *_values[] = {values ...};
2040 constexpr size_t work_size = (n_vals + 1) * Stride;
2043 for (
int i = 0; i < Stride; i++)
2046 for (
size_t i = 0; i < n_vals; i++)
2047 for (
int j = 0; j < Stride; j++)
2048 w[(i+1)*Stride + j] = _values[i][j];
2052 for (
int i = 0; i < Stride; i++)
2055 for (
size_t i = 0; i < n_vals; i++)
2056 for (
int j = 0; j < Stride; j++)
2057 _values[i][j] = w[(i+1)*Stride + j];
Definition: cs_execution_context.h:46
CS_F_HOST_DEVICE bool active() const
Definition: cs_execution_context.h:77
int cs_glob_n_ranks
Definition: cs_defs.cpp:171
MPI_Datatype cs_datatype_to_mpi[]
Definition: cs_defs.cpp:153
MPI_Comm cs_glob_mpi_comm
Definition: cs_defs.cpp:179
cs_datatype_t
Definition: cs_defs.h:290
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
#define CS_MPI_LNUM
Definition: cs_defs.h:428
#define CS_MPI_GNUM
Definition: cs_defs.h:420
unsigned cs_gnum_t
global mesh entity number
Definition: cs_defs.h:317
static cs_lnum_t cs_align(cs_lnum_t i, cs_lnum_t m)
Given a base index i, return the next index aligned with a size m.
Definition: cs_defs.h:639
#define CS_UNUSED(x)
Definition: cs_defs.h:518
#define END_C_DECLS
Definition: cs_defs.h:529
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
#define CS_CL_SIZE
Definition: cs_defs.h:488
void cs_parall_gather_r(int root_rank, int n_elts, int n_g_elts, const cs_real_t array[], cs_real_t g_array[])
Build a global array on the given root rank from all local arrays.
Definition: cs_parall.cpp:527
static void cs_parall_bcast(int root_rank, int n, cs_datatype_t datatype, void *val)
Broadcast values of a given datatype to all default communicator processes.
Definition: cs_parall.h:237
static void cs_parall_min_strided(T first[], Vals &&... values)
Minimum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:1960
void cs_parall_set_min_coll_buf_size(size_t buffer_size)
Define minimum recommended scatter or gather buffer size.
Definition: cs_parall.cpp:850
void cs_parall_gather_ordered_r(int root_rank, int n_elts, int n_g_elts, int stride, cs_real_t o_key[], cs_real_t array[], cs_real_t g_array[])
Build an ordered global array on the given root rank from all local arrays.
Definition: cs_parall.cpp:594
void cs_parall_min_id_rank_r(cs_lnum_t *elt_id, int *rank_id, cs_real_t val)
Given an (id, rank, value) tuple, return the local id and rank corresponding to the global minimum va...
Definition: cs_parall.cpp:352
static void cs_parall_thread_range_upper(cs_lnum_t n, size_t type_size, cs_lnum_t *s_id, cs_lnum_t *e_id)
Compute array index bounds for a local thread for upper triangular matrix elements.
Definition: cs_parall.h:628
static void cs_parall_max(int n, cs_datatype_t datatype, void *val)
Maximum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:171
static void cs_parall_counter_max(cs_lnum_t cpt[], const int n)
Maximum values of a counter on all default communicator processes.
Definition: cs_parall.h:110
void cs_parall_allgather_r(int n_elts, int n_g_elts, cs_real_t array[], cs_real_t g_array[])
Build a global array from each local array in each domain.
Definition: cs_parall.cpp:406
static int cs_parall_n_threads(cs_lnum_t n_elements, cs_lnum_t min_thread_elements)
Compute recommended number of threads for a section.
Definition: cs_parall.h:549
static void cs_parall_max_scalars(T &first, Vals &... values)
Maximum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:1644
static void cs_parall_counter(cs_gnum_t cpt[], const int n)
Sum values of a counter on all default communicator processes.
Definition: cs_parall.h:82
void cs_parall_scatter_r(int root_rank, int n_elts, int n_g_elts, const cs_real_t g_array[], cs_real_t array[])
Distribute a global array from a given root rank over all ranks. Each rank receive the part related t...
Definition: cs_parall.cpp:643
static void cs_parall_sum(int n, cs_datatype_t datatype, void *val)
Sum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:139
void cs_parall_allgather_ordered_r(int n_elts, int n_g_elts, int stride, cs_real_t o_key[], cs_real_t array[], cs_real_t g_array[])
Build an ordered global array from each local array in each domain.
Definition: cs_parall.cpp:483
void cs_parall_scatter_f(int root_rank, int n_elts, int n_g_elts, const float g_array[], float array[])
Distribute a global array from a given root rank over all ranks. Each rank receive the part related t...
Definition: cs_parall.cpp:773
static void cs_parall_thread_range(cs_lnum_t n, size_t type_size, cs_lnum_t *s_id, cs_lnum_t *e_id)
Compute array index bounds for a local thread. When called inside an OpenMP parallel section,...
Definition: cs_parall.h:583
void cs_parall_min_loc_vals(int n, cs_real_t *min, cs_real_t min_loc_vals[])
Minimum value of a real and the value of related array on all default communicator processes.
Definition: cs_parall.cpp:313
static void cs_parall_sum_scalars(T &first, Vals &... values)
Sum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:1427
static void cs_parall_min(int n, cs_datatype_t datatype, void *val)
Minimum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:203
void cs_parall_gather_f(int root_rank, int n_elts, int n_g_elts, const float array[], float g_array[])
Build a global array on the given root rank from all local arrays. Function dealing with single-preci...
Definition: cs_parall.cpp:708
void cs_parall_max_loc_vals(int n, cs_real_t *max, cs_real_t max_loc_vals[])
Maximum value of a real and the value of related array on all default communicator processes.
Definition: cs_parall.cpp:275
size_t cs_parall_get_min_coll_buf_size(void)
Return minimum recommended scatter or gather buffer size.
Definition: cs_parall.cpp:828
static size_t cs_parall_block_count(size_t n, size_t block_size)
Compute number of blocks needed for a given array and block sizes.
Definition: cs_parall.h:671
static void cs_parall_min_scalars(T &first, Vals &... values)
Minimum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:1858
static void cs_parall_max_strided(T first[], Vals &&... values)
Maximum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:1744
cs_e2n_sum_t
Definition: cs_parall.h:52
@ CS_E2N_SUM_SCATTER
Definition: cs_parall.h:54
@ CS_E2N_SUM_GATHER
Definition: cs_parall.h:56
static void cs_parall_sum_strided(const cs_mpi_wrapper &mpi_w, T first[], Vals &&... values)
Sum strided-values of a given datatype over a communicator.
Definition: cs_parall.h:1524
cs_e2n_sum_t cs_glob_e2n_sum_type
mpi_wrapper & default_mpi(void)
Definition: cs_execution_context.cpp:78
static void min(const cs_mpi_wrapper &mpi_w, T &first, Vals &... values)
Minimum values of a given datatype on a given communicator processes.
Definition: cs_parall.h:1261
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
static void max(T first[], Vals &&... values)
Maximum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:1236
static void max(const cs_mpi_wrapper &mpi_w, T &first, Vals &... values)
Maximum values of a given datatype on a given communicator processes.
Definition: cs_parall.h:1102
static void min(T first[], Vals &&... values)
Minimum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:1400
Definition: cs_algorithm.h:51
Definition: parall.f90:26