SkelGIS
3.0
|
00001 /*! \file macros.hpp 00002 * \brief macros of SKelGIS library 00003 */ 00004 #ifndef MACROS_H 00005 #define MACROS_H 00006 00007 #include "mpi.h" 00008 #include "dmatrix_vector.hpp" 00009 00010 namespace skelgis{ 00011 00012 //------------MPI FUNCS 00013 //! MPI_RANK_NB macro 00014 /*! 00015 Used to initialize the number of mpi processes and the rank of the current process 00016 */ 00017 #define MPI_RANK_NB MPI_Comm_size(MPI_COMM_WORLD,&(Mpi_::mpi_nb)); \ 00018 MPI_Comm_rank(MPI_COMM_WORLD,&(Mpi_::mpi_rank)); 00019 //! MPI_END macro 00020 /*! 00021 Used to end MPI 00022 */ 00023 #define MPI_END MPI_Finalize(); 00024 //------------ 00025 //------------SKELGIS INIT 00026 //! INITSKELGIS 00027 /*! 00028 Used to initialize SkelGIS library use. Mpi initializations. 00029 */ 00030 #define INITSKELGIS MPI_Init(&argc,&argv); \ 00031 MPI_RANK_NB 00032 //! ENDSKELGIS 00033 /*! 00034 Used to end SkelGIS library use. 00035 */ 00036 //-----------SKELGIS END 00037 #define ENDSKELGIS MPI_END 00038 //---------- 00039 00040 //----------PARAMETERS CLASS 00041 #define BEGINParam(name) struct name{ \ 00042 private : \ 00043 name(){} \ 00044 ~name(){} \ 00045 static name * singleton; \ 00046 public: \ 00047 static name * getInstance() \ 00048 { \ 00049 if(NULL==singleton) \ 00050 singleton = new name(); \ 00051 return singleton; \ 00052 } 00053 00054 #define ENDParam(name) }; \ 00055 name *name::singleton = NULL; 00056 //---------- 00057 //----------GET PARAMETER 00058 #define PARAM(class_name,param_name) class_name::getInstance()->param_name 00059 //---------- 00060 00061 //========================================== 00062 //============DMATRIX SKELETONS============= 00063 //========================================== 00064 //-----------SKELETON APPLYONE FUNCTION 00065 //! BEGINApplyUnary 00066 /*! 00067 Used to code the user function for the skeleton ApplyUnary 00068 */ 00069 #define BEGINApplyUnary(name, input_matrix, input_type, r, output_matrix, output_type, r2) struct _ApplyUnary_##name : public _ApplyUnary_Func<input_type, r, output_type,r2> \ 00070 { \ 00071 void operator()(DMatrix<input_type,r>& input_matrix, DMatrix<output_type,r2>& output_matrix) const 00072 00073 //-----------SKELETON APPLYONE FUNCTION - BLOCK DIVISION 00074 //! BEGINApplyUnaryBlock 00075 /*! 00076 Used to code the user function for the skeleton ApplyUnary in the case of a block distribution 00077 */ 00078 #define BEGINApplyUnaryBlock(name, input_matrix, input_type, r, output_matrix, output_type, r2) struct _ApplyUnary_##name : public _ApplyUnary_Func<input_type,r, output_type,r2,false> \ 00079 { \ 00080 void operator()(DMatrix<input_type,r,false>& input_matrix, DMatrix<output_type,r2,false>& output_matrix) const 00081 00082 //-----------SKELETON APPLYTWO FUNCTION 00083 //! BEGINApplyBinary 00084 /*! 00085 Used to code the user function for the skeleton ApplyBinary 00086 */ 00087 #define BEGINApplyBinary(name, input_matrix1, input_type1, input_matrix2, input_type2,r, output_matrix, output_type,r3) struct _ApplyBinary_##name : public _ApplyBinary_Func<input_type1,r,input_type2,output_type,r3> \ 00088 { \ 00089 void operator()(DMatrix<input_type1,r>& input_matrix1,DMatrix<input_type2,r>& input_matrix2, DMatrix<output_type,r3>& output_matrix) const 00090 00091 //-----------SKELETON APPLYTWO FUNCTION - BLOCK DIVISION 00092 //! BEGINApplyBinaryBlock 00093 /*! 00094 Used to code the user function for the skeleton ApplyBinary in the case of a block distribution 00095 */ 00096 #define BEGINApplyBinaryBlock(name, input_matrix1, input_type1, input_matrix2, input_type2,r, output_matrix, output_type,r3) struct _ApplyBinary_##name : public _ApplyBinary_Func<input_type1,r,input_type2,output_type,r3,false> \ 00097 { \ 00098 void operator()(DMatrix<input_type1,r,false>& input_matrix1,DMatrix<input_type2,r,false>& input_matrix2, DMatrix<output_type,r3,false>& output_matrix) const 00099 00100 //-----------SKELETON APPLYLIST FUNCTION 00101 //! BEGINApplyList 00102 /*! 00103 Used to code the user function for the skeleton ApplyList 00104 */ 00105 #define BEGINApplyList(name, inputs, inputs_type,r, outputs, outputs_type,r2) struct _ApplyList_##name : public _ApplyList_Func<inputs_type,r,outputs_type,r2> \ 00106 { \ 00107 void operator()(DMatrix_vector<inputs_type,r>& inputs, DMatrix_vector<outputs_type,r2>& outputs) const 00108 00109 //-----------SKELETON APPLYLIST FUNCTION - BLOCK DIVISION 00110 //! BEGINApplyListBlock 00111 /*! 00112 Used to code the user function for the skeleton ApplyList in the case of a block distribution 00113 */ 00114 #define BEGINApplyListBlock(name, inputs, inputs_type,r, outputs, outputs_type,r2) struct _ApplyList_##name : public _ApplyList_Func<inputs_type,r, outputs_type,r2,false> \ 00115 { \ 00116 void operator()(DMatrix_vector<inputs_type,r,false>& inputs, DMatrix_vector<outputs_type,r2,false>& outputs) const 00117 00118 //-----------SKELETON APPLYREDUCTION FUNCTION 00119 //! BEGINApplyReduction 00120 /*! 00121 Used to code the user function for the skeleton ApplyReduction 00122 */ 00123 #define BEGINApplyReduction(name, input_matrix, type, r,output) struct _ApplyReduction_##name : public _ApplyReduction_Func<type, r> \ 00124 { \ 00125 void operator()(DMatrix<type,r>& input_matrix, type& output) const 00126 00127 //! BEGINApplyReductionBlock 00128 /*! 00129 Used to code the user function for the skeleton ApplyReduction in the case of a block distribution 00130 */ 00131 #define BEGINApplyReductionBlock(name, input_matrix, type, r,output) struct _ApplyReduction_##name : public _ApplyReduction_Func<type, r,false> \ 00132 { \ 00133 void operator()(DMatrix<type,r,false>& input_matrix, type& output) const 00134 00135 //-----------SKELETON MAP FUNCTION 00136 //! BEGINMap 00137 /*! 00138 Used to code the user function for the skeleton Map 00139 */ 00140 #define BEGINMap(name, element, element_type, return_type) struct _Map_##name : public _Map_Func<element_type, return_type> \ 00141 { \ 00142 return_type operator()(element_type element) const 00143 //----------- 00144 00145 //======================================= 00146 //============DDAG SKELETONS============= 00147 //======================================= 00148 //-----------SKELETON APPLY UNARY FUNCTION 00149 //! BEGINApplyUnaryDDAG 00150 /*! 00151 Used to code the user function for the skeleton ApplyUnaryDDAG 00152 */ 00153 #define BEGINApplyUnaryDDAG(name, DPMap_n1, n1, DPMap_e1, e1, DPMap_n2, n2, DPMap_e2, e2) struct _ApplyUnaryDDAG_##name : public _ApplyUnaryDDAG_Func<DPMap_n1, DPMap_e1, DPMap_n2, DPMap_e2> \ 00154 { \ 00155 void operator()(DPMap_n1& n1, DPMap_e1& e1, DPMap_n2& n2, DPMap_e2& e2) const 00156 00157 //-----------SKELETON APPLY UNARY FUNCTION SPECIALIZATION 00158 //! BEGINApplyUnaryDDAG 00159 /*! 00160 Used to code the user function for the skeleton ApplyUnaryDDAG 00161 */ 00162 #define BEGINSApplyUnaryDDAG(name, DPMap_n, n1, n2, DPMap_e, e1, e2) struct _ApplyUnaryDDAG_##name : public _ApplyUnaryDDAG_Func<DPMap_n, DPMap_e, DPMap_n, DPMap_e> \ 00163 { \ 00164 void operator()(DPMap_n& n1, DPMap_e& e1, DPMap_n& n2, DPMap_e& e2) const 00165 00166 //-----------END oF SKELETON FUNCTIONS 00167 //! END 00168 /*! 00169 Used to end any BEGIN macro 00170 */ 00171 #define END(name) }name; 00172 //----------- 00173 00174 00175 } 00176 00177 #endif