TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Comm_Group_Noparallel.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Comm_Group_Noparallel_included
17#define Comm_Group_Noparallel_included
18
19#include <Comm_Group.h>
20
22{
23 Declare_instanciable_sans_constructeur_ni_destructeur(Comm_Group_Noparallel);
24public:
26 ~Comm_Group_Noparallel() override;
27 void abort() const override;
28
29 void mp_collective_op(const double *x, double *resu, int n, Collective_Op op) const override { mp_collective_op_template<double>(x,resu,n,op); }
30 void mp_collective_op(const double *x, double *resu, const Collective_Op *op, int n) const override { mp_collective_op_template<double>(x,resu,op,n); }
31 void mp_collective_op(const float *x, float *resu, int n, Collective_Op op) const override { mp_collective_op_template<float>(x,resu,n,op); }
32 void mp_collective_op(const float *x, float *resu, const Collective_Op *op, int n) const override { mp_collective_op_template<float>(x,resu,op,n); }
33 void mp_collective_op(const int *x, int *resu, int n, Collective_Op op) const override { mp_collective_op_template<int>(x,resu,n,op); }
34 void mp_collective_op(const int *x, int *resu, const Collective_Op *op, int n) const override { mp_collective_op_template<int>(x,resu,op,n); }
35#if INT_is_64_ == 2
36 void mp_collective_op(const trustIdType *x, trustIdType *resu, int n, Collective_Op op) const override { mp_collective_op_template<trustIdType>(x,resu,n,op); }
37 void mp_collective_op(const trustIdType *x, trustIdType *resu, const Collective_Op *op, int n) const override { mp_collective_op_template<trustIdType>(x,resu,op,n); }
38#endif
39
40 void barrier(int tag) const override;
41 int reverse_send_recv_list(const ArrOfInt& src_list, ArrOfInt& dest_list) const;
42
43 Comm_Group_Noparallel(const ArrOfInt& pe_list);
44 void send_recv_start(const ArrOfInt& send_list, const ArrOfInt& send_size, const char *const*const send_buffers, const ArrOfInt& recv_list, const ArrOfInt& recv_size, char *const*const recv_buffers,
45 TypeHint typehint = CHAR) const override;
46
47 void send_recv_finish() const override;
48 void send(int pe, const void *buffer, int size, int tag) const override; // Envoi bloquant
49 void recv(int pe, void *buffer, int size, int tag) const override; // Reception bloquante
50 void broadcast(void *buffer, int size, int pe_source) const override;
51 void all_to_all(const void *src_buffer, void *dest_buffer, int data_size) const override;
52 void all_gather(const void *src_buffer, void *dest_buffer, int data_size) const override;
53 void gather(const void *src_buffer, void *dest_buffer, int data_size, int root) const override;
54 void all_gatherv(const void *src_buffer, void *dest_buffer, int send_size, const int* recv_size, const int* displs) const override;
55
56protected:
57 void init_group(const ArrOfInt& pe_list) override;
58
59private:
60 static int sending_;
61
62 // Operation collective sur chaque element d'un tableau de taille n.
63 // x et resu doivent pointer sur un tableau de taille n.
64 template <typename _TYPE_>
65 void mp_collective_op_template(const _TYPE_ *x, _TYPE_ *resu, int n, Collective_Op op) const
66 {
67 if (op != COLL_PARTIAL_SUM)
68 for (int i = 0; i < n; i++) resu[i] = x[i];
69 else
70 for (int i = 0; i < n; i++) resu[i] = 0;
71 }
72
73 /*! @brief Operation collective sur chaque element d'un tableau de taille n.
74 *
75 * x, resu et op doivent pointer sur un tableau de taille n.
76 * Pour chaque element x[i] on effectue l'operation op[i] et on met le resultat dans resu[i]
77 *
78 */
79 template <typename _TYPE_>
80 void mp_collective_op_template(const _TYPE_ *x, _TYPE_ *resu, const Collective_Op *op, int n) const
81 {
82 for (int i = 0; i < n; i++)
83 {
84 if (op[i] != COLL_PARTIAL_SUM) resu[i] = x[i];
85 else resu[i] = 0;
86 }
87 }
88};
89
90#endif /* Comm_Group_Noparallel_included */
void mp_collective_op(const int *x, int *resu, int n, Collective_Op op) const override
Comm_Group_Noparallel(const ArrOfInt &pe_list)
void mp_collective_op(const double *x, double *resu, int n, Collective_Op op) const override
void recv(int pe, void *buffer, int size, int tag) const override
void send_recv_finish() const override
void all_gather(const void *src_buffer, void *dest_buffer, int data_size) const override
void abort() const override
void mp_collective_op(const int *x, int *resu, const Collective_Op *op, int n) const override
void all_to_all(const void *src_buffer, void *dest_buffer, int data_size) const override
void mp_collective_op(const float *x, float *resu, const Collective_Op *op, int n) const override
void mp_collective_op(const float *x, float *resu, int n, Collective_Op op) const override
void init_group(const ArrOfInt &pe_list) override
constructeur pour un sous-groupe //
int reverse_send_recv_list(const ArrOfInt &src_list, ArrOfInt &dest_list) const
Comm_Group_Noparallel()
constructeur pour le groupe Tous
void send_recv_start(const ArrOfInt &send_list, const ArrOfInt &send_size, const char *const *const send_buffers, const ArrOfInt &recv_list, const ArrOfInt &recv_size, char *const *const recv_buffers, TypeHint typehint=CHAR) const override
void broadcast(void *buffer, int size, int pe_source) const override
void gather(const void *src_buffer, void *dest_buffer, int data_size, int root) const override
void all_gatherv(const void *src_buffer, void *dest_buffer, int send_size, const int *recv_size, const int *displs) const override
void mp_collective_op(const double *x, double *resu, const Collective_Op *op, int n) const override
void send(int pe, const void *buffer, int size, int tag) const override
@ COLL_PARTIAL_SUM
Definition Comm_Group.h:52
static void barrier()
Synchronise tous les processeurs du groupe courant (attend que tous les processeurs soient arrives a ...
Definition Process.cpp:136