LAMA
|
00001 00033 #ifndef LAMA_CUDA_CSR_UTILS_HPP_ 00034 #define LAMA_CUDA_CSR_UTILS_HPP_ 00035 00036 // for dll_import 00037 #include <lama/config.hpp> 00038 00039 // others 00040 #include <lama/SyncToken.hpp> 00041 #include <lama/LAMATypes.hpp> 00042 00043 // assert 00044 #include <lama/exception/LAMAAssert.hpp> 00045 00046 // logging 00047 #include <logging/logging.hpp> 00048 00049 namespace lama 00050 { 00051 00052 class LAMA_DLL_IMPORTEXPORT CUDACSRUtils 00053 { 00054 public: 00055 00058 static IndexType sizes2offsets( IndexType sizes[], const IndexType numRows ); 00059 00060 static void offsets2sizes( IndexType sizes[], const IndexType offsets[], const IndexType n ); 00061 00062 static bool hasDiagonalProperty( const IndexType numDiagonals, 00063 const IndexType csrIA[], 00064 const IndexType csrJA[] ); 00065 00068 template <typename ValueType> 00069 static void convertCSR2CSC ( IndexType cscIA[], 00070 IndexType cscJA[], 00071 ValueType cscValues[], 00072 const IndexType csrIA[], 00073 const IndexType csrJA[], 00074 const ValueType csrValues[], 00075 int numRows, int numColumns, int numValues ); 00076 00079 template <typename ValueType> 00080 static void normalGEMV( ValueType result[], 00081 const ValueType alpha, 00082 const ValueType x[], 00083 const ValueType beta, 00084 const ValueType y[], 00085 const IndexType numRows, 00086 const IndexType csrIA[], 00087 const IndexType csrJA[], 00088 const ValueType csrValues[], 00089 class SyncToken* syncToken ); 00090 00093 template <typename ValueType> 00094 static void sparseGEMV( ValueType result[], 00095 const ValueType alpha, 00096 const ValueType x[], 00097 const IndexType numNonZeroRows, 00098 const IndexType rowIndexes[], 00099 const IndexType csrIA[], 00100 const IndexType csrJA[], 00101 const ValueType csrValues[], 00102 class SyncToken* syncToken ); 00103 00106 template <typename ValueType> 00107 static void jacobi( 00108 ValueType* const solution, 00109 const IndexType csrIA[], 00110 const IndexType csrJA[], 00111 const ValueType csrValues[], 00112 const ValueType rhs[], 00113 const ValueType oldSolution[], 00114 const ValueType omega, 00115 const IndexType numRows, 00116 class SyncToken* syncToken ); 00117 00120 template<typename ValueType> 00121 static void jacobiHalo( 00122 ValueType solution[], 00123 const IndexType localIA[], 00124 const ValueType localValues[], 00125 const IndexType haloIA[], 00126 const IndexType haloJA[], 00127 const ValueType haloValues[], 00128 const IndexType haloRowIndexes[], 00129 const ValueType oldSolution[], 00130 const ValueType omega, 00131 const IndexType numNonEmptyRows ); 00132 00135 static void setInterface( struct CSRUtilsInterface& CSRUtils ); 00136 00137 private: 00138 00139 LAMA_LOG_DECL_STATIC_LOGGER(logger); 00140 00141 }; 00142 00143 /* --------------------------------------------------------------------------- */ 00144 00145 } // namespace lama 00146 00147 #endif // LAMA_CUDA_CSR_UTILS_HPP_