votca
2024.2-dev
Loading...
Searching...
No Matches
xtp
src
libxtp
cudapipeline.cc
Go to the documentation of this file.
1
/*
2
* Copyright 2009-2020 The VOTCA Development Team
3
* (http://www.votca.org)
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License")
6
*
7
* You may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
*Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*
18
*/
19
20
// Local VOTCA includes
21
#include "
votca/xtp/cudapipeline.h
"
22
#include <stdexcept>
23
#include <string>
24
25
namespace
votca
{
26
namespace
xtp {
27
28
CudaPipeline::~CudaPipeline
() {
29
30
// destroy handle
31
cublasDestroy(
handle_
);
32
// destroy stream
33
cudaStreamDestroy(
stream_
);
34
}
35
36
void
CudaPipeline::axpy
(
const
CudaMatrix
&A,
CudaMatrix
&B,
37
double
alpha)
const
{
38
39
if
(A.
rows
() != B.
rows
() || A.
cols
() != B.
cols
()) {
40
throw
std::runtime_error(
"Shape mismatch in cuda axpy"
);
41
}
42
43
cublasSetStream(
handle_
,
stream_
);
44
cublasStatus_t status =
45
cublasDaxpy(
handle_
,
int
(A.
size
()), &alpha, A.
data
(), 1, B.
data
(), 1);
46
47
if
(status != CUBLAS_STATUS_SUCCESS) {
48
throw
std::runtime_error(
"axpy failed on gpu "
+ std::to_string(
deviceID_
) +
49
" with errorcode:"
+
cudaGetErrorEnum
(status));
50
}
51
}
52
53
}
// namespace xtp
54
}
// namespace votca
votca::xtp::CudaMatrix
Definition
cudamatrix.h:104
votca::xtp::CudaMatrix::cols
Index cols() const
Definition
cudamatrix.h:109
votca::xtp::CudaMatrix::rows
Index rows() const
Definition
cudamatrix.h:107
votca::xtp::CudaMatrix::data
double * data() const
Definition
cudamatrix.h:110
votca::xtp::CudaMatrix::size
Index size() const
Definition
cudamatrix.h:106
votca::xtp::CudaPipeline::~CudaPipeline
~CudaPipeline()
Definition
cudapipeline.cc:28
votca::xtp::CudaPipeline::axpy
void axpy(const CudaMatrix &A, CudaMatrix &B, double alpha=1.0) const
Definition
cudapipeline.cc:36
votca::xtp::CudaPipeline::deviceID_
int deviceID_
Definition
cudapipeline.h:76
votca::xtp::CudaPipeline::handle_
cublasHandle_t handle_
Definition
cudapipeline.h:78
votca::xtp::CudaPipeline::stream_
cudaStream_t stream_
Definition
cudapipeline.h:82
cudapipeline.h
votca::xtp::cudaGetErrorEnum
std::string cudaGetErrorEnum(cublasStatus_t error)
Definition
cudamatrix.cc:39
votca
base class for all analysis tools
Definition
basebead.h:33
Generated by
1.12.0