LAMA
/home/brandes/workspace/LAMA/src/lama/LAMAInterface.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_LAMA_INTERFACE_HPP_
00034 #define LAMA_LAMA_INTERFACE_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // base classes
00040 #include <lama/Printable.hpp>
00041 
00042 // others
00043 #include <lama/Scalar.hpp>
00044 #include <lama/Printable.hpp>
00045 #include <lama/SyncToken.hpp>
00046 
00050 #define LAMA_INTERFACE_DEFINE( structname, functionname )                                     \
00051                                                                                               \
00052     \
00053                                                                                               \
00054     structname::functionname                                                                  \
00055     functionname () const                                                                     \
00056     {                                                                                         \
00057         return functionname##_Table;                                                          \
00058     }                                                                                         \
00059                                                                                               \
00060                                      \
00061                                                                                               \
00062     void functionname##_add( structname::functionname functionPtr )                           \
00063     {                                                                                         \
00064         functionname##_Table = functionPtr;                                                   \
00065     }                                                                                         \
00066                                                                                               \
00067     structname::functionname functionname##_Table;         
00068 
00069 #define LAMA_INTERFACE_DEFINE_T( structname, functionname )                                   \
00070                                                                                               \
00071     \
00072                                                                                               \
00073     template<typename T>                                                                      \
00074     typename structname<T>::functionname                                                      \
00075     functionname () const                                                                     \
00076     {                                                                                         \
00077         return ( typename structname<T>::functionname )                                       \
00078                functionname##_Table[ Scalar::getType<T>() ];                                  \
00079     }                                                                                         \
00080                                                                                               \
00081                                      \
00082                                                                                               \
00083     template<typename T>                                                                      \
00084     void functionname##_add( typename structname<T>::functionname functionPtr )               \
00085     {                                                                                         \
00086         functionname##_Table[ Scalar::getType<T>() ]                                          \
00087          = ( void (*) () ) functionPtr;                                                       \
00088     }                                                                                         \
00089                                                                                               \
00090     void ( *functionname##_Table[ Scalar::UNKNOWN ] ) ();  
00091 
00092 #define LAMA_INTERFACE_DEFINE_TT( structname, functionname )                                  \
00093                                                                                               \
00094     \
00095                                                                                               \
00096     template<typename T1, typename T2>                                                        \
00097     typename structname<T1, T2>::functionname                                                 \
00098     functionname () const                                                                     \
00099     {                                                                                         \
00100         return ( typename structname<T1,T2>::functionname )                                   \
00101                functionname##_Table[ Scalar::getType<T1>()][ Scalar::getType<T2>() ];         \
00102     }                                                                                         \
00103                                                                                               \
00104                                      \
00105                                                                                               \
00106     template<typename T1, typename T2>                                                        \
00107     void functionname##_add( typename structname<T1, T2>::functionname functionPtr )          \
00108     {                                                                                         \
00109         functionname##_Table[ Scalar::getType<T1>() ][ Scalar::getType<T2>() ]                \
00110            = ( void (*) () ) functionPtr;                                                     \
00111     }                                                                                         \
00112                                                                                               \
00113     void ( *functionname##_Table[ Scalar::UNKNOWN ][ Scalar::UNKNOWN] ) ();   
00114                                                                                               
00119 #define LAMA_INTERFACE_INIT( functionname )                                                 \
00120     functionname##_Table = NULL; 
00121 
00122 #define LAMA_INTERFACE_INIT_T( functionname )                                               \
00123     for ( int i = 0; i < Scalar::UNKNOWN; ++i )                                             \
00124     {                                                                                       \
00125         functionname##_Table[i] = NULL;                                                     \
00126     }                                                                                       \
00127 
00128 #define LAMA_INTERFACE_INIT_TT( functionname )                                              \
00129     for ( int i = 0; i < Scalar::UNKNOWN; ++i )                                             \
00130     {                                                                                       \
00131         for ( int j = 0; j < Scalar::UNKNOWN; ++j )                                         \
00132         {                                                                                   \
00133             functionname##_Table[i][j] = NULL;                                              \
00134         }                                                                                   \
00135     }                                                                                       \
00136 
00137 #define LAMA_INTERFACE_REGISTER( interface, function )                                      \
00138     interface.function##_add( function );
00139 
00140 #define LAMA_INTERFACE_REGISTER_T( interface, function, T )                                 \
00141     interface.function##_add<T>( function<T> );
00142 
00143 #define LAMA_INTERFACE_REGISTER_TT( interface, function, T1, T2 )                           \
00144     interface.function##_add<T1,T2>( function<T1,T2> );
00145 
00146 #define LAMA_INTERFACE_FN( function, loc, module, structname )                                \
00147     typename module##Interface::structname::function function =                               \
00148        loc->getInterface().module.function();                                                 \
00149     if ( function == NULL )                                                                   \
00150     {                                                                                         \
00151         LAMA_THROWEXCEPTION( "Method " #module "::" #function " not available on " << *loc ); \
00152     }
00153 
00154 #define LAMA_INTERFACE_FN_T( function, loc, module, structname, T )                           \
00155     typename module##Interface::structname<T>::function function;                             \
00156     function = loc->getInterface().module.function<T>();                                      \
00157     if ( function == NULL )                                                                   \
00158     {                                                                                         \
00159         LAMA_THROWEXCEPTION( "Method " #module "::" #function " not available on " << *loc ); \
00160     }
00161     
00162 #define LAMA_INTERFACE_FN_DEFAULT_T( function, loc, module, structname, T )                   \
00163     typename module##Interface::structname<T>::function function =                            \
00164        loc->getInterface().module.function<T>();                                              \
00165     if ( function == NULL )                                                                   \
00166     {                                                                                         \
00167         LAMA_UNSUPPORTED( "Method " #module "::" #function " not available on " << *loc );    \
00168         loc = ContextFactory::getContext( Context::Host );                                    \
00169         function = loc->getInterface().module.function<T>();                                  \
00170         if ( function == NULL )                                                               \
00171         {                                                                                     \
00172             LAMA_THROWEXCEPTION( "Method " #module "::" #function                             \
00173                                  " also not available on " << *loc );                         \
00174         }                                                                                     \
00175     }
00176 
00177     
00178 #define LAMA_INTERFACE_FN_TT( function, loc, module, structname, T1, T2 )                     \
00179     typename module##Interface::structname<T1,T2>::function function;                         \
00180     function = loc->getInterface().module.function<T1,T2>();                                  \
00181     if ( function == NULL )                                                                   \
00182     {                                                                                         \
00183         LAMA_THROWEXCEPTION( "Method " #module "::" #function " not available on " << *loc ); \
00184     }
00185 
00186 namespace lama
00187 {
00188 
00189 template<typename T> 
00190 struct BLAS1Interface
00191 {
00192 
00204     void (*scal) ( const IndexType n, const T alpha, T* x, const IndexType incX, SyncToken* syncToken );
00205 
00217     T (*nrm2) ( const IndexType n, const T* x, const IndexType incX, SyncToken* syncToken );
00218 
00230     T (*asum) ( const IndexType n, const T* x, const IndexType incX, SyncToken* syncToken );
00231 
00243     IndexType (*iamax) ( const IndexType n, const T* x, const IndexType incX, SyncToken* syncToken );
00244 
00254     T (*viamax) ( const IndexType n, const T* x, const IndexType incX, SyncToken* syncToken );
00255 
00269     void (*swap) ( const IndexType n, T* x, const IndexType incX, T* y, const IndexType incY, SyncToken* syncToken );
00270 
00283     void (*copy) ( const IndexType n, const T* x, const IndexType incX, T* y, const IndexType incY, SyncToken* syncToken );
00284 
00299     void (*axpy) ( const IndexType n, T alpha, const T* x, const IndexType incX, T* y, const IndexType incY, SyncToken* syncToken );
00300 
00316     T (*dot) ( const IndexType n, const T* x, const IndexType incX, const T* y, const IndexType inc, SyncToken* syncToken);
00317 
00321     void (*sum) ( const IndexType n, T alpha, const T* x, T beta, const T* y, T* z, SyncToken* syncToken );
00322 
00334     void (*rot) ( const IndexType N, T *X, const IndexType incX, T *Y, const IndexType incY, const T c, const T s, SyncToken* syncToken );
00335 
00348     void (*rotm) ( const IndexType N, T *X, const IndexType incX, T *Y, const IndexType incY, const T *P, SyncToken* syncToken );
00349 
00359     void (*rotg) ( T *a, T *b, T *c, T *s, SyncToken* syncToken );
00360 
00373     void (*rotmg) ( T *d1, T *d2, T *b1, const T b2, T *p, SyncToken* syncToken );
00374 
00386     void (*ass) ( const IndexType n, const T value, T *x, SyncToken* syncToken );
00387 
00390     BLAS1Interface();
00391 };
00392 
00393 template<typename T>
00394 struct BLAS2Interface
00395 {
00430     void ( *gemv ) ( const enum CBLAS_ORDER order, const enum CBLAS_TRANSPOSE trans, 
00431                      const IndexType m, const IndexType n,
00432                      const T alpha, const T *A, const IndexType lda, 
00433                      const T *x, const IndexType incX, 
00434                      const T beta, T *y, const IndexType incY, SyncToken* syncToken );
00435 
00482     void (*symv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const IndexType n, const T alpha,
00483                    const T *A,const IndexType lda, const T *x, const IndexType incX, const T beta, T *y,
00484                    const IndexType incY, SyncToken* syncToken );
00485 
00533     void (*trmv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
00534                    const enum CBLAS_DIAG diag, const IndexType n, const T *A, const IndexType lda, T *x,
00535                    const IndexType incX, SyncToken* syncToken );
00536 
00587     void (*trsv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
00588                    const enum CBLAS_DIAG diag, const IndexType n, const T *A, const IndexType lda, T *x,
00589                    const IndexType incX, SyncToken* syncToken);
00590 
00628     void (*gbmv) ( const enum CBLAS_ORDER order, const enum CBLAS_TRANSPOSE trans, const int m, const int n,
00629                    const int kl, const int ku, const T alpha, const T *A, const int lda, const T *x,
00630                    const int incX, const T beta, T *y, const int incY, SyncToken* syncToken );
00631 
00676     void (*sbmv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const IndexType n, const IndexType k,
00677                    const T alpha, const T *A, const IndexType lda, const T *x, const IndexType incX, const T beta,
00678                    T *y, const IndexType incY, SyncToken* syncToken );
00679 
00738     void (*tbmv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
00739                    const enum CBLAS_DIAG diag, const IndexType n, const IndexType k, const T *A, const IndexType lda,
00740                    T *x, const IndexType incX, SyncToken* syncToken );
00741 
00801     void (*tbsv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
00802                    const enum CBLAS_DIAG diag, const IndexType n, const IndexType k, const T *A, const IndexType lda,
00803                    T *x, const IndexType incX, SyncToken* syncToken);
00804 
00830     void (*ger)  ( const enum CBLAS_ORDER order, const IndexType m, const IndexType n, const T alpha, const T *x,
00831                    const IndexType incX, const T *y, const IndexType incY, T *A, const IndexType lda, SyncToken* syncToken );
00832 
00870     void (*syr) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const IndexType n, const T alpha, const T *x,
00871                   const IndexType incX, T *A, const IndexType lda, SyncToken* syncToken );
00872 
00913     void (*syr2) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const IndexType n, const T alpha, const T *x,
00914                    const IndexType incX, const T *y, const IndexType incY, T *A, const IndexType lda, SyncToken* syncToken );
00915 
00951     void (*spmv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const IndexType n, const T alpha, const T *AP,
00952                    const T *x, const IndexType incX, const T beta, T *y, const IndexType incY, SyncToken* syncToken );
00953 
00985     void (*spr) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const IndexType n, const T alpha, const T *x,
00986                   const IndexType incX, T *AP, SyncToken* syncToken );
00987 
01021     void (*spr2) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const IndexType n, const T alpha, const T *x,
01022                    const IndexType incX, const T *y, const IndexType incY, T *AP, SyncToken* syncToken );
01023 
01068     void (*tpmv) ( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
01069                    const enum CBLAS_DIAG diag, const IndexType n, const T *AP, T *x, const IndexType incX, SyncToken* syncToken );
01070 
01120     void (*tpsv)( const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
01121                   const enum CBLAS_DIAG diag, const IndexType n, const T *Ap, T *x, const IndexType incX, SyncToken* syncToken );
01122 
01127     BLAS2Interface();
01128 };
01129 
01130 template<typename T>
01131 struct BLAS3Interface
01132 {
01187     void (*gemm) (const enum CBLAS_ORDER order, const enum CBLAS_TRANSPOSE transA, const enum CBLAS_TRANSPOSE transB,
01188                   const IndexType m, const IndexType n, const IndexType k, const T alpha, const T* A,
01189                   const IndexType lda, const T* B, const IndexType ldb, 
01190                   const T beta, T* C, const IndexType ldc, class SyncToken* syncToken );
01191 
01194     void (*symm) (const enum CBLAS_ORDER order, const enum CBLAS_SIDE side, const enum CBLAS_UPLO uplo, const int m,
01195                   const int n, const T alpha, const T *A, const int lda, const T *B, const int ldb,
01196                   const T beta, T *C, const int ldc, SyncToken* syncToken );
01197 
01200     void (*trmm) (const enum CBLAS_ORDER order, const enum CBLAS_SIDE Side, const enum CBLAS_UPLO Uplo,
01201                   const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag, const IndexType M,
01202                   const IndexType N, const T alpha, const T *A, const IndexType lda, T *B, const IndexType ldb,
01203                   SyncToken* syncToken );
01204 
01207     void (*trsm) (const enum CBLAS_ORDER order, const enum CBLAS_SIDE Side, const enum CBLAS_UPLO Uplo,
01208                   const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag, const IndexType M,
01209                   const IndexType N, const T alpha, const T *A, const IndexType lda, T *B,
01210                   const IndexType ldb, SyncToken* syncToken );
01211 
01214     void (*syrk) (const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
01215                   const int n, const int k, const T alpha, const T *A, const int lda, const T beta,
01216                   T *C, const int ldc, SyncToken* syncToken );
01217 
01218     void (*syrk2) (const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
01219                    const IndexType n, const IndexType k, const T alpha, const T *A, const IndexType lda, const T *B,
01220                    const IndexType ldb, const T beta, T *C, const IndexType ldc, SyncToken* syncToken );
01221 
01226     BLAS3Interface();
01227 };
01228 
01231 template<typename T>
01232 struct LAPACKInterface
01233 {
01235     IndexType (*getrf) (const enum CBLAS_ORDER order, const IndexType m, const IndexType n, T* a,
01236                         const IndexType lda, IndexType* ipivot);
01237 
01248     void (*getinv) ( const IndexType n, T* a, const IndexType lda );
01249 
01251     IndexType (*getri) (const enum CBLAS_ORDER , const IndexType n, T* a,
01252                         const IndexType lda, IndexType* ipivot);
01253 
01255     IndexType (*trtrs) (const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
01256                         const enum CBLAS_DIAG diag, const IndexType n, const IndexType nrhs, const T* A,
01257                         const IndexType lda, T* B, const IndexType ldb);
01258 
01260     IndexType (*tptrs) (const enum CBLAS_ORDER order, const enum CBLAS_UPLO uplo, const enum CBLAS_TRANSPOSE trans,
01261                         const enum CBLAS_DIAG diag, const IndexType n, const IndexType nrhs, const T* AP, T* B,
01262                         const IndexType ldb);
01263 
01265     void (*laswp) (const enum CBLAS_ORDER order, const IndexType n, T* A, const IndexType lda, const IndexType k1,
01266                    const IndexType k2, const IndexType* ipiv, const IndexType incx, SyncToken* syncToken);
01267 
01268     LAPACKInterface();   // default constructor, initializes all pointers to NULL
01269 };
01270 
01271 template<typename T>
01272 struct SCALAPACKInterface
01273 {
01275     IndexType (*pgetrf) (const IndexType m, const IndexType n, const T* const A, const IndexType ia, const IndexType ja,
01276                          IndexType* descA, IndexType* const ipiv);
01277 
01279     IndexType (*pgetri) (const IndexType n, const T* const A, const IndexType ia, const IndexType ja, IndexType* descA, IndexType* const ipiv,
01280                          const T* work, IndexType lwork, IndexType* iwork, IndexType liwork );
01281 
01290     void ( *inverse ) ( const IndexType n, const IndexType nB, const T* a,
01291                         const class Communicator& comm );
01292 
01295     SCALAPACKInterface();
01296 };
01297 
01300 struct UtilsInterface 
01301 {
01304     struct Indexes
01305     {
01314         typedef bool ( *validIndexes) ( const IndexType array[], const IndexType n, const IndexType size );
01315     };
01316 
01322     template<typename ValueType>
01323     struct Reductions
01324     {
01332         typedef ValueType ( *sum ) ( const ValueType array[], const IndexType n );
01333 
01334         typedef ValueType ( *maxval ) ( const ValueType array[], const IndexType n );
01335 
01338         typedef ValueType ( *absMaxVal ) ( const ValueType array[], const IndexType n );
01339 
01350         typedef ValueType ( *absMaxDiffVal ) ( const ValueType array1[], const ValueType array2[], const IndexType n );
01351     };
01352 
01353     template<typename ValueType>
01354     struct Setter
01355     {
01358         typedef void ( *setVal ) ( ValueType array[], const IndexType n, const ValueType val );
01359 
01362         typedef void ( *setOrder ) ( ValueType array[], const IndexType n );
01363     };
01364 
01365     template<typename ValueType>
01366     struct Getter
01367     {
01368         typedef ValueType ( *getValue ) ( const ValueType* array, const IndexType i );
01369     };
01370 
01371     LAMA_INTERFACE_DEFINE_T( Getter, getValue )
01372 
01373     template<typename ValueType1, typename ValueType2>
01374     struct Copy
01375     {
01378         typedef void ( *set ) ( ValueType1 out[],
01379                                 const ValueType2 in[],
01380                                 const IndexType n );
01381 
01384         typedef void ( *setGather ) ( ValueType1 out[],
01385                                       const ValueType2 in[],
01386                                       const IndexType indexes[], 
01387                                       const IndexType n );
01388 
01391         typedef void ( *setScatter ) ( ValueType1 out[],
01392                                        const IndexType indexes[], 
01393                                        const ValueType2 in[],
01394                                        const IndexType n );
01395     };
01396 
01397     template<typename ValueType>
01398     struct Math
01399     {
01406         typedef void ( *invert ) ( ValueType array[], const IndexType n );
01407     };
01408 
01409     template<typename ValueType, typename OtherValueType>
01410     struct Transform
01411     {
01412         typedef void ( *scale ) ( ValueType values[],
01413                                   const IndexType n,
01414                                   const OtherValueType value );
01415     };
01416 
01417     LAMA_INTERFACE_DEFINE( Indexes, validIndexes )
01418 
01419     LAMA_INTERFACE_DEFINE_T( Reductions, sum )
01420     LAMA_INTERFACE_DEFINE_T( Reductions, maxval )
01421     LAMA_INTERFACE_DEFINE_T( Reductions, absMaxVal )
01422     LAMA_INTERFACE_DEFINE_T( Reductions, absMaxDiffVal )
01423 
01424     LAMA_INTERFACE_DEFINE_T( Setter, setVal )
01425     LAMA_INTERFACE_DEFINE_T( Setter, setOrder )
01426 
01427     LAMA_INTERFACE_DEFINE_TT( Copy, setGather )
01428     LAMA_INTERFACE_DEFINE_TT( Copy, setScatter )
01429     LAMA_INTERFACE_DEFINE_TT( Copy, set )
01430 
01431     LAMA_INTERFACE_DEFINE_T( Math, invert )
01432 
01433     LAMA_INTERFACE_DEFINE_TT( Transform, scale )
01434 
01437     UtilsInterface ();
01438 };
01439 
01446 struct CSRUtilsInterface
01447 {
01450     template<typename ValueType>
01451     struct Operations
01452     {
01453         typedef void ( *sortRowElements ) ( IndexType csrJA[],
01454                                             ValueType csrValues[],
01455                                             const IndexType csrIA[],
01456                                             const IndexType numRows,
01457                                             const bool diagonalFlag ) ;
01458     };
01459 
01460     LAMA_INTERFACE_DEFINE_T( Operations, sortRowElements )
01461 
01462     
01464     template<typename ValueType>
01465     struct Solver
01466     {
01472        typedef void ( *jacobi ) ( ValueType* const solution,
01473                                   const IndexType csrIA[],
01474                                   const IndexType csrJA[],
01475                                   const ValueType csrValues[],
01476                                   const ValueType oldSolution[],
01477                                   const ValueType rhs[],
01478                                   const ValueType omega,
01479                                   const IndexType numRows, 
01480                                   class SyncToken* syncToken );
01481 
01487         typedef void ( *jacobiHalo ) ( ValueType solution[],
01488                                        const IndexType localIA[],
01489                                        const ValueType localValues[],
01490                                        const IndexType haloIA[],
01491                                        const IndexType haloJA[],
01492                                        const ValueType haloValues[],
01493                                        const IndexType haloRowIndexes[],
01494                                        const ValueType oldSolution[],
01495                                        const ValueType omega,
01496                                        const IndexType numNonEmptyRows );
01497     };
01498 
01499     LAMA_INTERFACE_DEFINE_T( Solver, jacobi )
01500     LAMA_INTERFACE_DEFINE_T( Solver, jacobiHalo )
01501 
01504     struct Offsets
01505     {
01521         typedef IndexType ( *sizes2offsets ) ( IndexType array[], const IndexType n );
01522 
01536         typedef void ( *offsets2sizes ) ( IndexType sizes[], const IndexType offsets[], const IndexType n );
01537 
01540         typedef bool ( *validOffsets ) ( const IndexType array[], const IndexType n, const IndexType total );
01541 
01555         typedef void ( *matrixAddSizes ) ( IndexType cSizes[], const IndexType numRows, 
01556                                            const IndexType numColumns, bool diagonalProperty,
01557                                            const IndexType aIA[], const IndexType aJA[],
01558                                            const IndexType bIA[], const IndexType bJA[] );
01559 
01570         typedef void ( *matrixMultiplySizes ) ( IndexType cSizes[], const IndexType numRows, 
01571                                                 const IndexType numColumns, bool diagonalProperty,
01572                                                 const IndexType aIA[], const IndexType aJA[],
01573                                                 const IndexType bIA[], const IndexType bJA[] );
01574 
01586         typedef void ( *matrixMultiplyJA ) ( IndexType cJA[], const IndexType cIA[],
01587                                              const IndexType numRows, const IndexType numColumns,
01588                                              bool diagonalProperty,
01589                                              const IndexType aIA[], const IndexType aJA[],
01590                                              const IndexType bIA[], const IndexType bJA[] );
01591 
01592         typedef bool ( *hasDiagonalProperty ) ( const IndexType numDiagonals,
01593                                                 const IndexType csrIA[],
01594                                                 const IndexType csrJA[] );
01595 
01596     };
01597 
01598     LAMA_INTERFACE_DEFINE( Offsets, sizes2offsets )
01599     LAMA_INTERFACE_DEFINE( Offsets, offsets2sizes )
01600     LAMA_INTERFACE_DEFINE( Offsets, validOffsets )
01601     LAMA_INTERFACE_DEFINE( Offsets, matrixAddSizes )
01602     LAMA_INTERFACE_DEFINE( Offsets, matrixMultiplySizes )
01603     LAMA_INTERFACE_DEFINE( Offsets, matrixMultiplyJA )
01604     LAMA_INTERFACE_DEFINE( Offsets, hasDiagonalProperty )
01605 
01613     template<typename ValueType>
01614     struct Transpose
01615     {
01625         typedef void( *convertCSR2CSC ) ( IndexType cscIA[],
01626                                           IndexType cscJA[],
01627                                           ValueType cscValues[],
01628                                           const IndexType csrIA[],
01629                                           const IndexType csrJA[],
01630                                           const ValueType csrValues[],
01631                                           IndexType numRows, IndexType numColumns,
01632                                           IndexType numValues );
01633     };
01634 
01635     LAMA_INTERFACE_DEFINE_T( Transpose, convertCSR2CSC )
01636 
01637     
01639     template<typename ValueType1, typename ValueType2>
01640     struct Scale
01641     {
01642 
01648         typedef void ( *scaleRows ) ( ValueType1 csrValues[],
01649                                       const IndexType csrIA[],
01650                                       const IndexType numRows,
01651                                       const ValueType2 values[] );
01652     };
01653 
01654     LAMA_INTERFACE_DEFINE_TT( Scale, scaleRows )
01655 
01656     
01658     template <typename ValueType>
01659     struct Reductions
01660     {
01670         typedef ValueType ( *absMaxDiffVal ) ( IndexType numRows, bool sortedRows,
01671            const IndexType csrIA1[], const IndexType csrJA1[], const ValueType csrValues1[],
01672            const IndexType csrIA2[], const IndexType csrJA2[], const ValueType csrValues2[] );
01673     };
01674 
01675     LAMA_INTERFACE_DEFINE_T( Reductions, absMaxDiffVal )
01676 
01677     
01679     template<typename ValueType>
01680     struct Mult
01681     {
01682 
01688         typedef void ( *scaleRows ) ( ValueType csrValues[],
01689                                       const IndexType csrIA[],
01690                                       const IndexType numRows,
01691                                       const ValueType values[] );
01692 
01705         typedef void ( *normalGEMV ) ( ValueType result[],
01706                                        const ValueType alpha,
01707                                        const ValueType x[],
01708                                        const ValueType beta,
01709                                        const ValueType y[],
01710                                        const IndexType numRows,
01711                                        const IndexType csrIA[],
01712                                        const IndexType csrJA[],
01713                                        const ValueType csrValues[],
01714                                        class SyncToken* syncToken );
01715 
01730         typedef void ( *sparseGEMV ) ( ValueType result[],
01731                                        const ValueType alpha,
01732                                        const ValueType x[],
01733                                        const IndexType numNonZeroRows,
01734                                        const IndexType rowIndexes[],
01735                                        const IndexType csrIA[],
01736                                        const IndexType csrJA[],
01737                                        const ValueType csrValues[],
01738                                        class SyncToken* syncToken );
01739 
01753         typedef void ( *gemm ) ( ValueType result[],
01754                                  const ValueType alpha,
01755                                  const ValueType x[],
01756                                  const ValueType beta,
01757                                  const ValueType y[],
01758                                  const IndexType m,
01759                                  const IndexType n,
01760                                  const IndexType p,
01761                                  const IndexType csrIA[],
01762                                  const IndexType csrJA[],
01763                                  const ValueType csrValues[],
01764                                  class SyncToken* syncToken );
01765 
01782         typedef void ( *matrixAdd ) ( IndexType cJA[],
01783                                       ValueType cValues[], 
01784                                       const IndexType cIA[], 
01785                                       const IndexType numRows,
01786                                       const IndexType numColumns,
01787                                       const bool diagonalProperty,
01788                                       const ValueType alpha,
01789                                       const IndexType aIA[], 
01790                                       const IndexType aJA[], 
01791                                       const ValueType aValues[],
01792                                       const ValueType beta,
01793                                       const IndexType bIA[], 
01794                                       const IndexType bJA[], 
01795                                       const ValueType bValues[] );
01796 
01811         typedef void ( *matrixMultiply ) ( ValueType cValues[], 
01812                                            const IndexType cIA[], 
01813                                            const IndexType cJA[],
01814                                            const IndexType numRows,
01815                                            const ValueType alpha,
01816                                            const IndexType aIA[], 
01817                                            const IndexType aJA[], 
01818                                            const ValueType aValues[],
01819                                            const IndexType bIA[], 
01820                                            const IndexType bJA[], 
01821                                            const ValueType bValues[] );
01822 
01823     };
01824 
01825     LAMA_INTERFACE_DEFINE_T( Mult, normalGEMV )
01826     LAMA_INTERFACE_DEFINE_T( Mult, gemm )
01827     LAMA_INTERFACE_DEFINE_T( Mult, sparseGEMV )
01828     LAMA_INTERFACE_DEFINE_T( Mult, matrixAdd )
01829     LAMA_INTERFACE_DEFINE_T( Mult, matrixMultiply )
01830 
01831     CSRUtilsInterface ();
01832 };
01833 
01840 struct DenseUtilsInterface
01841 {
01844     template<typename DenseValueType>
01845     struct Counting
01846     {
01859         typedef void ( *getCSRSizes )( IndexType csrSizes[],
01860                                        bool diagonalFlag,
01861                                        const IndexType numRows,
01862                                        const IndexType numColumns,
01863                                        const DenseValueType denseValues[],
01864                                        const DenseValueType eps );
01865     };
01866 
01867     LAMA_INTERFACE_DEFINE_T( Counting, getCSRSizes )
01868 
01869     
01871     template<typename DenseValueType, typename CSRValueType>
01872     struct Conversions
01873     {
01888         typedef void ( *getCSRValues ) ( IndexType csrJA[],
01889                                          CSRValueType csrValues[],
01890                                          const IndexType csrIA[],
01891                                          const bool diagonalFlag,
01892                                          const IndexType numRows,
01893                                          const IndexType numColumns,
01894                                          const DenseValueType denseValues[],
01895                                          const DenseValueType eps );
01896 
01899         typedef void ( *setCSRValues ) ( DenseValueType denseValues[],
01900                                          const IndexType numRows,
01901                                          const IndexType numColumns,
01902                                          const IndexType csrIA[],
01903                                          const IndexType csrJA[],
01904                                          const CSRValueType csrValues[] );
01905     };
01906 
01907     LAMA_INTERFACE_DEFINE_TT( Conversions, setCSRValues )
01908     LAMA_INTERFACE_DEFINE_TT( Conversions, getCSRValues )
01909 
01912     template<typename DenseValueType1, typename DenseValueType2>
01913     struct Copy
01914     {
01917         typedef void ( *copyDenseValues ) ( DenseValueType1 newValues[],
01918                                             const IndexType numRows,
01919                                            const IndexType numColumns,
01920                                            const DenseValueType2 oldValues[] );
01921         
01924          typedef void ( *getDiagonal ) ( DenseValueType1 diagonalValues[],
01925                                          const IndexType numDiagonalValues,
01926                                          const DenseValueType2 denseValues[],
01927                                          const IndexType numRows,
01928                                          const IndexType numColumns );
01929 
01932          typedef void ( *setDiagonal ) ( DenseValueType1 denseValues[],
01933                                          const IndexType numRows,
01934                                          const IndexType numColumns,
01935                                          const DenseValueType2 diagonalValues[],
01936                                          const IndexType numDiagonalValues );
01937     };
01938 
01939     LAMA_INTERFACE_DEFINE_TT( Copy, copyDenseValues )
01940     LAMA_INTERFACE_DEFINE_TT( Copy, setDiagonal )
01941     LAMA_INTERFACE_DEFINE_TT( Copy, getDiagonal )
01942 
01945     template<typename DenseValueType>
01946     struct Modify
01947     {
01950         typedef void ( *scaleValue ) ( DenseValueType denseValues[],
01951                                        const IndexType numRows,
01952                                        const IndexType numColumns,
01953                                        const DenseValueType val );
01954 
01957         typedef void ( *setDiagonalValue ) ( DenseValueType denseValues[],
01958                                              const IndexType numRows,
01959                                              const IndexType numColumns,
01960                                              const DenseValueType val );
01961     };
01962 
01963     LAMA_INTERFACE_DEFINE_T( Modify, scaleValue )
01964     LAMA_INTERFACE_DEFINE_T( Modify, setDiagonalValue )
01965 
01966     template<typename ValueType>
01967     struct Mult
01968     {
01982         typedef void ( *normalGEMV ) ( ValueType result[],
01983                                        const ValueType alpha,
01984                                        const ValueType x[],
01985                                        const ValueType beta,
01986                                        const ValueType y[],
01987                                        const IndexType numRows,
01988                                        const IndexType numColumns,
01989                                        const ValueType denseValues[],
01990                                        class SyncToken* syncToken );
01991     };
01992 
01993     LAMA_INTERFACE_DEFINE_T( Mult, normalGEMV )
01994 
01995     
01997     DenseUtilsInterface ();
01998 };
01999 
02006 struct ELLUtilsInterface
02007 {
02009     template<typename ValueType>
02010     struct Solver
02011     {
02026         typedef void ( *jacobi ) ( ValueType solution[],
02027                                    const IndexType numRows,
02028                                    const IndexType ellNumValuesPerRow,
02029                                    const IndexType ellSizes[],
02030                                    const IndexType ellJA[],
02031                                    const ValueType ellValues[],
02032                                    const ValueType oldSolution[],
02033                                    const ValueType rhs[],
02034                                    const ValueType omega,
02035                                    class SyncToken* syncToken );
02036 
02037         typedef void ( *jacobiHalo ) (ValueType solution[],
02038                                       const IndexType numRows,
02039                                       const ValueType diagonal[],
02040                                       const IndexType ellNumValuesPerRow,
02041                                       const IndexType ellSizes[],
02042                                       const IndexType ellJA[],
02043                                       const ValueType ellValues[],
02044                                       const IndexType rowIndexes[],
02045                                       const IndexType numNonEmptyRows,
02046                                       const ValueType oldSolution[],
02047                                       const ValueType omega,
02048                                       class SyncToken* syncToken );
02049     };
02050 
02051     LAMA_INTERFACE_DEFINE_T( Solver, jacobi )
02052     LAMA_INTERFACE_DEFINE_T( Solver, jacobiHalo )
02053 
02056     template<typename ELLValueType, typename CSRValueType>
02057     struct Conversions
02058     {
02070         typedef void ( *getCSRValues ) ( IndexType csrJA[],
02071                                          CSRValueType csrValues[],
02072                                          const IndexType csrIA[],
02073                                          const IndexType numRows,
02074                                          const IndexType ellSizes[],
02075                                          const IndexType ellJA[],
02076                                          const ELLValueType ellValues[] );
02077 
02080         typedef void( *setCSRValues ) ( IndexType ellJA[],
02081                                         ELLValueType ellValues[],
02082                                         const IndexType ellSizes[],
02083                                         const IndexType numRows,
02084                                         const IndexType numValuesPerRow,
02085                                         const IndexType csrIA[],
02086                                         const IndexType csrJA[],
02087                                         const CSRValueType csrValues[] );
02088 
02089 
02090 
02091     };
02092 
02093     LAMA_INTERFACE_DEFINE_TT( Conversions, setCSRValues )
02094     LAMA_INTERFACE_DEFINE_TT( Conversions, getCSRValues )
02095 
02096     template<typename ValueType>
02097     struct Helper
02098     {
02099 
02110         typedef void ( *compressIA ) ( const IndexType IA[],
02111                                        const IndexType JA[],
02112                                        const ValueType values[],
02113                                        const IndexType numRows,
02114                                        const ValueType eps,
02115                                        IndexType newIA[] );
02116 
02117 
02129         typedef void ( *compressValues ) ( const IndexType IA[],
02130                                            const IndexType JA[],
02131                                            const ValueType values[],
02132                                            const IndexType numRows,
02133                                            const ValueType eps,
02134                                            IndexType newJA[],
02135                                            ValueType newValues[] );
02136 
02137     };
02138 
02139     LAMA_INTERFACE_DEFINE_T( Helper, compressIA )
02140     LAMA_INTERFACE_DEFINE_T( Helper, compressValues )
02141 
02142 
02143     template<typename ValueType, typename OtherValueType>
02144     struct Getter
02145     {
02157         typedef void ( *getRow ) ( OtherValueType *row,
02158                                    const IndexType i,
02159                                    const IndexType numRows,
02160                                    const IndexType numColumns,
02161                                    const IndexType *ia,
02162                                    const IndexType *ja,
02163                                    const ValueType *values );
02164 
02175         typedef OtherValueType ( *getValue ) ( const IndexType i,
02176                                           const IndexType j,
02177                                           const IndexType numRows,
02178                                           const IndexType *ia,
02179                                           const IndexType *ja,
02180                                           const ValueType *values );
02181     };
02182 
02183     LAMA_INTERFACE_DEFINE_TT( Getter , getRow )
02184     LAMA_INTERFACE_DEFINE_TT( Getter, getValue )
02185 
02186     struct Operations
02187     {
02188         typedef IndexType ( *countNonEmptyRowsBySizes ) ( const IndexType sizes[],
02189                                                           const IndexType numRows );
02190 
02191         typedef void ( *setNonEmptyRowsBySizes ) (  IndexType rowIndexes[],
02192                                                     const IndexType numNonEmptyRows,
02193                                                     const IndexType sizes[],
02194                                                     const IndexType numRows );
02195 
02196         typedef bool ( *hasDiagonalProperty ) ( const IndexType numDiagonals,
02197                                                         const IndexType ellJA[] );
02198 
02199         typedef void ( *check ) ( const IndexType mNumRows,
02200                                   const IndexType mNumValuesPerRow,
02201                                   const IndexType mNumColumns,
02202                                   const IndexType *ia,
02203                                   const IndexType *ja,
02204                                   const char* msg );
02205     };
02206 
02207     LAMA_INTERFACE_DEFINE( Operations, countNonEmptyRowsBySizes )
02208     LAMA_INTERFACE_DEFINE( Operations, setNonEmptyRowsBySizes )
02209     LAMA_INTERFACE_DEFINE( Operations, hasDiagonalProperty )
02210     LAMA_INTERFACE_DEFINE( Operations, check )
02211 
02214     template<typename ValueType>
02215     struct Mult
02216     {
02229         typedef void ( *normalGEMV ) ( ValueType result[],
02230                                        const ValueType alpha,
02231                                        const ValueType x[],
02232                                        const ValueType beta,
02233                                        const ValueType y[],
02234                                        const IndexType numRows,
02235                                        const IndexType numNonZerosPerRows,
02236                                        const IndexType ellIA[],
02237                                        const IndexType ellJA[],
02238                                        const ValueType ellValues[],
02239                                        class SyncToken* syncToken );
02240 
02255         typedef void ( *sparseGEMV ) ( ValueType result[],
02256                                        const IndexType numRows,
02257                                        const IndexType numNonZerosPerRows,
02258                                        const ValueType alpha,
02259                                        const ValueType x[],
02260                                        const IndexType numNonZeroRows,
02261                                        const IndexType rowIndexes[],
02262                                        const IndexType ellIA[],
02263                                        const IndexType ellJA[],
02264                                        const ValueType ellValues[],
02265                                        class SyncToken* syncToken );
02266     };
02267 
02268     LAMA_INTERFACE_DEFINE_T( Mult, normalGEMV )
02269     LAMA_INTERFACE_DEFINE_T( Mult, sparseGEMV )
02270 
02271 
02272     template<typename ValueType, typename OtherValueType>
02273     struct Scale
02274     {
02275         typedef void ( *scaleValue ) ( const IndexType numRows,
02276                                        const IndexType Ia[],
02277                                        ValueType mValues[],
02278                                        const OtherValueType values[] );
02279     };
02280 
02281     LAMA_INTERFACE_DEFINE_TT( Scale, scaleValue )
02282 
02283 
02284     template<typename ValueType>
02285     struct MatrixTimesMatrix
02286     {
02299         typedef void ( *computeIA ) ( const IndexType aIA[],
02300                                       const IndexType aJA[],
02301                                       const IndexType aNumRows,
02302                                       const IndexType bIA[],
02303                                       const IndexType bJA[],
02304                                       const IndexType bNumRows,
02305                                       IndexType cIA[] );
02306 
02322         typedef void ( *computeValues ) ( const IndexType aIA[],
02323                                           const IndexType aJA[],
02324                                           const ValueType aValues[],
02325                                           const IndexType aNumRows,
02326                                           const IndexType bIA[],
02327                                           const IndexType bJA[],
02328                                           const ValueType bValues[],
02329                                           const IndexType bNumRows,
02330                                           const ValueType alpha,
02331                                           const IndexType cIA[],
02332                                           IndexType cJA[],
02333                                           ValueType cValues[] );
02334 
02347         typedef void ( *addComputeIA ) ( const IndexType aIA[],
02348                                          const IndexType aJA[],
02349                                          const IndexType aNumRows,
02350                                          const IndexType bIA[],
02351                                          const IndexType bJA[],
02352                                          const IndexType bNumRows,
02353                                          IndexType cIA[] );
02354 
02370         typedef void ( *addComputeValues ) ( const IndexType aIA[],
02371                                              const IndexType aJA[],
02372                                              const ValueType aValues[],
02373                                              const IndexType aNumRows,
02374                                              const IndexType bIA[],
02375                                              const IndexType bJA[],
02376                                              const ValueType bValues[],
02377                                              const IndexType bNumRows,
02378                                              const ValueType beta,
02379                                              const IndexType cIA[],
02380                                              IndexType cJA[],
02381                                              ValueType cValues[] );
02382 
02383     };
02384 
02385     LAMA_INTERFACE_DEFINE_T( MatrixTimesMatrix, computeIA )
02386     LAMA_INTERFACE_DEFINE_T( MatrixTimesMatrix, computeValues )
02387     LAMA_INTERFACE_DEFINE_T( MatrixTimesMatrix, addComputeIA )
02388     LAMA_INTERFACE_DEFINE_T( MatrixTimesMatrix, addComputeValues )
02389 
02390     ELLUtilsInterface ();
02391 
02392 };
02393 
02400 struct JDSUtilsInterface
02401 {
02403     template<typename ValueType>
02404     struct Solver
02405     {
02411        typedef void ( *jacobi ) ( ValueType* const solution,
02412                                   const IndexType numRows,
02413                                   const IndexType jdsPerm[],
02414                                   const IndexType jdsIlg[],
02415                                   const IndexType jdsNumDiagonals,
02416                                   const IndexType jdsDlg[],
02417                                   const IndexType jdsJA[],
02418                                   const ValueType jdsValues[],
02419                                   const ValueType oldSolution[],
02420                                   const ValueType rhs[],
02421                                   const ValueType omega,
02422                                   class SyncToken* syncToken );
02423 
02426         typedef void ( *jacobiHalo ) ( ValueType solution[],
02427                                        const IndexType numRows,
02428                                        const ValueType invDiagonal[],
02429                                        const IndexType numDiagonals,
02430                                        const IndexType jdsHaloPerm[],
02431                                        const IndexType jdsHaloIlg[],
02432                                        const IndexType jdsHaloDlg[],
02433                                        const IndexType jdsHaloJA[],
02434                                        const ValueType jdsHaloValues[],
02435                                        const ValueType oldSolution[],
02436                                        const ValueType omega,
02437                                        class SyncToken* syncToken );
02438     };
02439 
02440     LAMA_INTERFACE_DEFINE_T( Solver, jacobi )
02441     LAMA_INTERFACE_DEFINE_T( Solver, jacobiHalo )
02442 
02443     struct Sort
02444     {
02460         typedef void ( *sortRows ) ( IndexType array[],
02461                                      IndexType perm[],
02462                                      const IndexType n );
02463 
02478         typedef void ( *setInversePerm ) ( IndexType inversePerm[],
02479                                            const IndexType perm[],
02480                                            const IndexType n );
02481 
02501          typedef IndexType ( *ilg2dlg ) ( IndexType dlg[], const IndexType numDiagonals,
02502                                           const IndexType ilg[], const IndexType numRows );
02503 
02504     };
02505 
02506     LAMA_INTERFACE_DEFINE( Sort, sortRows )
02507     LAMA_INTERFACE_DEFINE( Sort, setInversePerm )
02508     LAMA_INTERFACE_DEFINE( Sort, ilg2dlg )
02509 
02510     template<typename JDSValueType, typename CSRValueType>
02511     struct Conversions
02512     {
02526         typedef void ( *getCSRValues ) ( IndexType csrJA[],
02527                                          CSRValueType csrValues[],
02528                                          const IndexType csrIA[],
02529                                          const IndexType numRows,
02530                                          const IndexType jdsPerm[],
02531                                          const IndexType jdsILG[],
02532                                          const IndexType jdsDLG[],
02533                                          const IndexType jdsJA[],
02534                                          const JDSValueType jdsValues[] );
02535 
02549         typedef void( *setCSRValues ) ( IndexType jdsJA[],
02550                                         JDSValueType jdsValues[],
02551                                         const IndexType numRows,
02552                                         const IndexType jdsPerm[],
02553                                         const IndexType jdsILG[],
02554                                         const IndexType jdsDLG[],
02555                                         const IndexType csrIA[],
02556                                         const IndexType csrJA[],
02557                                         const CSRValueType csrValues[] );
02558     };
02559 
02560     // Define tables ( indexed by template value types) for all methods
02561 
02562     LAMA_INTERFACE_DEFINE_TT( Conversions, setCSRValues )
02563     LAMA_INTERFACE_DEFINE_TT( Conversions, getCSRValues )
02564 
02565     template<typename ValueType>
02566     struct Mult
02567     {
02581         typedef void ( *normalGEMV ) ( ValueType result[],
02582                                        const ValueType alpha,
02583                                        const ValueType x[],
02584                                        const ValueType beta,
02585                                        const ValueType y[],
02586                                        const IndexType numRows,
02587                                        const IndexType jdsPerm[],
02588                                        const IndexType jdsILG[],
02589                                        const IndexType ndlg,
02590                                        const IndexType jdsDLG[],
02591                                        const IndexType jdsJA[],
02592                                        const ValueType jdsValues[],
02593                                        class SyncToken* syncToken );
02594     };
02595 
02596     LAMA_INTERFACE_DEFINE_T( Mult, normalGEMV )
02597 
02598     template<typename ValueType>
02599     struct Operations
02600     {
02601         typedef void ( *setDiagonalWithScalar ) ( const IndexType numDiagonal,
02602                                                   ValueType values[],
02603                                                   Scalar scalar );
02604     };
02605 
02606     LAMA_INTERFACE_DEFINE_T( Operations, setDiagonalWithScalar )
02607 
02608     template<typename ValueType, typename OtherValueType>
02609     struct Getter
02610     {
02611         typedef void ( *getRow ) ( OtherValueType row[],
02612                                    const IndexType i,
02613                                    const IndexType numColumns,
02614                                    const IndexType numRows,
02615                                    const IndexType perm[],
02616                                    const IndexType ilg[],
02617                                    const IndexType dlg[],
02618                                    const IndexType ja[],
02619                                    const ValueType values[] );
02620 
02621         typedef ValueType (*getValue ) ( const IndexType i,
02622                                          const IndexType j,
02623                                          const IndexType numRows,
02624                                          const IndexType* dlg,
02625                                          const IndexType* ilg,
02626                                          const IndexType* perm,
02627                                          const IndexType* ja,
02628                                          const ValueType* values );
02629 
02630     };
02631 
02632     LAMA_INTERFACE_DEFINE_TT( Getter, getRow )
02633     LAMA_INTERFACE_DEFINE_TT( Getter, getValue )
02634 
02635     template<typename ValueType, typename OtherValueType>
02636     struct Scale
02637     {
02638         typedef void ( *scaleValue ) ( const IndexType numRows,
02639                                        const IndexType perm[],
02640                                        const IndexType ilg[],
02641                                        const IndexType dlg[],
02642                                        ValueType mValues[],
02643                                        const OtherValueType values[] );
02644     };
02645 
02646     LAMA_INTERFACE_DEFINE_TT( Scale, scaleValue )
02647 
02648     struct Helper
02649     {
02650         typedef bool ( *checkDiagonalProperty ) ( const IndexType numDiagonals,
02651                                                   const IndexType numRows,
02652                                                   const IndexType numColumns,
02653                                                   const IndexType perm[],
02654                                                   const IndexType ja[],
02655                                                   const IndexType dlg[] );
02656 
02657         typedef bool ( *check ) ( const IndexType numRows,
02658                                   const IndexType numValues,
02659                                   const IndexType numColumns,
02660                                   const IndexType ja[],
02661                                   const IndexType ilg[],
02662                                   const IndexType dlg[] );
02663     };
02664 
02665     LAMA_INTERFACE_DEFINE( Helper, checkDiagonalProperty )
02666     LAMA_INTERFACE_DEFINE( Helper, check )
02667 
02668     JDSUtilsInterface ();
02669 };
02670 
02677 struct DIAUtilsInterface
02678 {
02679     template<typename ValueType>
02680     struct Counting
02681     {
02701         typedef void ( *getCSRSizes ) ( IndexType csrSizes[],
02702                                         bool diagonalFlag,
02703                                         const IndexType numRows,
02704                                         const IndexType numColumns,
02705                                         const IndexType numDiagonals,
02706                                         const IndexType diaOffsets[],
02707                                         const ValueType diaValues[],
02708                                         const ValueType eps );
02709 
02710     };
02711 
02712     LAMA_INTERFACE_DEFINE_T( Counting, getCSRSizes )
02713 
02714     template<typename DIAValueType, typename CSRValueType>
02715     struct Conversions
02716     {
02733         typedef void ( *getCSRValues ) ( IndexType csrJA[],
02734                                          CSRValueType csrValues[],
02735                                          const IndexType csrIA[],
02736                                          const bool diagonalFlag,
02737                                          const IndexType numRows,
02738                                          const IndexType numColumns,
02739                                          const IndexType numDiagonals,
02740                                          const IndexType diaOffsets[],
02741                                          const DIAValueType diaValues[],
02742                                          const DIAValueType eps );
02743     };
02744 
02745     LAMA_INTERFACE_DEFINE_TT( Conversions, getCSRValues )
02746 
02747     template<typename ValueType>
02748     struct Mult
02749     {
02763         typedef void ( *normalGEMV ) ( ValueType result[],
02764                                        const ValueType alpha,
02765                                        const ValueType x[],
02766                                        const ValueType beta,
02767                                        const ValueType y[],
02768                                        const IndexType numRows,
02769                                        const IndexType numColumns,
02770                                        const IndexType numDiagonals,
02771                                        const IndexType diaOffsets[],
02772                                        const ValueType diaValues[],
02773                                        class SyncToken* syncToken );
02774     };
02775 
02776     LAMA_INTERFACE_DEFINE_T( Mult, normalGEMV )
02777 
02778     
02780     template<typename ValueType>
02781     struct Solver
02782     {
02788        typedef void ( *jacobi ) ( ValueType* const solution,
02789                                   const IndexType numColumns,
02790                                   const IndexType numDiagonals,
02791                                   const IndexType diaOffset[],
02792                                   const ValueType diaValues[],
02793                                   const ValueType oldSolution[],
02794                                   const ValueType rhs[],
02795                                   const ValueType omega,
02796                                   const IndexType numRows,
02797                                   class SyncToken* syncToken );
02798     };
02799 
02800     LAMA_INTERFACE_DEFINE_T( Solver, jacobi )
02801 
02802     
02804     DIAUtilsInterface ();
02805 };
02806 
02813 struct COOUtilsInterface
02814 {
02815     struct Counting
02816     {
02825         typedef void ( *getCSRSizes )( IndexType csrSizes[],
02826                                        const IndexType numRows,
02827                                        const IndexType numValues,
02828                                        const IndexType cooIA[] );
02829     };
02830 
02831     LAMA_INTERFACE_DEFINE( Counting, getCSRSizes )
02832 
02833     template<typename COOValueType, typename CSRValueType>
02834     struct Conversions
02835     {
02848         typedef void ( *getCSRValues )( IndexType csrJA[],
02849                                         CSRValueType csrValues[],
02850                                         IndexType csrIA[],
02851                                         const IndexType numRow,
02852                                         const IndexType numValues,
02853                                         const IndexType cooIA[],
02854                                         const IndexType cooJA[],
02855                                         const COOValueType cooValues[] );
02856 
02869         typedef void ( *setCSRValues ) ( IndexType cooIA[],
02870                                          IndexType cooJA[],
02871                                          COOValueType cooValues[],
02872                                          const IndexType numRows,
02873                                          const IndexType numDiagonals,
02874                                          const IndexType csrIA[],
02875                                          const IndexType csrJA[],
02876                                          const CSRValueType csrValues[],
02877                                          const bool csrDiagonalProperty );
02878     };
02879 
02880     LAMA_INTERFACE_DEFINE_TT( Conversions, getCSRValues )
02881     LAMA_INTERFACE_DEFINE_TT( Conversions, setCSRValues )
02882 
02883     template<typename ValueType>
02884     struct Mult
02885     {
02899         typedef void ( *normalGEMV ) ( ValueType result[],
02900                                        const ValueType alpha,
02901                                        const ValueType x[],
02902                                        const ValueType beta,
02903                                        const ValueType y[],
02904                                        const IndexType numRows,
02905                                        const IndexType cooIA[],
02906                                        const IndexType cooJA[],
02907                                        const ValueType cooValues[],
02908                                        const IndexType numValues,
02909                                        class SyncToken* syncToken );
02910     };
02911 
02912     LAMA_INTERFACE_DEFINE_T( Mult, normalGEMV )
02913 
02914     
02915     template<typename ValueType>
02916     struct Solver
02917     {
02923        typedef void ( *jacobi ) ( ValueType* const solution,
02924                                   const IndexType cooNumValues,
02925                                   const IndexType cooIA[],
02926                                   const IndexType cooJA[],
02927                                   const ValueType cooValues[],
02928                                   const ValueType oldSolution[],
02929                                   const ValueType rhs[],
02930                                   const ValueType omega,
02931                                   const IndexType numRows,
02932                                   class SyncToken* syncToken );
02933 
02939         typedef void ( *jacobiHalo ) ( ValueType solution[],
02940                                        const ValueType diaValues[],
02941                                        const IndexType haloIA[],
02942                                        const IndexType haloJA[],
02943                                        const ValueType haloValues[],
02944                                        const IndexType haloRowIndexes[],
02945                                        const ValueType oldSolution[],
02946                                        const ValueType omega,
02947                                        const IndexType numNonEmptyRows );
02948     };
02949 
02950     LAMA_INTERFACE_DEFINE_T( Solver, jacobi )
02951     LAMA_INTERFACE_DEFINE_T( Solver, jacobiHalo )
02952 
02955     COOUtilsInterface ();
02956 };
02957 
02968 class LAMA_DLL_IMPORTEXPORT LAMAInterface : public Printable
02969 {
02970 public:
02971 
02972     LAMAInterface();
02973 
02974     virtual ~LAMAInterface();
02975 
02979     virtual void writeAt( std::ostream& stream ) const;
02980 
02985     template<typename T> 
02986     const BLAS1Interface<T>& getBLAS1Interface() const;
02987 
02988     template<typename T>
02989     const BLAS2Interface<T>& getBLAS2Interface() const;
02990 
02991     template<typename T>
02992     const BLAS3Interface<T>& getBLAS3Interface() const;
02993 
02994     template<typename T>
02995     const LAPACKInterface<T>& getLAPACKInterface() const;
02996 
02997     template<typename T>
02998     const SCALAPACKInterface<T>& getSCALAPACKInterface() const;
02999 
03000     CSRUtilsInterface CSRUtils;
03001     DenseUtilsInterface DenseUtils;
03002     ELLUtilsInterface ELLUtils;
03003     JDSUtilsInterface JDSUtils;
03004     DIAUtilsInterface DIAUtils;
03005     COOUtilsInterface COOUtils;
03006 
03007     UtilsInterface Utils;
03008 
03009 protected:
03010 
03011     BLAS1Interface<float>     mFloatBLAS1Interface;
03012     BLAS2Interface<float>     mFloatBLAS2Interface;
03013     BLAS3Interface<float>     mFloatBLAS3Interface;
03014     LAPACKInterface<float>    mFloatLAPACKInterface;
03015     SCALAPACKInterface<float> mFloatSCALAPACKInterface;
03016 
03017     BLAS1Interface<double>     mDoubleBLAS1Interface;
03018     BLAS2Interface<double>     mDoubleBLAS2Interface;
03019     BLAS3Interface<double>     mDoubleBLAS3Interface;
03020     LAPACKInterface<double>    mDoubleLAPACKInterface;
03021     SCALAPACKInterface<double> mDoubleSCALAPACKInterface;
03022 
03023     LAMA_LOG_DECL_STATIC_LOGGER(logger);
03024 };
03025 
03026 } //namespace lama
03027 
03028 #endif // LAMA_LAMA_INTERFACE_HPP_