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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/histo/hd2mpi (Version 11.3.0) and /externals/g4tools/include/tools/histo/hd2mpi (Version 11.1.1)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_histo_hd2mpi                          4 #ifndef tools_histo_hd2mpi
  5 #define tools_histo_hd2mpi                          5 #define tools_histo_hd2mpi
  6                                                     6 
  7 // code to MPI_Pack, MPI_Unpack histos without      7 // code to MPI_Pack, MPI_Unpack histos without having to include mpi.h.
  8                                                     8 
  9 #include "../impi"                                  9 #include "../impi"
 10                                                    10 
 11 #include "histo_data"                              11 #include "histo_data"
 12                                                    12 
 13 #include "../forit"                                13 #include "../forit"
 14                                                    14 
 15 namespace tools {                                  15 namespace tools {
 16 namespace histo {                                  16 namespace histo {
 17                                                    17 
 18 //////////////////////////////////////////////     18 /////////////////////////////////////////////////////////////////////////////
 19 /// hist_data to mpi /////////////////////////     19 /// hist_data to mpi ////////////////////////////////////////////////////////
 20 //////////////////////////////////////////////     20 /////////////////////////////////////////////////////////////////////////////
 21                                                    21 
 22 inline bool axis_dui_pack(impi& a_mpi,const ax     22 inline bool axis_dui_pack(impi& a_mpi,const axis<double,unsigned int>& a_axis) {
 23   //typedef double TC;                             23   //typedef double TC;
 24   //typedef unsigned int TO;                       24   //typedef unsigned int TO;
 25   //typedef unsigned int bn_t;                     25   //typedef unsigned int bn_t;
 26   if(!a_mpi.pack(a_axis.m_offset)) return fals     26   if(!a_mpi.pack(a_axis.m_offset)) return false; //TO
 27   if(!a_mpi.pack(a_axis.m_number_of_bins)) ret     27   if(!a_mpi.pack(a_axis.m_number_of_bins)) return false; //bn_t
 28   if(!a_mpi.pack(a_axis.m_minimum_value)) retu     28   if(!a_mpi.pack(a_axis.m_minimum_value)) return false; //TC
 29   if(!a_mpi.pack(a_axis.m_maximum_value)) retu     29   if(!a_mpi.pack(a_axis.m_maximum_value)) return false; //TC
 30   if(!a_mpi.bpack(a_axis.m_fixed)) return fals     30   if(!a_mpi.bpack(a_axis.m_fixed)) return false;
 31   if(!a_mpi.pack(a_axis.m_bin_width)) return f     31   if(!a_mpi.pack(a_axis.m_bin_width)) return false; //TC
 32   if(!a_mpi.vpack(a_axis.m_edges)) return fals     32   if(!a_mpi.vpack(a_axis.m_edges)) return false; //TC
 33   return true;                                     33   return true;
 34 }                                                  34 }
 35                                                    35 
 36 inline bool histo_data_duiuid_pack(impi& a_mpi     36 inline bool histo_data_duiuid_pack(impi& a_mpi,const histo_data<double,unsigned int,unsigned int,double>& a_hd) {
 37   //typedef double TC;                             37   //typedef double TC;
 38   //typedef unsigned int TO;                       38   //typedef unsigned int TO;
 39   //typedef unsigned int TN;                       39   //typedef unsigned int TN;
 40   //typedef double TW;                             40   //typedef double TW;
 41   //typedef unsigned int dim_t;                    41   //typedef unsigned int dim_t;
 42   typedef unsigned int num_t;                      42   typedef unsigned int num_t;
 43                                                    43 
 44   if(!a_mpi.spack(a_hd.m_title)) return false;     44   if(!a_mpi.spack(a_hd.m_title)) return false;
 45   if(!a_mpi.pack(a_hd.m_dimension)) return fal     45   if(!a_mpi.pack(a_hd.m_dimension)) return false; //dim_t
 46   if(!a_mpi.pack(a_hd.m_bin_number)) return fa     46   if(!a_mpi.pack(a_hd.m_bin_number)) return false; //TO
 47   if(!a_mpi.vpack(a_hd.m_bin_entries)) return      47   if(!a_mpi.vpack(a_hd.m_bin_entries)) return false; //TN
 48   if(!a_mpi.vpack(a_hd.m_bin_Sw)) return false     48   if(!a_mpi.vpack(a_hd.m_bin_Sw)) return false;  //TW
 49   if(!a_mpi.vpack(a_hd.m_bin_Sw2)) return fals     49   if(!a_mpi.vpack(a_hd.m_bin_Sw2)) return false; //TW
 50                                                    50 
 51  {for(unsigned int ibin=0;ibin<a_hd.m_bin_numb     51  {for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
 52     if(!a_mpi.vpack(a_hd.m_bin_Sxw[ibin])) ret     52     if(!a_mpi.vpack(a_hd.m_bin_Sxw[ibin])) return false;
 53   }}                                               53   }}
 54  {for(unsigned int ibin=0;ibin<a_hd.m_bin_numb     54  {for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
 55     if(!a_mpi.vpack(a_hd.m_bin_Sx2w[ibin])) re     55     if(!a_mpi.vpack(a_hd.m_bin_Sx2w[ibin])) return false;
 56   }}                                               56   }}
 57                                                    57 
 58   // Axes :                                        58   // Axes :
 59  {for(unsigned int iaxis=0;iaxis<a_hd.m_dimens     59  {for(unsigned int iaxis=0;iaxis<a_hd.m_dimension;iaxis++) {
 60     if(!axis_dui_pack(a_mpi,a_hd.m_axes[iaxis]     60     if(!axis_dui_pack(a_mpi,a_hd.m_axes[iaxis])) return false;
 61   }}                                               61   }}
 62                                                    62 
 63   // etc :                                         63   // etc :
 64   if(!a_mpi.vpack(a_hd.m_in_range_plane_Sxyw))     64   if(!a_mpi.vpack(a_hd.m_in_range_plane_Sxyw)) return false; //TC
 65                                                    65 
 66   // Annotations :                                 66   // Annotations :
 67  {if(!a_mpi.pack((num_t)a_hd.m_annotations.siz     67  {if(!a_mpi.pack((num_t)a_hd.m_annotations.size())) return false; //num_t
 68   tools_mforcit(std::string,std::string,a_hd.m     68   tools_mforcit(std::string,std::string,a_hd.m_annotations,it) {
 69     if(!a_mpi.spack((*it).first)) return false     69     if(!a_mpi.spack((*it).first)) return false;
 70     if(!a_mpi.spack((*it).second)) return fals     70     if(!a_mpi.spack((*it).second)) return false;
 71   }}                                               71   }}
 72                                                    72 
 73   // fast getters :                                73   // fast getters :
 74   if(!a_mpi.pack(a_hd.m_all_entries)) return f     74   if(!a_mpi.pack(a_hd.m_all_entries)) return false; //TN
 75   if(!a_mpi.pack(a_hd.m_in_range_entries)) ret     75   if(!a_mpi.pack(a_hd.m_in_range_entries)) return false; //TN
 76   if(!a_mpi.pack(a_hd.m_in_range_Sw)) return f     76   if(!a_mpi.pack(a_hd.m_in_range_Sw)) return false; //TW
 77   if(!a_mpi.pack(a_hd.m_in_range_Sw2)) return      77   if(!a_mpi.pack(a_hd.m_in_range_Sw2)) return false; //TW
 78   if(!a_mpi.vpack(a_hd.m_in_range_Sxw)) return     78   if(!a_mpi.vpack(a_hd.m_in_range_Sxw)) return false; //TC
 79   if(!a_mpi.vpack(a_hd.m_in_range_Sx2w)) retur     79   if(!a_mpi.vpack(a_hd.m_in_range_Sx2w)) return false; //TC
 80                                                    80 
 81   return true;                                     81   return true;
 82 }                                                  82 }
 83                                                    83 
 84 //////////////////////////////////////////////     84 /////////////////////////////////////////////////////////////////////////////
 85 /// mpi to hist_data /////////////////////////     85 /// mpi to hist_data ////////////////////////////////////////////////////////
 86 //////////////////////////////////////////////     86 /////////////////////////////////////////////////////////////////////////////
 87                                                    87 
 88 inline bool axis_dui_unpack(impi& a_mpi,axis<d     88 inline bool axis_dui_unpack(impi& a_mpi,axis<double,unsigned int>& a_axis) {
 89   //typedef double TC;                             89   //typedef double TC;
 90   //typedef unsigned int TO;                       90   //typedef unsigned int TO;
 91   //typedef unsigned int bn_t;                     91   //typedef unsigned int bn_t;
 92                                                    92 
 93   if(!a_mpi.unpack(a_axis.m_offset)) return fa     93   if(!a_mpi.unpack(a_axis.m_offset)) return false; //TO
 94   if(!a_mpi.unpack(a_axis.m_number_of_bins)) r     94   if(!a_mpi.unpack(a_axis.m_number_of_bins)) return false; //bn_t
 95   if(!a_mpi.unpack(a_axis.m_minimum_value)) re     95   if(!a_mpi.unpack(a_axis.m_minimum_value)) return false; //TC
 96   if(!a_mpi.unpack(a_axis.m_maximum_value)) re     96   if(!a_mpi.unpack(a_axis.m_maximum_value)) return false; //TC
 97   if(!a_mpi.bunpack(a_axis.m_fixed)) return fa     97   if(!a_mpi.bunpack(a_axis.m_fixed)) return false;
 98   if(!a_mpi.unpack(a_axis.m_bin_width)) return     98   if(!a_mpi.unpack(a_axis.m_bin_width)) return false; //TC
 99   if(!a_mpi.vunpack(a_axis.m_edges)) return fa     99   if(!a_mpi.vunpack(a_axis.m_edges)) return false; //TC
100                                                   100 
101   return true;                                    101   return true;
102 }                                                 102 }
103                                                   103 
104 inline bool histo_data_duiuid_unpack(impi& a_m    104 inline bool histo_data_duiuid_unpack(impi& a_mpi,histo_data<double,unsigned int,unsigned int,double>& a_hd) {
105   //typedef double TC;                            105   //typedef double TC;
106   //typedef unsigned int TO;                      106   //typedef unsigned int TO;
107   //typedef unsigned int TN;                      107   //typedef unsigned int TN;
108   //typedef double TW;                            108   //typedef double TW;
109   //typedef unsigned int dim_t;                   109   //typedef unsigned int dim_t;
110   typedef unsigned int num_t;                     110   typedef unsigned int num_t;
111                                                   111 
112   if(!a_mpi.sunpack(a_hd.m_title)) return fals    112   if(!a_mpi.sunpack(a_hd.m_title)) return false;
113   if(!a_mpi.unpack(a_hd.m_dimension)) return f    113   if(!a_mpi.unpack(a_hd.m_dimension)) return false; //dim_t
114   if(!a_mpi.unpack(a_hd.m_bin_number)) return     114   if(!a_mpi.unpack(a_hd.m_bin_number)) return false; //TO
115   if(!a_mpi.vunpack(a_hd.m_bin_entries)) retur    115   if(!a_mpi.vunpack(a_hd.m_bin_entries)) return false; //TN
116   if(!a_mpi.vunpack(a_hd.m_bin_Sw)) return fal    116   if(!a_mpi.vunpack(a_hd.m_bin_Sw)) return false; //TW
117   if(!a_mpi.vunpack(a_hd.m_bin_Sw2)) return fa    117   if(!a_mpi.vunpack(a_hd.m_bin_Sw2)) return false; //TW
118                                                   118 
119  {a_hd.m_bin_Sxw.resize(a_hd.m_bin_number);       119  {a_hd.m_bin_Sxw.resize(a_hd.m_bin_number);
120   for(unsigned int ibin=0;ibin<a_hd.m_bin_numb    120   for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
121     if(!a_mpi.vunpack(a_hd.m_bin_Sxw[ibin])) r    121     if(!a_mpi.vunpack(a_hd.m_bin_Sxw[ibin])) return false;
122   }}                                              122   }}
123  {a_hd.m_bin_Sx2w.resize(a_hd.m_bin_number);      123  {a_hd.m_bin_Sx2w.resize(a_hd.m_bin_number);
124   for(unsigned int ibin=0;ibin<a_hd.m_bin_numb    124   for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
125     if(!a_mpi.vunpack(a_hd.m_bin_Sx2w[ibin]))     125     if(!a_mpi.vunpack(a_hd.m_bin_Sx2w[ibin])) return false;
126   }}                                              126   }}
127                                                   127 
128   // Axes :                                       128   // Axes :
129  {a_hd.m_axes.resize(a_hd.m_dimension);           129  {a_hd.m_axes.resize(a_hd.m_dimension);
130   for(unsigned int iaxis=0;iaxis<a_hd.m_dimens    130   for(unsigned int iaxis=0;iaxis<a_hd.m_dimension;iaxis++) {
131     if(!axis_dui_unpack(a_mpi,a_hd.m_axes[iaxi    131     if(!axis_dui_unpack(a_mpi,a_hd.m_axes[iaxis])) return false;
132   }}                                              132   }}
133                                                   133 
134   // etc :                                        134   // etc :
135   if(!a_mpi.vunpack(a_hd.m_in_range_plane_Sxyw    135   if(!a_mpi.vunpack(a_hd.m_in_range_plane_Sxyw)) return false; //TC
136                                                   136 
137   // Annotations :                                137   // Annotations :
138  {a_hd.m_annotations.clear();                     138  {a_hd.m_annotations.clear();
139   num_t num;                                      139   num_t num;
140   if(!a_mpi.unpack(num)) return false;            140   if(!a_mpi.unpack(num)) return false;
141   for(unsigned int index=0;index<num;index++)     141   for(unsigned int index=0;index<num;index++) {
142     std::string k,v;                              142     std::string k,v;
143     if(!a_mpi.sunpack(k)) return false;           143     if(!a_mpi.sunpack(k)) return false;
144     if(!a_mpi.sunpack(v)) return false;           144     if(!a_mpi.sunpack(v)) return false;
145     a_hd.m_annotations[k] = v;                    145     a_hd.m_annotations[k] = v;
146   }}                                              146   }}
147                                                   147 
148   // fast getters :                               148   // fast getters :
149   if(!a_mpi.unpack(a_hd.m_all_entries)) return    149   if(!a_mpi.unpack(a_hd.m_all_entries)) return false; //TN
150   if(!a_mpi.unpack(a_hd.m_in_range_entries)) r    150   if(!a_mpi.unpack(a_hd.m_in_range_entries)) return false; //TN
151   if(!a_mpi.unpack(a_hd.m_in_range_Sw)) return    151   if(!a_mpi.unpack(a_hd.m_in_range_Sw)) return false; //TW
152   if(!a_mpi.unpack(a_hd.m_in_range_Sw2)) retur    152   if(!a_mpi.unpack(a_hd.m_in_range_Sw2)) return false; //TW
153   if(!a_mpi.vunpack(a_hd.m_in_range_Sxw)) retu    153   if(!a_mpi.vunpack(a_hd.m_in_range_Sxw)) return false; //TC
154   if(!a_mpi.vunpack(a_hd.m_in_range_Sx2w)) ret    154   if(!a_mpi.vunpack(a_hd.m_in_range_Sx2w)) return false; //TC
155                                                   155 
156   return true;                                    156   return true;
157 }                                                 157 }
158                                                   158 
159 }}                                                159 }}
160                                                   160 
161 #include "profile_data"                           161 #include "profile_data"
162                                                   162 
163 namespace tools {                                 163 namespace tools {
164 namespace histo {                                 164 namespace histo {
165                                                   165 
166 //////////////////////////////////////////////    166 /////////////////////////////////////////////////////////////////////////////
167 /// profile_data to C struct /////////////////    167 /// profile_data to C struct ////////////////////////////////////////////////
168 //////////////////////////////////////////////    168 /////////////////////////////////////////////////////////////////////////////
169                                                   169 
170 inline bool profile_data_duiuidd_pack(impi& a_    170 inline bool profile_data_duiuidd_pack(impi& a_mpi,const profile_data<double,unsigned int,unsigned int,double,double>& a_pd) {
171                                                   171 
172   if(!histo_data_duiuid_pack(a_mpi,a_pd)) retu    172   if(!histo_data_duiuid_pack(a_mpi,a_pd)) return false;
173                                                   173 
174   //typedef double TV;                            174   //typedef double TV;
175                                                   175 
176   if(!a_mpi.bpack(a_pd.m_is_profile)) return f    176   if(!a_mpi.bpack(a_pd.m_is_profile)) return false;
177   if(!a_mpi.vpack(a_pd.m_bin_Svw)) return fals    177   if(!a_mpi.vpack(a_pd.m_bin_Svw)) return false; //TV
178   if(!a_mpi.vpack(a_pd.m_bin_Sv2w)) return fal    178   if(!a_mpi.vpack(a_pd.m_bin_Sv2w)) return false; //TV
179   if(!a_mpi.bpack(a_pd.m_cut_v)) return false;    179   if(!a_mpi.bpack(a_pd.m_cut_v)) return false;
180   if(!a_mpi.pack(a_pd.m_min_v)) return false;     180   if(!a_mpi.pack(a_pd.m_min_v)) return false; //TV
181   if(!a_mpi.pack(a_pd.m_max_v)) return false;     181   if(!a_mpi.pack(a_pd.m_max_v)) return false; //TV
182                                                   182 
183   return true;                                    183   return true;
184 }                                                 184 }
185                                                   185 
186 //////////////////////////////////////////////    186 /////////////////////////////////////////////////////////////////////////////
187 /// mpi to profile_data //////////////////////    187 /// mpi to profile_data /////////////////////////////////////////////////////
188 //////////////////////////////////////////////    188 /////////////////////////////////////////////////////////////////////////////
189                                                   189 
190 inline bool profile_data_duiuidd_unpack(impi&     190 inline bool profile_data_duiuidd_unpack(impi& a_mpi,profile_data<double,unsigned int,unsigned int,double,double>& a_pd) {
191                                                   191 
192   if(!histo_data_duiuid_unpack(a_mpi,a_pd)) re    192   if(!histo_data_duiuid_unpack(a_mpi,a_pd)) return false;
193                                                   193 
194   //typedef double TV;                            194   //typedef double TV;
195                                                   195 
196   if(!a_mpi.bunpack(a_pd.m_is_profile)) return    196   if(!a_mpi.bunpack(a_pd.m_is_profile)) return false;
197   if(!a_mpi.vunpack(a_pd.m_bin_Svw)) return fa    197   if(!a_mpi.vunpack(a_pd.m_bin_Svw)) return false; //TV
198   if(!a_mpi.vunpack(a_pd.m_bin_Sv2w)) return f    198   if(!a_mpi.vunpack(a_pd.m_bin_Sv2w)) return false; //TV
199   if(!a_mpi.bunpack(a_pd.m_cut_v)) return fals    199   if(!a_mpi.bunpack(a_pd.m_cut_v)) return false;
200   if(!a_mpi.unpack(a_pd.m_min_v)) return false    200   if(!a_mpi.unpack(a_pd.m_min_v)) return false; //TV
201   if(!a_mpi.unpack(a_pd.m_max_v)) return false    201   if(!a_mpi.unpack(a_pd.m_max_v)) return false; //TV
202                                                   202 
203   return true;                                    203   return true;
204 }                                                 204 }
205                                                   205 
206 }}                                                206 }}
207                                                   207 
208 #endif                                            208 #endif