Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
detail/device/MVmultiply.h
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 /*
11  * Copyright 2008-2009 NVIDIA Corporation
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  */
25 
26 #pragma once
27 
28 #include <cusp/format.h>
29 #include <cusp/csr_matrix.h>
30 #include <cusp/detail/functional.h>
31 #include <iostream>
32 
33 // SpMM
36 
37 #include "Teuchos_TimeMonitor.hpp"
38 
39 namespace cusp
40 {
41 namespace detail
42 {
43 namespace device
44 {
45 
47 // Sparse Matrix-BlockVector Multiply //
49 template <typename Matrix,
50  typename Vector1,
51  typename Vector2>
52 void MVmultiply(const Matrix& A,
53  const Vector1& B,
54  Vector2& C,
55  cusp::sparse_format,
56  cusp::array2d_format,
57  cusp::array2d_format
58  )
59 {
60  TEUCHOS_FUNC_TIME_MONITOR("CUSP Matrix block-apply");
62  cudaDeviceSynchronize();
63 }
64 
66 // Sparse Matrix-BlockVector Multiply //
68 template <typename Matrix,
69  typename Vector1,
70  typename Vector2>
71 void OVmultiply(const Matrix& A,
72  const Vector1& B,
73  Vector2& C,
74  cusp::sparse_format,
75  cusp::array2d_format,
76  cusp::array2d_format
77  )
78 {
79  TEUCHOS_FUNC_TIME_MONITOR("CUSP Operator block-apply");
81  cudaDeviceSynchronize();
82 }
83 
87 template <typename Matrix1,
88  typename Matrix2,
89  typename Matrix3>
90 void MVmultiply(const Matrix1& A,
91  const Matrix2& B,
92  Matrix3& C,
93  cusp::array2d_format,
94  cusp::array1d_format,
95  cusp::array2d_format)
96 {
97  TEUCHOS_FUNC_TIME_MONITOR("CUSP Dense-diag");
99  cudaDeviceSynchronize();
100 }
101 
103 // Dot Product: Computes C[i] = A[i] ^ T * B[i] where A[i] and B[i] are the i-th columns of A and B
105 
106 
107 template <typename MV,
108  typename MV1,
109  typename MV2>
110 void MVdot(const MV& A,
111  const MV1& B,
112  MV2& C)
113 {
114  TEUCHOS_FUNC_TIME_MONITOR("CUSP dot");
116  cudaDeviceSynchronize();
117 }
118 
122 template <typename ValueType,
123  typename MV1,
124  typename MV2>
125 void axpby(const ValueType& A, const MV1& X, const ValueType& B,
126  const MV1& Y,
127  MV2& Z)
128 {
129  TEUCHOS_FUNC_TIME_MONITOR("CUSP axpby");
131  cudaDeviceSynchronize();
132 }
133 
134 
136 // Entry Point //
138 template <typename Matrix,
139  typename MatrixOrVector1,
140  typename MatrixOrVector2>
141 void MVmultiply(const Matrix& A,
142  const MatrixOrVector1& B,
143  MatrixOrVector2& C)
144 {
146  typename Matrix::format(),
147  typename MatrixOrVector1::format(),
148  typename MatrixOrVector2::format());
149 }
150 
151 template <typename Matrix,
152  typename MatrixOrVector1,
153  typename MatrixOrVector2>
154 void OVmultiply(const Matrix& A,
155  const MatrixOrVector1& B,
156  MatrixOrVector2& C)
157 {
159  typename Matrix::format(),
160  typename MatrixOrVector1::format(),
161  typename MatrixOrVector2::format());
162 }
163 
164 } // end namespace device
165 } // end namespace detail
166 } // end namespace cusp
void spmm_MVdot(const Vector1 &A, const Vector2 &x, Vector3 &y)
Definition: array2d.h:482
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
void MVmultiply(const Matrix &A, const Vector1 &B, Vector2 &C, cusp::sparse_format, cusp::array2d_format, cusp::array2d_format)
void spmm_csr_vector(const Matrix &A, const Vector2 &x, Vector3 &y)
Definition: csr_vector.h:483
void OVmultiply(const Matrix &A, const Vector1 &B, Vector2 &C, cusp::sparse_format, cusp::array2d_format, cusp::array2d_format)
void spmm_axpby(const ValueType &a, const Vector1 &x, const ValueType &b, const Vector1 &y, Vector2 &z)
Definition: array2d.h:504
void spmm_dense_diag(const Vector1 &A, const Vector2 &x, Vector3 &y)
Definition: array2d.h:493
Kokkos::DefaultExecutionSpace device
void axpby(const ValueType &A, const MV1 &X, const ValueType &B, const MV1 &Y, MV2 &Z)
void MVdot(const MV &A, const MV1 &B, MV2 &C)