blas.h (2014-04-30 15:38:09 -0400, (build fd32605))
Go to the documentation of this file.
1 //-----------------------------------------------------------------------//
2 // Copyright (c) AccelerEyes LLC. All rights reserved. //
3 // See http://www.accelereyes.com/eula for details. //
4 // This software is distributed WITHOUT ANY WARRANTY; without even //
5 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
6 // PURPOSE. See the above copyright notices for more information. //
7 //-----------------------------------------------------------------------//
8 
9 #pragma once
10 
11 #include "defines.h"
12 #include "constants.h"
13 
14 #ifdef __cplusplus
15  #define ZERO =0 // default: no batch/tiles
16 #else
17  #define ZERO
18 #endif
19 
20 namespace af {
21 
22  class array;
23 
110  template<typename ty> ty norm(const array& in, float p = af::NaN);
111 
137  template<typename ty> ty dot(const array& x, const array& y);
138 
139  AFAPI array dot(const array&x, const array& y);
140 
166  AFAPI array matmul(const array&, const array&,
168 
178  AFAPI array matmul(const array&, const array&, const array&);
179 
190  AFAPI array matmul(const array&, const array&, const array&, const array&);
191 
195 }
196 
197 #ifdef __cplusplus
198 extern "C" {
199 #endif
200 
226  // BLAS Level 3
228  AFAPI afError af_gemm_S(char TRANSA, char TRANSB, int M, int N, int K, float ALPHA, const float *d_A, int LDA, const float *d_B, int LDB, float BETA, float *d_C, int LDC, unsigned batch_A ZERO, unsigned batch_B ZERO);
230  AFAPI afError af_gemm_D(char TRANSA, char TRANSB, int M, int N, int K, double ALPHA, const double *d_A, int LDA, const double *d_B, int LDB, double BETA, double *d_C, int LDC, unsigned batch_A ZERO, unsigned batch_B ZERO);
232  AFAPI afError af_gemm_C(char TRANSA, char TRANSB, int M, int N, int K, cfloat ALPHA, const cfloat *d_A, int LDA, const cfloat *d_B, int LDB, cfloat BETA, cfloat *d_C, int LDC, unsigned batch_A ZERO, unsigned batch_B ZERO);
234  AFAPI afError af_gemm_Z(char TRANSA, char TRANSB, int M, int N, int K, cdouble ALPHA, const cdouble *d_A, int LDA, const cdouble *d_B, int LDB, cdouble BETA, cdouble *d_C, int LDC, unsigned batch_A ZERO, unsigned batch_B ZERO);
236  AFAPI afError af_matmul_SS(const float *d_A, const float *d_B,
237  float *d_C, int M, int N, int K,
238  unsigned batch_A ZERO, unsigned batch_B ZERO);
239  AFAPI afError af_matmul_DS(const double *d_A, const float *d_B,
240  float *d_C, int M, int N, int K,
241  unsigned batch_A ZERO, unsigned batch_B ZERO);
242  AFAPI afError af_matmul_SD(const float *d_A, const double *d_B,
243  float *d_C, int M, int N, int K,
244  unsigned batch_A ZERO, unsigned batch_B ZERO);
245  AFAPI afError af_matmul_DD(const double *d_A, const double *d_B,
246  double *d_C, int M, int N, int K,
247  unsigned batch_A ZERO, unsigned batch_B ZERO);
248  AFAPI afError af_matmul_CS(const cfloat *d_A, const float *d_B,
249  cfloat *d_C, int M, int N, int K,
250  unsigned batch_A ZERO, unsigned batch_B ZERO);
251  AFAPI afError af_matmul_ZS(const cdouble *d_A, const float *d_B,
252  cfloat *d_C, int M, int N, int K,
253  unsigned batch_A ZERO, unsigned batch_B ZERO);
254  AFAPI afError af_matmul_CD(const cfloat *d_A, const double *d_B,
255  cfloat *d_C, int M, int N, int K,
256  unsigned batch_A ZERO, unsigned batch_B ZERO);
257  AFAPI afError af_matmul_ZD(const cdouble *d_A, const double *d_B,
258  cdouble *d_C, int M, int N,
259  int K, unsigned batch_A ZERO,
260  unsigned batch_B ZERO);
261  AFAPI afError af_matmul_SC(const float *d_A, const cfloat *d_B,
262  cfloat *d_C, int M, int N, int K,
263  unsigned batch_A ZERO, unsigned batch_B ZERO);
264  AFAPI afError af_matmul_DC(const double *d_A, const cfloat *d_B,
265  cfloat *d_C, int M, int N, int K,
266  unsigned batch_A ZERO, unsigned batch_B ZERO);
267  AFAPI afError af_matmul_SZ(const float *d_A, const cdouble *d_B,
268  cfloat *d_C, int M, int N, int K,
269  unsigned batch_A ZERO, unsigned batch_B ZERO);
270  AFAPI afError af_matmul_DZ(const double *d_A, const cdouble *d_B,
271  cdouble *d_C, int M, int N,
272  int K, unsigned batch_A ZERO,
273  unsigned batch_B ZERO);
274  AFAPI afError af_matmul_CC(const cfloat *d_A, const cfloat *d_B,
275  cfloat *d_C, int M, int N, int K,
276  unsigned batch_A ZERO, unsigned batch_B ZERO);
277  AFAPI afError af_matmul_ZC(const cdouble *d_A,
278  const cfloat *d_B, cfloat *d_C,
279  int M, int N, int K,
280  unsigned batch_A ZERO, unsigned batch_B ZERO);
281  AFAPI afError af_matmul_CZ(const cfloat *d_A,
282  const cdouble *d_B,
283  cfloat *d_C, int M, int N, int K,
284  unsigned batch_A ZERO, unsigned batch_B ZERO);
285  AFAPI afError af_matmul_ZZ(const cdouble *d_A,
286  const cdouble *d_B,
287  cdouble *d_C, int M, int N,
288  int K, unsigned batch_A ZERO,
289  unsigned batch_B ZERO);
307  AFAPI afError af_norm_vector_S(float* h_dst,
309  unsigned numel, const float* d_src);
311  AFAPI afError af_norm_vector_D(double* h_dst,
312  unsigned numel, const double* d_src);
313 
315  AFAPI afError af_norm_S(float* d_dst,
316  unsigned ndims, const unsigned* dims,
317  const float* d_src, int dim);
319  AFAPI afError af_norm_D(double* d_dst,
320  unsigned ndims, const unsigned* dims,
321  const double* d_src, int dim);
340  AFAPI afError af_dot_S(float *h_res, unsigned len, const float *d_A,
341  const float *d_B);
342  AFAPI afError af_dot_D(double *h_res, unsigned len, const double *d_A,
343  const double *d_B);
344  AFAPI afError af_dot_C(cfloat *h_res, unsigned len,
345  const cfloat *d_A, const cfloat *d_B);
346  AFAPI afError af_dot_Z(cdouble *h_res, unsigned len,
347  const cdouble *d_A, const cdouble *d_B);
351 #undef ZERO
352 
353 #ifdef __cplusplus
354 }
355 #endif
afError af_gemm_D(char TRANSA, char TRANSB, int M, int N, int K, double ALPHA, const double *d_A, int LDA, const double *d_B, int LDB, double BETA, double *d_C, int LDC, unsigned batch_A=0, unsigned batch_B=0)
Double precision, Real matrix multiply.
#define ZERO
Definition: blas.h:15
afError af_matmul_ZD(const cdouble *d_A, const double *d_B, cdouble *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_gemm_S(char TRANSA, char TRANSB, int M, int N, int K, float ALPHA, const float *d_A, int LDA, const float *d_B, int LDB, float BETA, float *d_C, int LDC, unsigned batch_A=0, unsigned batch_B=0)
afError af_matmul_ZC(const cdouble *d_A, const cfloat *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_matmul_ZS(const cdouble *d_A, const float *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_matmul_CS(const cfloat *d_A, const float *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_norm_vector_D(double *h_dst, unsigned numel, const double *d_src)
norm The value of a double precision vector
afError af_matmul_SD(const float *d_A, const double *d_B, float *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
af_matprop_t
Definition: defines.h:4
afError af_matmul_DD(const double *d_A, const double *d_B, double *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_matmul_CZ(const cfloat *d_A, const cdouble *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_dot_Z(cdouble *h_res, unsigned len, const cdouble *d_A, const cdouble *d_B)
afError
Definition: defines.h:10
afError af_dot_D(double *h_res, unsigned len, const double *d_A, const double *d_B)
cuDoubleComplex cdouble
Definition: defines.h:109
const double NaN
representation for not-a-number
afError af_matmul_SS(const float *d_A, const float *d_B, float *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
Mixed precision, mixed complexity matrix multiply.
afError af_matmul_SC(const float *d_A, const cfloat *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_gemm_Z(char TRANSA, char TRANSB, int M, int N, int K, cdouble ALPHA, const cdouble *d_A, int LDA, const cdouble *d_B, int LDB, cdouble BETA, cdouble *d_C, int LDC, unsigned batch_A=0, unsigned batch_B=0)
Double precision, Complex matrix multiply.
afError af_norm_D(double *d_dst, unsigned ndims, const unsigned *dims, const double *d_src, int dim)
norm the value along a dimension in double precision matrix
afError af_matmul_DS(const double *d_A, const float *d_B, float *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_matmul_SZ(const float *d_A, const cdouble *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_matmul_ZZ(const cdouble *d_A, const cdouble *d_B, cdouble *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_norm_vector_S(float *h_dst, unsigned numel, const float *d_src)
afError af_gemm_C(char TRANSA, char TRANSB, int M, int N, int K, cfloat ALPHA, const cfloat *d_A, int LDA, const cfloat *d_B, int LDB, cfloat BETA, cfloat *d_C, int LDC, unsigned batch_A=0, unsigned batch_B=0)
Single precision, Complex matrix multiply.
afError af_dot_S(float *h_res, unsigned len, const float *d_A, const float *d_B)
afError af_matmul_CC(const cfloat *d_A, const cfloat *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
#define AFAPI
Definition: defines.h:45
afError af_matmul_DZ(const double *d_A, const cdouble *d_B, cdouble *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
afError af_matmul_DC(const double *d_A, const cfloat *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
array matmul(const array &, const array &, af_matprop_t=af_none, af_matprop_t=af_none)
Multiply two arrays together.
afError af_matmul_CD(const cfloat *d_A, const double *d_B, cfloat *d_C, int M, int N, int K, unsigned batch_A=0, unsigned batch_B=0)
ty norm(const array &in, float p=af::NaN)
Matrix or vector norm.
afError af_dot_C(cfloat *h_res, unsigned len, const cfloat *d_A, const cfloat *d_B)
cuFloatComplex cfloat
Definition: defines.h:108
Default.
Definition: defines.h:5
ty dot(const array &x, const array &y)
Scalar dot product between two vectors.
afError af_norm_S(float *d_dst, unsigned ndims, const unsigned *dims, const float *d_src, int dim)
norm the value along a dimension in single precision matrix