SkelGIS
3.0
|
00001 /*! \file apply_list.hpp 00002 * \brief Definitions of the skeleton object ApplyList. This skeleton takes a list of DMatrix and a user function as inputs and returns a list of DMatrix as output. 00003 */ 00004 #ifndef APPLYLIST_H 00005 #define APPLYLIST_H 00006 00007 #include "../../../util/dmatrix_vector.hpp" 00008 00009 namespace skelgis{ 00010 00011 //================================================================================ 00012 //Types of user functions 00013 //================================================================================ 00014 //! _ApplyList_Func structure 00015 /*! 00016 These objects are not directly used by the user, but the macros used by the user, to define its functions, uses these. Four specializations of this structure are available. 00017 \tparam T is the type of data to store in the input list of DMatrix 00018 \tparam R is the overlap distance needed by the calculation for input DMatrix. 00019 \tparam T2 is the type of data to store in the output list of DMatrix 00020 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00021 \tparam line is the parallel distribution wanted, the default value is true, then the parallel distribution will be divided along height but not along width 00022 */ 00023 //------------------------------------------------------------------------------- 00024 template <typename T,int R, typename T2, int R2,bool line=true> struct _ApplyList_Func 00025 //------------------------------------------------------------------------------- 00026 { 00027 virtual void operator()(DMatrix_vector<T,R>&,DMatrix_vector<T2,R2>&) const =0; 00028 }; 00029 //================================================================================ 00030 //! _ApplyList_Func structure 00031 /*! 00032 \tparam T is the type of data to store in the input list of DMatrix 00033 R overlap template parameter is not asked and specialized to 0 00034 \tparam T2 is the type of data to store in the output list of DMatrix 00035 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00036 The default value of line is used (true). 00037 */ 00038 //------------------------------------------------------------------------------- 00039 template <typename T, typename T2, int R2> struct _ApplyList_Func<T,0,T2,R2> 00040 //------------------------------------------------------------------------------- 00041 { 00042 virtual void operator()(DMatrix_vector<T,0>&, DMatrix_vector<T2,R2>&) const =0; 00043 }; 00044 //================================================================================ 00045 //! _ApplyList_Func structure 00046 /*! 00047 \tparam T is the type of data to store in the input list of DMatrix 00048 \tparam R is the overlap distance needed by the calculation for input DMatrix. 00049 \tparam T2 is the type of data to store in the output list of DMatrix 00050 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00051 The line template parameter is specialized with the false value. In this case the parallel data distribution will be done along height and width (by block) 00052 */ 00053 //------------------------------------------------------------------------------- 00054 template <typename T,int R, typename T2,int R2> struct _ApplyList_Func<T,R,T2,R2,false> 00055 //------------------------------------------------------------------------------- 00056 { 00057 virtual void operator()(DMatrix_vector<T,R,false>&,DMatrix_vector<T2,R2,false>&) const =0; 00058 }; 00059 //================================================================================ 00060 //! _ApplyList_Func structure 00061 /*! 00062 \tparam T is the type of data to store in the input list of DMatrix 00063 R overlap template parameter is not asked and specialized to 0 00064 \tparam T2 is the type of data to store in the output list of DMatrix 00065 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00066 The line template parameter is specialized with the false value. In this case the parallel data distribution will be done along height and width (by block). 00067 */ 00068 //------------------------------------------------------------------------------- 00069 template <typename T, typename T2,int R2> struct _ApplyList_Func<T,0,T2,R2,false> 00070 //------------------------------------------------------------------------------- 00071 { 00072 virtual void operator()(DMatrix_vector<T,0,false>&, DMatrix_vector<T2,R2,false>&) const =0; 00073 }; 00074 //------------------------------------------------------------------------------- 00075 00076 //================================================================================ 00077 //Specializations of skeleton ApplyList 00078 //================================================================================ 00079 //! ApplyList structure 00080 /*! 00081 These objects are directly called by the user to apply a function on a list of Dmatrix. 00082 \tparam T is the type of data to store in input list of Dmatrix 00083 \tparam R is the overlap distance needed by the calculation 00084 \tparam T2 is the type of data to store in output DMatrix 00085 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00086 \tparam line is the parallel distribution wanted, the default value is true, then the parallel distribution will be divided along height but not along width 00087 \tparam local is a particular choice if it is explicitely indicate to not make any MPI exchanges. The default behavior is to make normaly MPI exchanges. 00088 */ 00089 //------------------------------------------------------------------------------- 00090 template<class T,int R,class T2, int R2,bool line=true,bool local=false> struct ApplyList{}; 00091 //------------------------------------------------------------------------------- 00092 00093 //================================================================================ 00094 //! ApplyList structure 00095 /*! 00096 First specialization with line and local default values. 00097 \tparam T is the type of data to store in input list of Dmatrix 00098 \tparam R is the overlap distance needed by the calculation 00099 \tparam T2 is the type of data to store in output DMatrix 00100 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00101 */ 00102 //------------------------------------------------------------------------------- 00103 template<class T,int R,class T2,int R2> struct ApplyList<T,R,T2,R2> 00104 //------------------------------------------------------------------------------- 00105 { 00106 static void apply(const _ApplyList_Func<T,R,T2,R2>& func,DMatrix_vector<T,R>& inputs, DMatrix_vector<T2,R2>& outputs) 00107 { 00108 for(int i=0;i<inputs.size();i++) 00109 { 00110 DMatrix_impl<T,R> * m = inputs[i]; 00111 m->getBorders(); 00112 } 00113 func(inputs,outputs); 00114 } 00115 }; 00116 //------------------------------------------------------------------------------- 00117 00118 //================================================================================ 00119 //! ApplyList structure 00120 /*! 00121 Second specialization with line and local default values and R=0 00122 \tparam T is the type of data to store in input list of Dmatrix 00123 R overlap template parameter is not asked and specialized to 0 00124 \tparam T2 is the type of data to store in output DMatrix 00125 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00126 */ 00127 //------------------------------------------------------------------------------- 00128 template<class T,class T2,int R2> struct ApplyList<T,0,T2,R2> 00129 //------------------------------------------------------------------------------- 00130 { 00131 inline static void apply(const _ApplyList_Func<T,0,T2,R2>& func,DMatrix_vector<T,0>& inputs, DMatrix_vector<T2,R2>& outputs){func(inputs,outputs);} 00132 }; 00133 //------------------------------------------------------------------------------- 00134 00135 //================================================================================ 00136 //! ApplyList structure 00137 /*! 00138 Third specialization with with line=true and local=true 00139 \tparam T is the type of data to store in input list of Dmatrix 00140 \tparam R is the overlap distance needed by the calculation 00141 \tparam T2 is the type of data to store in output DMatrix 00142 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00143 */ 00144 //------------------------------------------------------------------------------- 00145 template<class T,int R,class T2,int R2> struct ApplyList<T,R,T2,R2,true,true> 00146 //------------------------------------------------------------------------------- 00147 { 00148 inline static void apply(const _ApplyList_Func<T,R,T2,R2>& func, DMatrix_vector<T,R>& inputs, DMatrix_vector<T2,R2>& outputs){func(inputs,outputs);} 00149 }; 00150 //------------------------------------------------------------------------------- 00151 00152 //================================================================================ 00153 //! ApplyList structure 00154 /*! 00155 Fourth specialization with line=true and local=true and R=0 00156 \tparam T is the type of data to store in input list of Dmatrix 00157 R overlap template parameter is not asked and specialized to 0 00158 \tparam T2 is the type of data to store in output DMatrix 00159 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00160 */ 00161 //------------------------------------------------------------------------------- 00162 template<class T,class T2,int R2> struct ApplyList<T,0,T2,R2,true,true> 00163 //------------------------------------------------------------------------------- 00164 { 00165 inline static void apply(const _ApplyList_Func<T,0,T2,R2>& func, DMatrix_vector<T,0>& inputs, DMatrix_vector<T2,R2>& outputs){func(inputs,outputs);} 00166 }; 00167 //------------------------------------------------------------------------------- 00168 00169 //================================================================================ 00170 //! ApplyList structure 00171 /*! 00172 Fith specialization with line=false and local=false default value 00173 \tparam T is the type of data to store in input list of Dmatrix 00174 \tparam R is the overlap distance needed by the calculation 00175 \tparam T2 is the type of data to store in output DMatrix 00176 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00177 */ 00178 //------------------------------------------------------------------------------- 00179 template<class T,int R,class T2,int R2> struct ApplyList<T,R,T2,R2,false> 00180 //------------------------------------------------------------------------------- 00181 { 00182 static void apply(const _ApplyList_Func<T,R,T2,R2,false>& func,DMatrix_vector<T,R,false>& inputs, DMatrix_vector<T2,R2,false>& outputs) 00183 { 00184 for(int i=0;i<inputs.size();i++) 00185 { 00186 DMatrix_impl<T,R,false> * m = inputs[i]; 00187 m->getBorders(); 00188 } 00189 func(inputs,outputs); 00190 } 00191 }; 00192 //------------------------------------------------------------------------------- 00193 00194 //================================================================================ 00195 //! ApplyList structure 00196 /*! 00197 Sixth specialization with line=false and local=false default value and R=0 00198 \tparam T is the type of data to store in input list of Dmatrix 00199 R overlap template parameter is not asked and specialized to 0 00200 \tparam T2 is the type of data to store in output DMatrix 00201 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00202 */ 00203 //------------------------------------------------------------------------------- 00204 template<class T,class T2,int R2> struct ApplyList<T,0,T2,R2,false> 00205 //------------------------------------------------------------------------------- 00206 { 00207 inline static void apply(const _ApplyList_Func<T,0,T2,R2,false>& func,DMatrix_vector<T,0,false>& inputs, DMatrix_vector<T2,R2,false>& outputs){func(inputs,outputs);} 00208 }; 00209 //------------------------------------------------------------------------------- 00210 00211 //================================================================================ 00212 //! ApplyList structure 00213 /*! 00214 Seventh specialization with line=false and local=true 00215 \tparam T is the type of data to store in input list of Dmatrix 00216 \tparam R is the overlap distance needed by the calculation 00217 \tparam T2 is the type of data to store in output DMatrix 00218 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00219 */ 00220 //------------------------------------------------------------------------------- 00221 template<class T,int R,class T2,int R2> struct ApplyList<T,R,T2,R2,false,true> 00222 //------------------------------------------------------------------------------- 00223 { 00224 inline static void apply(const _ApplyList_Func<T,R,T2,R2,false>& func, DMatrix_vector<T,R,false>& inputs, DMatrix_vector<T2,R2,false>& outputs){func(inputs,outputs);} 00225 }; 00226 //------------------------------------------------------------------------------- 00227 00228 //================================================================================ 00229 //! ApplyList structure 00230 /*! 00231 Eighth specialization with line=false and local=true and R=0 00232 \tparam T is the type of data to store in input list of Dmatrix 00233 R overlap template parameter is not asked and specialized to 0 00234 \tparam T2 is the type of data to store in output DMatrix 00235 \tparam R2 is the overlap distance needed by the calculation for output DMatrix. 00236 */ 00237 //------------------------------------------------------------------------------- 00238 template<class T,class T2,int R2> struct ApplyList<T,0,T2,R2,false,true> 00239 //------------------------------------------------------------------------------- 00240 { 00241 inline static void apply(const _ApplyList_Func<T,0,T2,R2,false>& func, DMatrix_vector<T,0,false>& inputs, DMatrix_vector<T2,R2,false>& outputs){func(inputs,outputs);} 00242 }; 00243 //------------------------------------------------------------------------------- 00244 00245 } 00246 00247 #endif