mgcpp
A C++ Math Library Based on CUDA
cublas.hpp
Go to the documentation of this file.
1 
2 // Copyright RedPortal, mujjingun 2017 - 2018.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef _MGCPP_CUDA_LIBS_CUBLAS_HPP_
8 #define _MGCPP_CUDA_LIBS_CUBLAS_HPP_
9 
10 #include <cstdlib>
11 
12 #include <mgcpp/system/outcome.hpp>
13 
14 #include <cublas_v2.h>
15 
16 namespace mgcpp {
17 namespace cublas {
18 // lv1
19 template <typename T>
20 outcome::result<void> dot(cublasHandle_t handle,
21  size_t n,
22  T const* x,
23  size_t incx,
24  T const* y,
25  size_t incy,
26  T* result) noexcept;
27 
28 template <typename T>
29 outcome::result<void> axpy(cublasHandle_t handle,
30  size_t n,
31  T const* alpha,
32  T const* x,
33  size_t incx,
34  T* y,
35  size_t incy) noexcept;
36 
37 template <typename VectorType, typename ScalarType>
38 outcome::result<void> scal(cublasHandle_t handle,
39  size_t n,
40  ScalarType const* alpha,
41  VectorType* vec,
42  size_t incvec) noexcept;
43 
44 // lv2
45 
64 template <typename T>
65 outcome::result<void> gemv(cublasHandle_t handle,
66  cublasOperation_t trans,
67  int m,
68  int n,
69  T const* alpha,
70  T const* A,
71  int lda,
72  T const* x,
73  int incx,
74  T const* beta,
75  T* y,
76  int incy);
77 
79 template <typename T>
80 outcome::result<void> ger(cublasHandle_t handle,
81  size_t m,
82  size_t n,
83  T const* alpha,
84  T const* x,
85  size_t incx,
86  T const* y,
87  size_t incy,
88  T* A,
89  int lda);
90 
91 // lv3
92 
93 template <typename T>
94 outcome::result<void> gemm(cublasHandle_t handle,
95  cublasOperation_t transa,
96  cublasOperation_t transb,
97  size_t m,
98  size_t n,
99  size_t k,
100  T const* alpha,
101  T const* A,
102  size_t lda,
103  T const* B,
104  size_t ldb,
105  T const* beta,
106  T* C,
107  size_t ldc) noexcept;
108 
109 template <typename T>
110 outcome::result<void> gemm_batched(cublasHandle_t handle,
111  cublasOperation_t transa,
112  cublasOperation_t transb,
113  size_t m,
114  size_t n,
115  size_t k,
116  T const* alpha,
117  T const* A,
118  size_t lda,
119  T const* B,
120  size_t ldb,
121  T const* beta,
122  T* C,
123  size_t ldc) noexcept;
124 
125 // blas-like cublas extensions
126 
127 template <typename T>
128 outcome::result<void> geam(cublasHandle_t handle,
129  cublasOperation_t transa,
130  cublasOperation_t transb,
131  size_t m,
132  size_t n,
133  const T* alpha,
134  const T* A,
135  size_t lda,
136  const T* beta,
137  const T* B,
138  size_t ldb,
139  T* C,
140  size_t ldc) noexcept;
141 } // namespace cublas
142 } // namespace mgcpp
143 #endif
outcome::result< void > scal(cublasHandle_t handle, size_t n, ScalarType const *alpha, VectorType *vec, size_t incvec) noexcept
outcome::result< void > geam(cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, size_t m, size_t n, const T *alpha, const T *A, size_t lda, const T *beta, const T *B, size_t ldb, T *C, size_t ldc) noexcept
Definition: adapter_base.hpp:12
outcome::result< void > gemm(cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, size_t m, size_t n, size_t k, T const *alpha, T const *A, size_t lda, T const *B, size_t ldb, T const *beta, T *C, size_t ldc) noexcept
outcome::result< void > gemm_batched(cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, size_t m, size_t n, size_t k, T const *alpha, T const *A, size_t lda, T const *B, size_t ldb, T const *beta, T *C, size_t ldc) noexcept
outcome::result< void > ger(cublasHandle_t handle, size_t m, size_t n, T const *alpha, T const *x, size_t incx, T const *y, size_t incy, T *A, int lda)
This function performs the rank-1 update.
outcome::result< void > gemv(cublasHandle_t handle, cublasOperation_t trans, int m, int n, T const *alpha, T const *A, int lda, T const *x, int incx, T const *beta, T *y, int incy)
dmat_trans_expr< Expr > trans(dmat_expr< Expr > const &expr) noexcept
BOOST_OUTCOME_V2_NAMESPACE::std_result< R > result
Definition: outcome.hpp:8
outcome::result< void > dot(cublasHandle_t handle, size_t n, T const *x, size_t incx, T const *y, size_t incy, T *result) noexcept
outcome::result< void > axpy(cublasHandle_t handle, size_t n, T const *alpha, T const *x, size_t incx, T *y, size_t incy) noexcept