22
33void BlasConnector::axpy ( const int n, const float alpha, const float *X, const int incX, float *Y, const int incY, base_device::AbacusDevice_t device_type)
44{
5- if (device_type == base_device::AbacusDevice_t::CpuDevice)
5+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
66 saxpy_ (&n, &alpha, X, &incX, Y, &incY);
77}
8+ }
89
910void BlasConnector::axpy ( const int n, const double alpha, const double *X, const int incX, double *Y, const int incY, base_device::AbacusDevice_t device_type)
1011{
11- if (device_type == base_device::AbacusDevice_t::CpuDevice)
12+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
1213 daxpy_ (&n, &alpha, X, &incX, Y, &incY);
1314}
15+ }
1416
1517void BlasConnector::axpy ( const int n, const std::complex <float > alpha, const std::complex <float > *X, const int incX, std::complex <float > *Y, const int incY, base_device::AbacusDevice_t device_type)
1618{
17- if (device_type == base_device::AbacusDevice_t::CpuDevice)
19+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
1820 caxpy_ (&n, &alpha, X, &incX, Y, &incY);
1921}
22+ }
2023
2124void BlasConnector::axpy ( const int n, const std::complex <double > alpha, const std::complex <double > *X, const int incX, std::complex <double > *Y, const int incY, base_device::AbacusDevice_t device_type)
2225{
23- if (device_type == base_device::AbacusDevice_t::CpuDevice)
26+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
2427 zaxpy_ (&n, &alpha, X, &incX, Y, &incY);
2528}
29+ }
2630
2731
2832// x=a*x
2933void BlasConnector::scal ( const int n, const float alpha, float *X, const int incX, base_device::AbacusDevice_t device_type)
3034{
31- if (device_type == base_device::AbacusDevice_t::CpuDevice)
35+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
3236 sscal_ (&n, &alpha, X, &incX);
3337}
38+ }
3439
3540void BlasConnector::scal ( const int n, const double alpha, double *X, const int incX, base_device::AbacusDevice_t device_type)
3641{
37- if (device_type == base_device::AbacusDevice_t::CpuDevice)
42+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
3843 dscal_ (&n, &alpha, X, &incX);
3944}
45+ }
4046
4147void BlasConnector::scal ( const int n, const std::complex <float > alpha, std::complex <float > *X, const int incX, base_device::AbacusDevice_t device_type)
4248{
43- if (device_type == base_device::AbacusDevice_t::CpuDevice)
49+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
4450 cscal_ (&n, &alpha, X, &incX);
4551}
52+ }
4653
4754void BlasConnector::scal ( const int n, const std::complex <double > alpha, std::complex <double > *X, const int incX, base_device::AbacusDevice_t device_type)
4855{
49- if (device_type == base_device::AbacusDevice_t::CpuDevice)
56+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
5057 zscal_ (&n, &alpha, X, &incX);
5158}
59+ }
5260
5361
5462// d=x*y
5563float BlasConnector::dot ( const int n, const float *X, const int incX, const float *Y, const int incY, base_device::AbacusDevice_t device_type)
5664{
57- if (device_type == base_device::AbacusDevice_t::CpuDevice)
65+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
5866 return sdot_ (&n, X, &incX, Y, &incY);
5967}
68+ }
6069
6170double BlasConnector::dot ( const int n, const double *X, const int incX, const double *Y, const int incY, base_device::AbacusDevice_t device_type)
6271{
63- if (device_type == base_device::AbacusDevice_t::CpuDevice)
72+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
6473 return ddot_ (&n, X, &incX, Y, &incY);
6574}
75+ }
6676
6777// C = a * A.? * B.? + b * C
6878void BlasConnector::gemm (const char transa, const char transb, const int m, const int n, const int k,
6979 const float alpha, const float *a, const int lda, const float *b, const int ldb,
7080 const float beta, float *c, const int ldc, base_device::AbacusDevice_t device_type)
7181{
72- if (device_type == base_device::AbacusDevice_t::CpuDevice)
82+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
7383 sgemm_ (&transb, &transa, &n, &m, &k,
7484 &alpha, b, &ldb, a, &lda,
7585 &beta, c, &ldc);
7686}
87+ }
7788
7889void BlasConnector::gemm (const char transa, const char transb, const int m, const int n, const int k,
7990 const double alpha, const double *a, const int lda, const double *b, const int ldb,
8091 const double beta, double *c, const int ldc, base_device::AbacusDevice_t device_type)
8192{
82- if (device_type == base_device::AbacusDevice_t::CpuDevice)
93+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
8394 dgemm_ (&transb, &transa, &n, &m, &k,
8495 &alpha, b, &ldb, a, &lda,
8596 &beta, c, &ldc);
8697}
98+ }
8799
88100void BlasConnector::gemm (const char transa, const char transb, const int m, const int n, const int k,
89101 const std::complex <float > alpha, const std::complex <float > *a, const int lda, const std::complex <float > *b, const int ldb,
90102 const std::complex <float > beta, std::complex <float > *c, const int ldc, base_device::AbacusDevice_t device_type)
91103{
92- if (device_type == base_device::AbacusDevice_t::CpuDevice)
104+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
93105 cgemm_ (&transb, &transa, &n, &m, &k,
94106 &alpha, b, &ldb, a, &lda,
95107 &beta, c, &ldc);
96108}
109+ }
97110
98111void BlasConnector::gemm (const char transa, const char transb, const int m, const int n, const int k,
99112 const std::complex <double > alpha, const std::complex <double > *a, const int lda, const std::complex <double > *b, const int ldb,
100113 const std::complex <double > beta, std::complex <double > *c, const int ldc, base_device::AbacusDevice_t device_type)
101114{
102- if (device_type == base_device::AbacusDevice_t::CpuDevice)
115+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
103116 zgemm_ (&transb, &transa, &n, &m, &k,
104117 &alpha, b, &ldb, a, &lda,
105118 &beta, c, &ldc);
106119}
120+ }
107121
108122void BlasConnector::gemv (const char trans, const int m, const int n,
109123 const double alpha, const double * A, const int lda, const double * X, const int incx,
110124 const double beta, double * Y, const int incy, base_device::AbacusDevice_t device_type)
111125{
112- if (device_type == base_device::AbacusDevice_t::CpuDevice)
126+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
113127 dgemv_ (&trans, &m, &n, &alpha, A, &lda, X, &incx, &beta, Y, &incy);
114128}
129+ }
115130
116131void BlasConnector::gemv (const char trans, const int m, const int n,
117132 const std::complex <float > alpha, const std::complex <float > *A, const int lda, const std::complex <float > *X, const int incx,
118133 const std::complex <float > beta, std::complex <float > *Y, const int incy, base_device::AbacusDevice_t device_type)
119134{
120- if (device_type == base_device::AbacusDevice_t::CpuDevice)
135+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
121136 cgemv_ (&trans, &m, &n, &alpha, A, &lda, X, &incx, &beta, Y, &incy);
122137}
138+ }
123139
124140void BlasConnector::gemv (const char trans, const int m, const int n,
125141 const std::complex <double > alpha, const std::complex <double > *A, const int lda, const std::complex <double > *X, const int incx,
126142 const std::complex <double > beta, std::complex <double > *Y, const int incy, base_device::AbacusDevice_t device_type)
127143{
128- if (device_type == base_device::AbacusDevice_t::CpuDevice)
144+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
129145 zgemv_ (&trans, &m, &n, &alpha, A, &lda, X, &incx, &beta, Y, &incy);
130146}
147+ }
131148
132149
133150// out = ||x||_2
134151float BlasConnector::nrm2 ( const int n, const float *X, const int incX, base_device::AbacusDevice_t device_type )
135152{
136- if (device_type == base_device::AbacusDevice_t::CpuDevice)
153+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
137154 return snrm2_ ( &n, X, &incX );
138155}
156+ }
139157
140158
141159double BlasConnector::nrm2 ( const int n, const double *X, const int incX, base_device::AbacusDevice_t device_type )
142160{
143- if (device_type == base_device::AbacusDevice_t::CpuDevice)
161+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
144162 return dnrm2_ ( &n, X, &incX );
145163}
164+ }
146165
147166
148167double BlasConnector::nrm2 ( const int n, const std::complex <double > *X, const int incX, base_device::AbacusDevice_t device_type )
149168{
150- if (device_type == base_device::AbacusDevice_t::CpuDevice)
169+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
151170 return dznrm2_ ( &n, X, &incX );
152171}
172+ }
153173
154174// copies a into b
155175void BlasConnector::copy (const long n, const double *a, const int incx, double *b, const int incy, base_device::AbacusDevice_t device_type)
156176{
157- if (device_type == base_device::AbacusDevice_t::CpuDevice)
177+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
158178 dcopy_ (&n, a, &incx, b, &incy);
159179}
180+ }
160181
161182void BlasConnector::copy (const long n, const std::complex <double > *a, const int incx, std::complex <double > *b, const int incy, base_device::AbacusDevice_t device_type)
162183{
163- if (device_type == base_device::AbacusDevice_t::CpuDevice)
184+ if (device_type == base_device::AbacusDevice_t::CpuDevice) {
164185 zcopy_ (&n, a, &incx, b, &incy);
186+ }
165187}
0 commit comments