imate
C++/CUDA Reference
cblas_interface.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3  * SPDX-License-Identifier: BSD-3-Clause
4  * SPDX-FileType: SOURCE
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the license found in the LICENSE.txt file in the root
8  * directory of this source tree.
9  */
10 
11 
12 #ifndef _C_BASIC_ALGEBRA_CBLAS_INTERFACE_H_
13 #define _C_BASIC_ALGEBRA_CBLAS_INTERFACE_H_
14 
15 
16 // =======
17 // Headers
18 // =======
19 
20 #include "../_definitions/definitions.h" // USE_CBLAS
21 
22 #if (USE_CBLAS == 1)
23 
24 #include <cblas.h> // CBLAS_LAYOUT, CBLAS_TRANSPOSE, cblas_sgemv, cblas_dgemv,
25  // cblas_scopy, cblas_dcopy, cblas_saxpy, cblas_daxpy,
26  // cblas_snrm2, cblas_dnrm2, cblas_sscal, cblas_dscal
27 
28 typedef CBLAS_ORDER CBLAS_LAYOUT; // backward compatibility with CBLAS_LAYOUT
29 
30 
31 // ===============
32 // cblas interface
33 // ===============
34 
38 
39 namespace cblas_interface
40 {
41  // cblas xgemv
42  template <typename DataType>
43  void xgemv(
44  CBLAS_LAYOUT layout,
45  CBLAS_TRANSPOSE TransA,
46  const int M,
47  const int N,
48  const DataType alpha,
49  const DataType* A,
50  const int lda,
51  const DataType* X,
52  const int incX,
53  const DataType beta,
54  DataType* Y,
55  const int incY);
56 
57  // cblas xcopy
58  template <typename DataType>
59  void xcopy(
60  const int N,
61  const DataType* X,
62  const int incX,
63  DataType* Y,
64  const int incY);
65 
66  // cblas xaxpy
67  template <typename DataType>
68  void xaxpy(
69  const int N,
70  const DataType alpha,
71  const DataType* X,
72  const int incX,
73  DataType* Y,
74  const int incY);
75 
76  // cblas xdot
77  template <typename DataType>
78  DataType xdot(
79  const int N,
80  const DataType* X,
81  const int incX,
82  const DataType* Y,
83  const int incY);
84 
85  // cblas xnrm2
86  template <typename DataType>
87  DataType xnrm2(
88  const int N,
89  const DataType* X,
90  const int incX);
91 
92  // cblas xscal
93  template <typename DataType>
94  void xscal(
95  const int N,
96  const DataType alpha,
97  DataType* X,
98  const int incX);
99 
100 } // namespace cblas_interface
101 
102 #endif // USE_CBLAS
103 #endif // _C_BASIC_ALGEBRA_CBLAS_INTERFACE_H_