LAMA
/home/brandes/workspace/LAMA/src/lama/openmp/OpenMPELLUtils.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_OPENMP_ELL_UTILS_HPP_
00034 #define LAMA_OPENMP_ELL_UTILS_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // others
00040 #include <lama/LAMATypes.hpp>
00041 #include <lama/LAMAInterface.hpp>
00042 
00043 // assert
00044 #include <lama/exception/LAMAAssert.hpp>
00045 
00046 // logging
00047 #include <logging/logging.hpp>
00048 
00049 namespace lama
00050 {
00051 
00057 class LAMA_DLL_IMPORTEXPORT OpenMPELLUtils
00058 {
00059 public:
00060 
00063     static IndexType countNonEmptyRowsBySizes( const IndexType sizes[], const IndexType numRows );
00064 
00067     static void setNonEmptyRowsBySizes( IndexType rowIndexes[], const IndexType numNonEmptyRows,
00068                                         const IndexType sizes[], const IndexType numRows );
00069 
00072     static inline IndexType ellindex( const IndexType i, const IndexType jj, const IndexType numRows )
00073     {
00074         return jj * numRows + i;
00075     }
00076 
00077     static void check ( const IndexType mNumRows,
00078                         const IndexType mNumValuesPerRow,
00079                         const IndexType mNumColumns,
00080                         const IndexType *ia,
00081                         const IndexType *ja,
00082                         const char* msg );
00083 
00084 
00085 
00088     template<typename ValueType, typename OtherValueType>
00089     static void getRow( OtherValueType *row,
00090                         const IndexType i,
00091                         const IndexType numRows,
00092                         const IndexType numColumns,
00093                         const IndexType *ia,
00094                         const IndexType *ja,
00095                         const ValueType *values );
00096 
00099     template<typename ValueType, typename OtherValueType>
00100     static OtherValueType getValue ( const IndexType i,
00101                                      const IndexType j,
00102                                      const IndexType numRows,
00103                                      const IndexType *ia,
00104                                      const IndexType *ja,
00105                                      const ValueType *values );
00106 
00109     static bool hasDiagonalProperty( const IndexType numDiagonals, const IndexType csrJA[] );
00110 
00111     template<typename ValueType, typename OtherValueType>
00112     static void scaleValue( const IndexType numRows,
00113                             const IndexType Ia[],
00114                             ValueType mValues[],
00115                             const OtherValueType values[] );
00116 
00119     template<typename ValueType>
00120     static void compressIA( const IndexType IA[],
00121                             const IndexType JA[],
00122                             const ValueType values[],
00123                             const IndexType numRows,
00124                             const ValueType eps,
00125                             IndexType newIA[] );
00126 
00129     template<typename ValueType>
00130     static void compressValues( const IndexType IA[],
00131                                 const IndexType JA[],
00132                                 const ValueType values[],
00133                                 const IndexType numRows,
00134                                 const ValueType eps,
00135                                 IndexType newJA[],
00136                                 ValueType newValues[] );
00137 
00140     template<typename ELLValueType, typename CSRValueType>
00141     static void getCSRValues( IndexType csrJA[],
00142                               CSRValueType csrValues[],
00143                               const IndexType csrIA[],
00144                               const IndexType numRows,
00145                               const IndexType ellSizes[],
00146                               const IndexType ellJA[],
00147                               const ELLValueType ellValues[] );
00148 
00151     template<typename ELLValueType, typename CSRValueType>
00152     static void setCSRValues( IndexType ellJA[],
00153                               ELLValueType ellValues[],
00154                               const IndexType ellSizes[],
00155                               const IndexType numRows,
00156                               const IndexType numValuesPerRow,
00157                               const IndexType csrIA[],
00158                               const IndexType csrJA[],
00159                               const CSRValueType csrValues[] );
00160 
00163     template <typename ValueType>
00164     static void computeIA( const IndexType aIA[],
00165                            const IndexType aJA[],
00166                            const IndexType aNumRows,
00167                            const IndexType bIA[],
00168                            const IndexType bJA[],
00169                            const IndexType bNumRows,
00170                            IndexType cIA[] );
00171 
00174     template <typename ValueType>
00175     static void computeValues( const IndexType aIA[],
00176                                const IndexType aJA[],
00177                                const ValueType aValues[],
00178                                const IndexType aNumRows,
00179                                const IndexType bIA[],
00180                                const IndexType bJA[],
00181                                const ValueType bValues[],
00182                                const IndexType bNumRows,
00183                                const ValueType alpha,
00184                                const IndexType cIA[],
00185                                IndexType cJA[],
00186                                ValueType cValues[] );
00187 
00190     template <typename ValueType>
00191     static void addComputeIA( const IndexType aIA[],
00192                               const IndexType aJA[],
00193                               const IndexType aNumRows,
00194                               const IndexType bIA[],
00195                               const IndexType bJA[],
00196                               const IndexType bNumRows,
00197                               IndexType cIA[] );
00198 
00201     template <typename ValueType>
00202     static void addComputeValues( const IndexType aIA[],
00203                                   const IndexType aJA[],
00204                                   const ValueType aValues[],
00205                                   const IndexType aNumRows,
00206                                   const IndexType bIA[],
00207                                   const IndexType bJA[],
00208                                   const ValueType bValues[],
00209                                   const IndexType bNumRows,
00210                                   const ValueType beta,
00211                                   const IndexType cIA[],
00212                                   IndexType cJA[],
00213                                   ValueType cValues[] );
00214 
00217     template <typename ValueType>
00218     static void jacobi( ValueType solution[],
00219                         const IndexType numRows,
00220                         const IndexType ellNumValuesPerRow,
00221                         const IndexType ellSizes[],
00222                         const IndexType ellJA[],
00223                         const ValueType ellValues[],
00224                         const ValueType oldSolution[],
00225                         const ValueType rhs[],
00226                         const ValueType omega,
00227                         class SyncToken* syncToken );
00228 
00231     template<typename ValueType>
00232     static void jacobiHalo( ValueType solution[],
00233                             const IndexType numRows,
00234                             const ValueType diagonal[],
00235                             const IndexType ellNumValuesPerRow,
00236                             const IndexType ellSizes[],
00237                             const IndexType ellJA[],
00238                             const ValueType ellValues[],
00239                             const IndexType rowIndexes[],
00240                             const IndexType numNonEmptyRows,
00241                             const ValueType oldSolution[],
00242                             const ValueType omega,
00243                             class SyncToken* syncToken );
00244 
00247     template <typename ValueType>
00248     static void normalGEMV( ValueType result[],
00249                             const ValueType alpha,
00250                             const ValueType x[],
00251                             const ValueType beta,
00252                             const ValueType y[],
00253                             const IndexType numRows,
00254                             const IndexType numNonZerosPerRow,
00255                             const IndexType csrIA[],
00256                             const IndexType csrJA[],
00257                             const ValueType csrValues[],
00258                             class SyncToken* syncToken );
00259 
00262     template <typename ValueType>
00263     static void sparseGEMV( ValueType result[],
00264                             const IndexType numRows,
00265                             const IndexType numNonZerosPerRow,
00266                             const ValueType alpha,
00267                             const ValueType x[],
00268                             const IndexType numNonZeroRows,
00269                             const IndexType rowIndexes[],
00270                             const IndexType csrIA[],
00271                             const IndexType csrJA[],
00272                             const ValueType csrValues[],
00273                             class SyncToken* syncToken );
00274 
00277     static void setInterface( struct ELLUtilsInterface& ELLUtils );
00278 
00279 private:
00280 
00281     template <typename ValueType>
00282     static void normalGEMV( ValueType result[],
00283                             const ValueType alpha,
00284                             const ValueType x[],
00285                             const ValueType beta,
00286                             const ValueType y[],
00287                             const IndexType numRows,
00288                             const IndexType csrIA[],
00289                             const IndexType csrJA[],
00290                             const ValueType csrValues[] );
00291 
00292     template <typename ValueType>
00293     static void sparseGEMV( ValueType result[],
00294                             const IndexType numRows,
00295                             const ValueType alpha,
00296                             const ValueType x[],
00297                             const IndexType numNonZeroRows,
00298                             const IndexType rowIndexes[],
00299                             const IndexType csrIA[],
00300                             const IndexType csrJA[],
00301                             const ValueType csrValues[] );
00302 
00303     LAMA_LOG_DECL_STATIC_LOGGER( logger );
00304 };
00305 
00306 /* --------------------------------------------------------------------------- */
00307 
00308 }  // namespace lama
00309 
00310 #endif  //  LAMA_ELL_STORAGE_UTILS_HPP_