LAMA
/home/brandes/workspace/LAMA/src/lama/openmp/OpenMPJDSUtils.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_OPENMP_JDS_UTILS_HPP_
00034 #define LAMA_OPENMP_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 
00052 class LAMA_DLL_IMPORTEXPORT OpenMPJDSUtils
00053 {
00054 public:
00055 
00058     template<typename ValueType>
00059     static void setDiagonalWithScalar( const IndexType numDiagonal,
00060                                        ValueType values[],
00061                                        Scalar scalar );
00062 
00065     template<typename ValueType, typename OtherValueType>
00066     static void scaleValue( const IndexType numRows,
00067                             const IndexType perm[],
00068                             const IndexType ilg[],
00069                             const IndexType dlg[],
00070                             ValueType mValues[],
00071                             const OtherValueType values[] );
00072 
00075     template<typename ValueType, typename OtherValueType>
00076     static void getRow( OtherValueType row[],
00077                         const IndexType i,
00078                         const IndexType numColumns,
00079                         const IndexType numRows,
00080                         const IndexType perm[],
00081                         const IndexType ilg[],
00082                         const IndexType dlg[],
00083                         const IndexType ja[],
00084                         const ValueType values[] );
00085 
00086     template<typename ValueType, typename NoType>
00087     static ValueType getValue( const IndexType i,
00088                                const IndexType j,
00089                                const IndexType numRows,
00090                                const IndexType* dlg,
00091                                const IndexType* ilg,
00092                                const IndexType* perm,
00093                                const IndexType* ja,
00094                                const ValueType* values );
00095 
00098     static bool checkDiagonalProperty( const IndexType numDiagonals,
00099                                        const IndexType numRows,
00100                                        const IndexType numColumns,
00101                                        const IndexType perm[],
00102                                        const IndexType ja[],
00103                                        const IndexType dlg[] );
00104 
00107     static bool check( const IndexType numRows,
00108                        const IndexType numValues,
00109                        const IndexType numColumns,
00110                        const IndexType ja[],
00111                        const IndexType ilg[],
00112                        const IndexType dlg[] );
00113 
00116     static void sortRows( IndexType array[], IndexType perm[], const IndexType n );
00117 
00120     static void setInversePerm( IndexType inversePerm[], 
00121                                 const IndexType perm[], 
00122                                 const IndexType n );
00123 
00126     static IndexType ilg2dlg( IndexType dlg[],
00127                               const IndexType numDiagonals,
00128                               const IndexType ilg[],
00129                               const IndexType numRows );
00130 
00133     template<typename JDSValueType, typename CSRValueType>
00134     static void getCSRValues( IndexType csrJA[],
00135                               CSRValueType csrValues[],
00136                               const IndexType csrIA[],
00137                               const IndexType numRows,
00138                               const IndexType jdsPerm[],
00139                               const IndexType jdsILG[],
00140                               const IndexType jdsDLG[],
00141                               const IndexType jdsJA[],
00142                               const JDSValueType jdsValues[] );
00143 
00146     template<typename JDSValueType, typename CSRValueType>
00147     static void setCSRValues( IndexType jdsJA[],
00148                               JDSValueType jdsValues[],
00149                               const IndexType numRows,
00150                               const IndexType jdsPerm[],
00151                               const IndexType jdsILG[],
00152                               const IndexType jdsDLG[],
00153                               const IndexType csrIA[],
00154                               const IndexType csrJA[],
00155                               const CSRValueType csrValues[] );
00156 
00159     template <typename ValueType>
00160     static void normalGEMV( ValueType result[],
00161                             const ValueType alpha,
00162                             const ValueType x[],
00163                             const ValueType beta,
00164                             const ValueType y[],
00165                             const IndexType numRows,
00166                             const IndexType perm[],
00167                             const IndexType jdsILG[],
00168                             const IndexType ndlg,
00169                             const IndexType jdsDLG[],
00170                             const IndexType jdsJA[],
00171                             const ValueType jdsValues[],
00172                             SyncToken* syncToken );
00173 
00174     template <typename ValueType>
00175     static void jacobi( ValueType solution[],
00176                         const IndexType numRows,
00177                         const IndexType jdsPerm[],
00178                         const IndexType jdsIlg[],
00179                         const IndexType jdsNumDiagonals,
00180                         const IndexType jdsDlg[],
00181                         const IndexType jdsJA[],
00182                         const ValueType jdsValues[],
00183                         const ValueType oldSolution[],
00184                         const ValueType rhs[],
00185                         const ValueType omega,
00186                         SyncToken* syncToken );
00187 
00188     template<typename ValueType>
00189     static void jacobiHalo( ValueType solution[],
00190                             const IndexType numRows,
00191                             const ValueType localDiagonal[],
00192                             const IndexType numDiagonals,
00193                             const IndexType jdsHaloPerm[],
00194                             const IndexType jdsHaloIlg[],
00195                             const IndexType jdsHaloDlg[],
00196                             const IndexType jdsHaloJA[],
00197                             const ValueType jdsHaloValues[],
00198                             const ValueType oldSolution[],
00199                             const ValueType omega, 
00200                             SyncToken* syncToken );
00201 
00204     static void setInterface( struct JDSUtilsInterface& JDSUtils );
00205 
00206 private:
00207 
00208     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00209 
00210 };
00211 
00212 /* --------------------------------------------------------------------------- */
00213 
00214 }  // namespace lama
00215 
00216 #endif //  LAMA_OPENMP_JDS_UTILS_HPP_