opm-simulators
vector_operations.hpp
1 /*
2  Copyright 2022-2023 SINTEF AS
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef OPM_CUISTL_VECTOR_OPERATIONS_HPP
20 #define OPM_CUISTL_VECTOR_OPERATIONS_HPP
21 
22 #include <cstddef>
23 #include <cublas_v2.h>
24 
25 namespace Opm::gpuistl::detail
26 {
27 
34 template <class T>
35 void setVectorValue(T* deviceData, size_t numberOfElements, const T& value);
36 
43 template <class T>
44 void setZeroAtIndexSet(T* deviceData, size_t numberOfElements, const int* indices);
45 
59 template <class T>
60 T innerProductAtIndices(cublasHandle_t cublasHandle, const T* deviceA, const T* deviceB, T* buffer, size_t numberOfElements, const int* indices);
61 
62 template <class T>
63 void prepareSendBuf(const T* deviceA, T* buffer, size_t numberOfElements, const int* indices);
64 template <class T>
65 void syncFromRecvBuf(T* deviceA, T* buffer, size_t numberOfElements, const int* indices);
66 
80 template <class T>
81 void weightedDiagMV(const T* squareBlockVector,
82  const size_t numberOfRows,
83  const size_t blocksize,
84  T relaxationFactor,
85  const T* srcVec,
86  T* dstVec);
87 
88 } // namespace Opm::gpuistl::detail
89 
90 #endif
void setVectorValue(T *deviceData, size_t numberOfElements, const T &value)
setVectorValue sets every element of deviceData to value
void weightedDiagMV(const T *squareBlockVector, const size_t numberOfRows, const size_t blocksize, T relaxationFactor, const T *srcVec, T *dstVec)
Compue the weighted matrix vector product where the matrix is diagonal, the diagonal is a vector...
void setZeroAtIndexSet(T *deviceData, size_t numberOfElements, const int *indices)
setZeroAtIndexSet sets deviceData to zero in the indices of contained in indices
T innerProductAtIndices(cublasHandle_t cublasHandle, const T *deviceA, const T *deviceB, T *buffer, size_t numberOfElements, const int *indices)
innerProductAtIndices computes the inner product between deviceA[indices] and deviceB[indices] ...
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading...
Definition: autotuner.hpp:29