Compadre  1.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Compadre_LinearAlgebra_Declarations.hpp
Go to the documentation of this file.
1 #ifndef _COMPADRE_LINEAR_ALGEBRA_DECLARATIONS_HPP_
2 #define _COMPADRE_LINEAR_ALGEBRA_DECLARATIONS_HPP_
3 
4 #include "Compadre_Config.h"
5 #include "Compadre_Typedefs.hpp"
7 
8 #ifdef COMPADRE_USE_CUDA
9  #include <cuda_runtime.h>
10  #include <cublas_v2.h>
11  #include <cublas_api.h>
12  #include <cusolverDn.h>
13 #endif
14 
15 #ifdef COMPADRE_USE_LAPACK
16  extern "C" int dgels_( char* trans, int *m, int *n, int *k, double *a,
17  int *lda, double *c, int *ldc, double *work, int *lwork, int *info);
18 
19  extern "C" void dgelsd_( int* m, int* n, int* nrhs, double* a, int* lda,
20  double* b, int* ldb, double* s, double* rcond, int* rank,
21  double* work, int* lwork, int* iwork, int* info );
22 
23  // LU decomposition of a general matrix
24  extern "C" void dgetrf_( int* m, int* n, double* a,
25  int* lda, int* ipiv, int* info);
26 
27  // Solve a system of linear equations from LU decomposed matrix
28  extern "C" void dgetrs_( char* trans, int* n, int* nrhs, double* a, int* lda,
29  int* ipiv, double* b, int* ldb, int* info );
30 #endif // COMPADRE_USE_LAPACK
31 
32 namespace Compadre {
33 
34 namespace GMLS_LinearAlgebra {
35 
36  /*! \brief Creates a matrix M=A^T*A from a matrix A
37  \param teamMember [in] - Kokkos::TeamPolicy member type (created by parallel_for)
38  \param M_data [out] - result of weighted_P^T * weighted_P
39  \param weighted_P [in] - matrix to be multiplied by its transpose
40  \param columns [in] - number of columns in weighted_P
41  \param rows [in] - number of rows in weighted_P
42  */
43  KOKKOS_INLINE_FUNCTION
44  void createM(const member_type& teamMember, scratch_matrix_right_type M_data, scratch_matrix_right_type weighted_P, const int columns, const int rows);
45 
46  /*! \brief Calculates two eigenvectors corresponding to two dominant eigenvalues
47  \param teamMember [in] - Kokkos::TeamPolicy member type (created by parallel_for)
48  \param V [out] - dimension * dimension Kokkos View
49  \param PtP [in] - dimension * dimension Kokkos View
50  \param dimensions [in] - dimension of PtP
51  */
52  KOKKOS_INLINE_FUNCTION
53  void largestTwoEigenvectorsThreeByThreeSymmetric(const member_type& teamMember, scratch_matrix_right_type V, scratch_matrix_right_type PtP, const int dimensions, pool_type& random_number_pool);
54 
55  /*! \brief Calls LAPACK or CUBLAS to solve a batch of QR problems
56 
57  P contains num_matrices * lda * ndb data which is num_matrices different matrices, and
58  RHS contains num_matrices * ldn * ndb data which is num_matrices different matrix right hand sides.
59 
60  \param pm [in] - manager class for team and thread parallelism
61  \param P [in/out] - evaluation of sampling functional on polynomial basis (in), meaningless workspace output (out)
62  \param lda [in] - row dimension of each matrix in P
63  \param nda [in] - columns dimension of each matrix in P
64  \param RHS [in/out] - basis to invert P against (in), polynomial coefficients (out)
65  \param ldb [in] - row dimension of each matrix in RHS
66  \param ndb [in] - column dimension of each matrix in RHS
67  \param M [in] - number of rows containing data (maximum rows over everything in batch)
68  \param N [in] - number of columns containing data
69  \param num_matrices [in] - number of target (GMLS problems to be solved)
70  \param max_neighbors [in] - integer for maximum neighbor over all targets
71  \param neighbor_list_sizes [in] - pointer to all neighbor list sizes for each target
72  */
73  void batchQRFactorize(ParallelManager pm, double *P, int lda, int nda, double *RHS, int ldb, int ndb, int M, int N, int NRHS, const int num_matrices, const size_t max_neighbors = 0, const int initial_index_of_batch = 0, int * neighbor_list_sizes = NULL);
74 
75  /*! \brief Calls LAPACK or CUBLAS to solve a batch of SVD problems
76 
77  P contains num_matrices * lda * ndb data which is num_matrices different matrices, and
78  RHS contains num_matrices * ldn * ndb data which is num_matrices different matrix right hand sides.
79 
80  \param pm [in] - manager class for team and thread parallelism
81  \param swap_layout_P [in] - boolean to check if layout of P will need to be swapped or not
82  \param P [in/out] - evaluation of sampling functional on polynomial basis (in), meaningless workspace output (out)
83  \param lda [in] - row dimension of each matrix in P
84  \param nda [in] - columns dimension of each matrix in P
85  \param swap_layout_RHS [in] - boolean to check if layout of RHS will need to be swapped or not
86  \param RHS [in/out] - basis to invert P against (in), polynomial coefficients (out)
87  \param ldb [in] - row dimension of each matrix in RHS
88  \param ndb [in] - column dimension of each matrix in RHS
89  \param M [in] - number of rows containing data (maximum rows over everything in batch)
90  \param N [in] - number of columns containing data
91  \param num_matrices [in] - number of target (GMLS problems to be solved)
92  \param max_neighbors [in] - integer for maximum neighbor over all targets
93  \param neighbor_list_sizes [in] - pointer to all neighbor list sizes for each target
94  */
95  void batchSVDFactorize(ParallelManager pm, bool swap_layout_P, double *P, int lda, int nda, bool swap_layout_RHS, double *RHS, int ldb, int ndb, int M, int N, int NRHS, const int num_matrices, const size_t max_neighbors = 0, const int initial_index_of_batch = 0, int * neighbor_list_sizes = NULL);
96 
97  /*! \brief Calls LAPACK or CUBLAS to solve a batch of LU problems
98 
99  P contains num_matrices * lda * ndb data which is num_matrices different matrices, and
100  RHS contains num_matrices * ldn * ndb data which is num_matrices different matrix right hand sides.
101 
102  \param pm [in] - manager class for team and thread parallelism
103  \param P [in/out] - evaluation of sampling functional on polynomial basis (in), meaningless workspace output (out)
104  \param lda [in] - row dimension of each matrix in P
105  \param nda [in] - columns dimension of each matrix in P
106  \param RHS [in/out] - basis to invert P against (in), polynomial coefficients (out)
107  \param ldb [in] - row dimension of each matrix in RHS
108  \param ndb [in] - column dimension of each matrix in RHS
109  \param M [in] - number of rows containing data (maximum rows over everything in batch)
110  \param N [in] - number of columns containing data
111  \param num_matrices [in] - number of target (GMLS problems to be solved)
112  \param max_neighbors [in] - integer for maximum neighbor over all targets
113  \param neighbor_list_sizes [in] - pointer to all neighbor list sizes for each target
114  */
115  void batchLUFactorize(ParallelManager pm, double *P, int lda, int nda, double *RHS, int ldb, int ndb, int M, int N, int NRHS, const int num_matrices, const size_t max_neighbors = 0, const int initial_index_of_batch = 0, int * neighbor_list_sizes = NULL);
116 
117 } // GMLS_LinearAlgebra
118 } // Compadre
119 
120 #endif
team_policy::member_type member_type
KOKKOS_INLINE_FUNCTION void largestTwoEigenvectorsThreeByThreeSymmetric(const member_type &teamMember, scratch_matrix_right_type V, scratch_matrix_right_type PtP, const int dimensions, pool_type &random_number_pool)
Calculates two eigenvectors corresponding to two dominant eigenvalues.
void batchLUFactorize(ParallelManager pm, double *P, int lda, int nda, double *RHS, int ldb, int ndb, int M, int N, int NRHS, const int num_matrices, const size_t max_neighbors, const int initial_index_of_batch, int *neighbor_list_sizes)
Calls LAPACK or CUBLAS to solve a batch of LU problems.
Kokkos::View< double **, layout_right, Kokkos::MemoryTraits< Kokkos::Unmanaged > > scratch_matrix_right_type
void batchSVDFactorize(ParallelManager pm, bool swap_layout_P, double *P, int lda, int nda, bool swap_layout_RHS, double *RHS, int ldb, int ndb, int M, int N, int NRHS, const int num_matrices, const size_t max_neighbors, const int initial_index_of_batch, int *neighbor_list_sizes)
Calls LAPACK or CUBLAS to solve a batch of SVD problems.
void batchQRFactorize(ParallelManager pm, double *P, int lda, int nda, double *RHS, int ldb, int ndb, int M, int N, int NRHS, const int num_matrices, const size_t max_neighbors, const int initial_index_of_batch, int *neighbor_list_sizes)
Calls LAPACK or CUBLAS to solve a batch of QR problems.
Kokkos::Random_XorShift64_Pool pool_type
KOKKOS_INLINE_FUNCTION void createM(const member_type &teamMember, scratch_matrix_right_type M_data, scratch_matrix_right_type weighted_P, const int columns, const int rows)
Creates a matrix M=A^T*A from a matrix A.