Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
detail/device/MVmultiply.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2009 NVIDIA Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <cusp/format.h>
20#include <cusp/csr_matrix.h>
21#include <cusp/detail/functional.h>
22#include <iostream>
23
24// SpMM
27
28#include "Teuchos_TimeMonitor.hpp"
29
30namespace cusp
31{
32namespace detail
33{
34namespace device
35{
36
38// Sparse Matrix-BlockVector Multiply //
40template <typename Matrix,
41 typename Vector1,
42 typename Vector2>
43void MVmultiply(const Matrix& A,
44 const Vector1& B,
45 Vector2& C,
46 cusp::sparse_format,
47 cusp::array2d_format,
48 cusp::array2d_format
49 )
50{
51 TEUCHOS_FUNC_TIME_MONITOR("CUSP Matrix block-apply");
53 cudaDeviceSynchronize();
54}
55
57// Sparse Matrix-BlockVector Multiply //
59template <typename Matrix,
60 typename Vector1,
61 typename Vector2>
62void OVmultiply(const Matrix& A,
63 const Vector1& B,
64 Vector2& C,
65 cusp::sparse_format,
66 cusp::array2d_format,
67 cusp::array2d_format
68 )
69{
70 TEUCHOS_FUNC_TIME_MONITOR("CUSP Operator block-apply");
72 cudaDeviceSynchronize();
73}
74
78template <typename Matrix1,
79 typename Matrix2,
80 typename Matrix3>
81void MVmultiply(const Matrix1& A,
82 const Matrix2& B,
83 Matrix3& C,
84 cusp::array2d_format,
85 cusp::array1d_format,
86 cusp::array2d_format)
87{
88 TEUCHOS_FUNC_TIME_MONITOR("CUSP Dense-diag");
90 cudaDeviceSynchronize();
91}
92
94// 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
96
97
98template <typename MV,
99 typename MV1,
100 typename MV2>
101void MVdot(const MV& A,
102 const MV1& B,
103 MV2& C)
104{
105 TEUCHOS_FUNC_TIME_MONITOR("CUSP dot");
107 cudaDeviceSynchronize();
108}
109
113template <typename ValueType,
114 typename MV1,
115 typename MV2>
116void axpby(const ValueType& A, const MV1& X, const ValueType& B,
117 const MV1& Y,
118 MV2& Z)
119{
120 TEUCHOS_FUNC_TIME_MONITOR("CUSP axpby");
122 cudaDeviceSynchronize();
123}
124
125
127// Entry Point //
129template <typename Matrix,
130 typename MatrixOrVector1,
131 typename MatrixOrVector2>
132void MVmultiply(const Matrix& A,
133 const MatrixOrVector1& B,
134 MatrixOrVector2& C)
135{
137 typename Matrix::format(),
138 typename MatrixOrVector1::format(),
139 typename MatrixOrVector2::format());
140}
141
142template <typename Matrix,
143 typename MatrixOrVector1,
144 typename MatrixOrVector2>
145void OVmultiply(const Matrix& A,
146 const MatrixOrVector1& B,
147 MatrixOrVector2& C)
148{
150 typename Matrix::format(),
151 typename MatrixOrVector1::format(),
152 typename MatrixOrVector2::format());
153}
154
155} // end namespace device
156} // end namespace detail
157} // end namespace cusp
Kokkos::DefaultExecutionSpace device
void spmm_csr_vector(const Matrix &A, const Vector2 &x, Vector3 &y)
Definition: csr_vector.h:474
void MVdot(const MV &A, const MV1 &B, MV2 &C)
void spmm_MVdot(const Vector1 &A, const Vector2 &x, Vector3 &y)
Definition: array2d.h:473
void MVmultiply(const Matrix &A, const Vector1 &B, Vector2 &C, cusp::sparse_format, cusp::array2d_format, cusp::array2d_format)
void spmm_dense_diag(const Vector1 &A, const Vector2 &x, Vector3 &y)
Definition: array2d.h:484
void spmm_axpby(const ValueType &a, const Vector1 &x, const ValueType &b, const Vector1 &y, Vector2 &z)
Definition: array2d.h:495
void axpby(const ValueType &A, const MV1 &X, const ValueType &B, const MV1 &Y, MV2 &Z)
void OVmultiply(const Matrix &A, const Vector1 &B, Vector2 &C, cusp::sparse_format, cusp::array2d_format, cusp::array2d_format)