32 #ifndef MCKL_INTERNAL_CBLAS_HPP 33 #define MCKL_INTERNAL_CBLAS_HPP 39 #if MCKL_USE_MKL_CBLAS 40 #include <mkl_cblas.h> 42 #define MCKL_BLAS_INT MKL_INT 49 #define MCKL_BLAS_INT int 56 using ::CblasColMajor;
57 using ::CblasRowMajor;
59 using ::CblasConjTrans;
94 #else // MCKL_USE_CBLAS 96 #ifndef MCKL_BLAS_NAME 97 #ifdef MCKL_BLAS_NAME_NO_UNDERSCORE 98 #define MCKL_BLAS_NAME(x) x 100 #define MCKL_BLAS_NAME(x) x##_ 104 #ifndef MCKL_BLAS_INT 105 #define MCKL_BLAS_INT int 110 void MCKL_BLAS_NAME(sgemv)(
const char *trans,
const MCKL_BLAS_INT *m,
115 void MCKL_BLAS_NAME(dgemv)(
const char *trans,
const MCKL_BLAS_INT *m,
116 const MCKL_BLAS_INT *n,
const double *alpha,
const double *a,
120 void MCKL_BLAS_NAME(stpmv)(
const char *uplo,
const char *trans,
121 const char *diag,
const MCKL_BLAS_INT *n,
const float *ap,
float *x,
124 void MCKL_BLAS_NAME(dtpmv)(
const char *uplo,
const char *trans,
125 const char *diag,
const MCKL_BLAS_INT *n,
const double *ap,
double *x,
128 void MCKL_BLAS_NAME(ssyr)(
const char *uplo,
const MCKL_BLAS_INT *n,
129 const float *alpha,
const float *x,
const MCKL_BLAS_INT *incx,
float *a,
132 void MCKL_BLAS_NAME(dsyr)(
const char *uplo,
const MCKL_BLAS_INT *n,
133 const double *alpha,
const double *x,
const MCKL_BLAS_INT *incx,
double *a,
136 void MCKL_BLAS_NAME(strmm)(
const char *side,
const char *uplo,
137 const char *transa,
const char *diag,
const MCKL_BLAS_INT *m,
141 void MCKL_BLAS_NAME(dtrmm)(
const char *side,
const char *uplo,
142 const char *transa,
const char *diag,
const MCKL_BLAS_INT *m,
143 const MCKL_BLAS_INT *n,
const double *alpha,
const double *a,
146 void MCKL_BLAS_NAME(ssyrk)(
const char *uplo,
const char *trans,
148 const float *a,
const MCKL_BLAS_INT *lda,
const float *beta,
float *c,
151 void MCKL_BLAS_NAME(dsyrk)(
const char *uplo,
const char *trans,
153 const double *a,
const MCKL_BLAS_INT *lda,
const double *beta,
double *c,
162 enum CBLAS_LAYOUT { CblasRowMajor = 101, CblasColMajor = 102 };
164 using CBLAS_ORDER = CBLAS_LAYOUT;
166 enum CBLAS_TRANSPOSE {
172 enum CBLAS_UPLO { CblasUpper = 121, CblasLower = 122 };
174 enum CBLAS_DIAG { CblasNonUnit = 131, CblasUnit = 132 };
176 enum CBLAS_SIDE { CblasLeft = 141, CblasRight = 142 };
178 inline char cblas_trans(
const CBLAS_LAYOUT layout,
const CBLAS_TRANSPOSE trans)
180 if (layout == CblasColMajor) {
181 if (trans == CblasNoTrans)
183 else if (trans == CblasTrans)
185 else if (trans == CblasConjTrans)
188 if (layout == CblasRowMajor) {
189 if (trans == CblasNoTrans)
191 else if (trans == CblasTrans)
193 else if (trans == CblasConjTrans)
199 inline char cblas_uplo(
const CBLAS_LAYOUT layout,
const CBLAS_UPLO uplo)
201 if (layout == CblasColMajor) {
202 if (uplo == CblasUpper)
204 if (uplo == CblasLower)
207 if (layout == CblasRowMajor) {
208 if (uplo == CblasUpper)
210 if (uplo == CblasLower)
216 inline char cblas_diag(
const CBLAS_DIAG diag)
218 if (diag == CblasUnit)
220 if (diag == CblasNonUnit)
225 inline char cblas_side(
const CBLAS_LAYOUT layout,
const CBLAS_SIDE side)
227 if (layout == CblasColMajor) {
228 if (side == CblasLeft)
230 if (side == CblasRight)
233 if (layout == CblasRowMajor) {
234 if (side == CblasLeft)
236 if (side == CblasRight)
242 inline float cblas_sdot(
const MCKL_BLAS_INT n,
const float *x,
252 inline double cblas_ddot(
const MCKL_BLAS_INT n,
const double *x,
262 inline void cblas_sgemv(
const CBLAS_LAYOUT layout,
const CBLAS_TRANSPOSE trans,
268 const char transf = cblas_trans(layout, trans);
269 MCKL_BLAS_NAME(sgemv)
270 (&transf, &m, &n, &alpha, a, &lda, x, &incx, &beta, y, &incy);
273 inline void cblas_dgemv(
const CBLAS_LAYOUT layout,
const CBLAS_TRANSPOSE trans,
279 const char transf = cblas_trans(layout, trans);
280 MCKL_BLAS_NAME(dgemv)
281 (&transf, &m, &n, &alpha, a, &lda, x, &incx, &beta, y, &incy);
284 inline void cblas_stpmv(
const CBLAS_LAYOUT layout,
const CBLAS_UPLO uplo,
285 const CBLAS_TRANSPOSE trans,
const CBLAS_DIAG diag,
const MCKL_BLAS_INT n,
288 const char uplof = cblas_uplo(layout, uplo);
289 const char transf = cblas_trans(layout, trans);
290 const char diagf = cblas_diag(diag);
291 MCKL_BLAS_NAME(stpmv)(&uplof, &transf, &diagf, &n, ap, x, &incx);
294 inline void cblas_dtpmv(CBLAS_LAYOUT layout,
const CBLAS_UPLO uplo,
295 const CBLAS_TRANSPOSE trans,
const CBLAS_DIAG diag,
const MCKL_BLAS_INT n,
298 const char uplof = cblas_uplo(layout, uplo);
299 const char transf = cblas_trans(layout, trans);
300 const char diagf = cblas_diag(diag);
301 MCKL_BLAS_NAME(dtpmv)(&uplof, &transf, &diagf, &n, ap, x, &incx);
304 inline void cblas_ssyr(
const CBLAS_LAYOUT layout,
const CBLAS_UPLO uplo,
308 const char uplof = cblas_uplo(layout, uplo);
309 MCKL_BLAS_NAME(ssyr)(&uplof, &n, &alpha, x, &incx, a, &lda);
312 inline void cblas_dsyr(
const CBLAS_LAYOUT layout,
const CBLAS_UPLO uplo,
316 const char uplof = cblas_uplo(layout, uplo);
317 MCKL_BLAS_NAME(dsyr)(&uplof, &n, &alpha, x, &incx, a, &lda);
320 inline void cblas_strmm(
const CBLAS_LAYOUT layout,
const CBLAS_SIDE side,
321 const CBLAS_UPLO uplo,
const CBLAS_TRANSPOSE trans,
const CBLAS_DIAG diag,
325 const char sidef = cblas_side(layout, side);
326 const char uplof = cblas_uplo(layout, uplo);
327 const char transf = cblas_trans(CblasColMajor, trans);
328 const char diagf = cblas_diag(diag);
329 MCKL_BLAS_NAME(strmm)
330 (&sidef, &uplof, &transf, &diagf, &m, &n, &alpha, a, &lda, b, &ldb);
333 inline void cblas_dtrmm(
const CBLAS_LAYOUT layout,
const CBLAS_SIDE side,
334 const CBLAS_UPLO uplo,
const CBLAS_TRANSPOSE trans,
const CBLAS_DIAG diag,
339 const char sidef = cblas_side(layout, side);
340 const char uplof = cblas_uplo(layout, uplo);
341 const char transf = cblas_trans(CblasColMajor, trans);
342 const char diagf = cblas_diag(diag);
343 MCKL_BLAS_NAME(dtrmm)
344 (&sidef, &uplof, &transf, &diagf, &m, &n, &alpha, a, &lda, b, &ldb);
347 inline void cblas_ssyrk(
const CBLAS_LAYOUT layout,
const CBLAS_UPLO uplo,
352 const char uplof = cblas_uplo(layout, uplo);
353 const char transf = cblas_trans(layout, trans);
354 MCKL_BLAS_NAME(ssyrk)
355 (&uplof, &transf, &n, &k, &alpha, a, &lda, &beta, c, &ldc);
358 inline void cblas_dsyrk(
const CBLAS_LAYOUT layout,
const CBLAS_UPLO uplo,
360 const double alpha,
const double *a,
const MCKL_BLAS_INT lda,
363 const char uplof = cblas_uplo(layout, uplo);
364 const char transf = cblas_trans(layout, trans);
365 MCKL_BLAS_NAME(dsyrk)
366 (&uplof, &transf, &n, &k, &alpha, a, &lda, &beta, c, &ldc);
373 #endif // MCKL_USE_CBLAS 375 #endif // MCKL_INTERNAL_CBLAS_HPP