LAMA
/home/brandes/workspace/LAMA/src/lama/cuda/CUDAJDSUtils.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_CUDA_JDS_UTILS_HPP_
00034 #define LAMA_CUDA_JDS_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 #include <lama/Scalar.hpp>
00043 
00044 // logging
00045 #include <logging/logging.hpp>
00046 
00047 namespace lama
00048 {
00049 
00054 class LAMA_DLL_IMPORTEXPORT CUDAJDSUtils
00055 {
00056 public:
00057 
00060     template<typename ValueType>
00061     static void setDiagonalWithScalar( const IndexType numDiagonal,
00062                                        ValueType values[],
00063                                        Scalar scalar );
00064 
00067     template<typename ValueType, typename OtherValueType>
00068     static void scaleValue( const IndexType numRows,
00069                             const IndexType perm[],
00070                             const IndexType ilg[],
00071                             const IndexType dlg[],
00072                             ValueType mValues[],
00073                             const OtherValueType values[] );
00074 
00077     template<typename ValueType, typename OtherValueType>
00078     static void getRow( OtherValueType row[],
00079                         const IndexType i,
00080                         const IndexType numColumns,
00081                         const IndexType numRows,
00082                         const IndexType perm[],
00083                         const IndexType ilg[],
00084                         const IndexType dlg[],
00085                         const IndexType ja[],
00086                         const ValueType values[] );
00087 
00088     template<typename ValueType, typename NoType>
00089     static ValueType getValue( const IndexType i,
00090                                const IndexType j,
00091                                const IndexType numRows,
00092                                const IndexType* dlg,
00093                                const IndexType* ilg,
00094                                const IndexType* perm,
00095                                const IndexType* ja,
00096                                const ValueType* values );
00097 
00100     static bool checkDiagonalProperty( const IndexType numDiagonals,
00101                                        const IndexType numRows,
00102                                        const IndexType numColumns,
00103                                        const IndexType perm[],
00104                                        const IndexType ja[],
00105                                        const IndexType dlg[] );
00106 
00109     static bool check( const IndexType numRows,
00110                        const IndexType numValues,
00111                        const IndexType numColumns,
00112                        const IndexType ja[],
00113                        const IndexType ilg[],
00114                        const IndexType dlg[] );
00115 
00118     static void sortRows( IndexType array[], IndexType perm[], 
00119                           const IndexType n );
00120 
00123     static IndexType ilg2dlg( IndexType dlg[],
00124                               const IndexType numDiagonals,
00125                               const IndexType ilg[],
00126                               const IndexType numRows );
00127 
00130     static void setInversePerm( IndexType inversePerm[],
00131                                 const IndexType perm[],
00132                                 const IndexType n );
00133 
00136     template<typename JDSValueType, typename CSRValueType>
00137     static void getCSRValues( IndexType csrJA[],
00138                               CSRValueType csrValues[],
00139                               const IndexType csrIA[],
00140                               const IndexType numRows,
00141                               const IndexType jdsPerm[],
00142                               const IndexType jdsILG[],
00143                               const IndexType jdsDLG[],
00144                               const IndexType jdsJA[],
00145                               const JDSValueType jdsValues[] );
00146 
00149     template<typename JDSValueType, typename CSRValueType>
00150     static void setCSRValues( IndexType jdsJA[],
00151                               JDSValueType jdsValues[],
00152                               const IndexType numRows,
00153                               const IndexType jdsPerm[],
00154                               const IndexType jdsILG[],
00155                               const IndexType jdsDLG[],
00156                               const IndexType csrIA[],
00157                               const IndexType csrJA[],
00158                               const CSRValueType csrValues[] );
00159 
00162     template <typename ValueType>
00163     static void jacobi( ValueType solution[],
00164                         const IndexType numRows,
00165                         const IndexType jdsPerm[],
00166                         const IndexType jdsIlg[],
00167                         const IndexType jdsNumDiagonals,
00168                         const IndexType jdsDlg[],
00169                         const IndexType jdsJA[],
00170                         const ValueType jdsValues[],
00171                         const ValueType oldSolution[],
00172                         const ValueType rhs[],
00173                         const ValueType omega,
00174                         SyncToken* syncToken);
00175 
00176     template <typename ValueType>
00177     static void jacobiHalo( ValueType solutionLocal[],
00178                             const IndexType numRows,
00179                             const ValueType diagonal[],
00180                             const IndexType ndlg_halo,
00181                             const IndexType jdsPermHalo[],
00182                             const IndexType jdsIlgHalo[],
00183                             const IndexType jdsDlgHalo[],
00184                             const IndexType jdsJAHalo[],
00185                             const ValueType jdsValuesHalo[],
00186                             const ValueType oldSolutionHalo[],
00187                             const ValueType omega,
00188                             SyncToken* syncToken );
00191     template <typename ValueType>
00192     static void normalGEMV( ValueType result[],
00193                             const ValueType alpha,
00194                             const ValueType x[],
00195                             const ValueType beta,
00196                             const ValueType y[],
00197                             const IndexType numRows,
00198                             const IndexType perm[],
00199                             const IndexType jdsILG[],
00200                             const IndexType ndlg,
00201                             const IndexType jdsDLG[],
00202                             const IndexType jdsJA[],
00203                             const ValueType jdsValues[],
00204                             class SyncToken* syncToken );
00205 
00208     static void setInterface( struct JDSUtilsInterface& JDSUtils );
00209 
00210 private:
00211 
00212     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00213 
00214 };
00215 
00216 /* --------------------------------------------------------------------------- */
00217 
00218 }  // namespace lama
00219 
00220 #endif //  LAMA_CUDA_JDS_UTILS_HPP_