votca 2024.1-dev
Loading...
Searching...
No Matches
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
22#include <stdexcept>
23#include <string>
24
25namespace votca {
26namespace xtp {
27
29
30 // destroy handle
31 cublasDestroy(handle_);
32 // destroy stream
33 cudaStreamDestroy(stream_);
34}
35
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
double * data() const
Definition cudamatrix.h:110
void axpy(const CudaMatrix &A, CudaMatrix &B, double alpha=1.0) const
std::string cudaGetErrorEnum(cublasStatus_t error)
Definition cudamatrix.cc:39
base class for all analysis tools
Definition basebead.h:33