LAMA
/home/brandes/workspace/LAMA/src/lama/cuda/CUDAELLUtils.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_CUDA_ELL_UTILS_HPP_
00034 #define LAMA_CUDA_ELL_UTILS_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // others
00040 #include <lama/LAMATypes.hpp>
00041 #include <lama/SyncToken.hpp>
00042 
00043 // logging
00044 #include <logging/logging.hpp>
00045 
00046 namespace lama
00047 {
00048 
00054 class LAMA_DLL_IMPORTEXPORT CUDAELLUtils
00055 {
00056 public:
00057 
00060     static inline IndexType ellindex( const IndexType i,
00061                                       const IndexType jj,
00062                                       const IndexType numRows )
00063     {
00064         return jj * numRows + i;
00065     }
00066 
00067 
00070     static IndexType countNonEmptyRowsBySizes( const IndexType sizes[],
00071                                                const IndexType numRows );
00072 
00075     static bool hasDiagonalProperty( const IndexType numDiagonals,
00076                                      const IndexType ellJA[] );
00077 
00080     static void setNonEmptyRowsBySizes( IndexType rowIndexes[],
00081                                         const IndexType numNonEmptyRows,
00082                                         const IndexType sizes[],
00083                                         const IndexType numRows );
00084 
00085     static void check ( const IndexType mNumRows,
00086                         const IndexType mNumValuesPerRow,
00087                         const IndexType mNumColumns,
00088                         const IndexType *ia,
00089                         const IndexType *ja,
00090                         const char* msg );
00091 
00094     template<typename ValueType, typename OtherValueType>
00095     static void getRow( OtherValueType *row,
00096                         const IndexType i,
00097                         const IndexType numRows,
00098                         const IndexType numColumns,
00099                         const IndexType *ia,
00100                         const IndexType *ja,
00101                         const ValueType *values );
00102 
00105     template<typename ValueType, typename OtherValueType>
00106     static OtherValueType getValue ( const IndexType i,
00107                                 const IndexType j,
00108                                 const IndexType numRows,
00109                                 const IndexType *ia,
00110                                 const IndexType *ja,
00111                                 const ValueType *values );
00112 
00115     template<typename ValueType, typename OtherValueType>
00116     static void scaleValue( const IndexType numRows,
00117                             const IndexType Ia[],
00118                             ValueType mValues[],
00119                             const OtherValueType values[] );
00120 
00123     template<typename ELLValueType, typename CSRValueType>
00124     static void getCSRValues( IndexType csrJA[],
00125                               CSRValueType csrValues[],
00126                               const IndexType csrIA[],
00127                               const IndexType numRows,
00128                               const IndexType ellSizes[],
00129                               const IndexType ellJA[],
00130                               const ELLValueType ellValues[] );
00131 
00132 
00133 
00136     template<typename ELLValueType, typename CSRValueType>
00137     static void setCSRValues( IndexType ellJA[],
00138                               ELLValueType ellValues[],
00139                               const IndexType ellSizes[],
00140                               const IndexType numRows,
00141                               const IndexType numValuesPerRow,
00142                               const IndexType csrIA[],
00143                               const IndexType csrJA[],
00144                               const CSRValueType csrValues[] );
00145 
00148     template <typename ValueType>
00149     static void normalGEMV( ValueType result[],
00150                             const ValueType alpha,
00151                             const ValueType x[],
00152                             const ValueType beta,
00153                             const ValueType y[],
00154                             const IndexType numRows,
00155                             const IndexType numNonZerosPerRows,
00156                             const IndexType csrIA[],
00157                             const IndexType csrJA[],
00158                             const ValueType csrValues[],
00159                             class SyncToken* syncToken );
00160 
00163     template <typename ValueType>
00164     static void sparseGEMV( ValueType result[],
00165                             const IndexType numRows,
00166                             const IndexType numNonZerosPerRows,
00167                             const ValueType alpha,
00168                             const ValueType x[],
00169                             const IndexType numNonZeroRows,
00170                             const IndexType rowIndexes[],
00171                             const IndexType csrIA[],
00172                             const IndexType csrJA[],
00173                             const ValueType csrValues[],
00174                             class SyncToken* syncToken );
00175 
00178     template <typename ValueType>
00179     static void jacobi( ValueType solution[],
00180                         const IndexType numRows,
00181                         const IndexType ellNumValuesPerRow,
00182                         const IndexType ellSizes[],
00183                         const IndexType ellJA[],
00184                         const ValueType ellValues[],
00185                         const ValueType oldSolution[],
00186                         const ValueType rhs[],
00187                         const ValueType omega,
00188                         class SyncToken* syncToken );
00189 
00192     template<typename ValueType>
00193     static void jacobiHalo( ValueType solution[],
00194                             const IndexType numRows,
00195                             const ValueType diagonal[],
00196                             const IndexType ellNumValuesPerRow,
00197                             const IndexType ellSizes[],
00198                             const IndexType ellJA[],
00199                             const ValueType ellValues[],
00200                             const IndexType rowIndexes[],
00201                             const IndexType numNonEmptyRows,
00202                             const ValueType oldSolution[],
00203                             const ValueType omega,
00204                             class SyncToken* syncToken );
00205 
00208     static void setInterface( struct ELLUtilsInterface& ELLUtils );
00209 
00210 private:
00211 
00212     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00213 
00214 };
00215 
00216 /* --------------------------------------------------------------------------- */
00217 
00218 }  // namespace lama
00219 
00220 #endif  //  LAMA_CUDA_ELL_UTILS_HPP_