TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
MD_Vector_seq.h
1/****************************************************************************
2* Copyright (c) 2024, 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 MD_Vector_seq_included
17#define MD_Vector_seq_included
18
19#include <MD_Vector_mono.h>
20#include <TRUSTArray.h>
21
22/*! @brief Dummy parallel descriptor used for sequential computations.
23 *
24 * Its only useful information is the total number of items hold by the array which can be big (hence the use of trustIdType).
25 *
26 * In this class, all the inherited counters accessors (get_nb_items*() methods, etc.) return this number. We however carefully check
27 * that the number of items fit within 32b since thoses inherited accessors return 'int'. No piece of code is actually using those
28 * methods in the 64b part of the execution (i.e. before Scatter).
29 *
30 * Historically we used a MD_Vector_std for sequential computations too, and this std MD_Vector had a single block covering
31 * the whole array. But having a template version of the MD_Vector_std class (supporting both 32b and 64b) seemed unreasonable,
32 * hence the creation of the current class.
33 *
34 * See arch.h.in for more explanations on 64b.
35 *
36 * In this class, members inherited from MD_Vector_mono are meaningless and their information is not updated.
37 * Algorithm like get_sequential_items_flags() are actually overriden not to use this.
38 */
40{
41 Declare_instanciable_sans_constructeur(MD_Vector_seq);
42
43public:
44
46 MD_Vector_seq(const trustIdType& nb) : MD_Vector_mono(), nb_items_(nb)
47 {
48 // We should never create a MD_Vector_seq when parallel ... but unfortunately we do in Scatter :-(
49 // assert(Process::is_sequential());
50 }
51
52 trustIdType get_nb_items() const { return nb_items_; }
53
54 // A sequential descriptor is never actually used. It is always OK, hence its validation is always true:
55 bool validate(trustIdType sz_array, int line_size) const override { return true; }
56
57 // For all those methods, return nb_items_, but check before it is smaller than 64b!
58 // They should never be called from the 64b part of TRUST.
59 int get_nb_items_reels() const override;
60 int get_nb_items_tot() const override;
61 trustIdType nb_items_seq_tot() const override { return nb_items_; }
62 int nb_items_seq_local() const override;
63
64 // All these should never be called in sequential:
65 void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, DoubleVect&) const override { throw; }
66 void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, DoubleVect&) const override { throw; }
67 void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, DoubleVect&) const override { throw; }
68
69 void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, FloatVect&) const override { throw; }
70 void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, FloatVect&) const override { throw; }
71 void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, FloatVect&) const override { throw; }
72
73 void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, IntVect&) const override { throw; }
74 void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, IntVect&) const override { throw; }
75 void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, IntVect&) const override { throw; }
76
77#if INT_is_64_ == 2
78 void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, TIDVect&) const override { throw; }
79 void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, TIDVect&) const override { throw; }
80 void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, TIDVect&) const override { throw; }
81#endif
82
83 void append_from_other_seq(const MD_Vector_seq& src, int offset, int multiplier) override;
84 void fill_md_vect_renum(const IntVect& renum, MD_Vector& md_vect) const override;
85
86 bool use_blocks() const override { return false; }
87
88protected:
89 int get_seq_flags_impl(ArrOfBit& flags, int line_size) const override;
90
91private:
92 /*! The number of items in the array - all real, no virtuals */
93 trustIdType nb_items_ = -1;
94};
95#endif
friend class MD_Vector
Generic class for all mono-block MD_Vectors (i.e. non compoosite).
int get_seq_flags_impl(ArrOfBit &flags, int line_size) const override
void prepare_send_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const override
void process_recv_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const override
trustIdType nb_items_seq_tot() const override
void initialize_comm(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const override
void prepare_send_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, IntVect &) const override
void fill_md_vect_renum(const IntVect &renum, MD_Vector &md_vect) const override
bool use_blocks() const override
void initialize_comm(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, IntVect &) const override
void process_recv_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, IntVect &) const override
int get_nb_items_tot() const override
void prepare_send_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, FloatVect &) const override
MD_Vector_seq(const trustIdType &nb)
int get_nb_items_reels() const override
bool validate(trustIdType sz_array, int line_size) const override
void append_from_other_seq(const MD_Vector_seq &src, int offset, int multiplier) override
void initialize_comm(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, FloatVect &) const override
trustIdType get_nb_items() const
void process_recv_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, FloatVect &) const override
int nb_items_seq_local() const override