2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
// =================================================================================================
|
|
|
|
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
|
|
|
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
|
|
|
// width of 100 characters per line.
|
|
|
|
//
|
|
|
|
// Author(s):
|
|
|
|
// Cedric Nugteren <www.cedricnugteren.nl>
|
|
|
|
//
|
|
|
|
// This file contains the interface to the CLBlast BLAS routines. It also contains the definitions
|
|
|
|
// of the returned status codes and the layout and transpose types. This is the only header users
|
|
|
|
// of CLBlast should include and use.
|
|
|
|
//
|
|
|
|
// =================================================================================================
|
|
|
|
|
|
|
|
#ifndef CLBLAST_CLBLAST_H_
|
|
|
|
#define CLBLAST_CLBLAST_H_
|
|
|
|
|
|
|
|
#include <cstdlib> // For size_t
|
|
|
|
|
|
|
|
// Includes the normal OpenCL C header
|
|
|
|
#if defined(__APPLE__) || defined(__MACOSX)
|
|
|
|
#include <OpenCL/opencl.h>
|
|
|
|
#else
|
|
|
|
#include <CL/opencl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace clblast {
|
|
|
|
// =================================================================================================
|
|
|
|
|
|
|
|
// Status codes. These codes can be returned by functions declared in this header file. The error
|
|
|
|
// codes match either the standard OpenCL error codes or the clBLAS error codes.
|
|
|
|
enum class StatusCode {
|
|
|
|
|
|
|
|
// Status codes in common with the OpenCL standard
|
|
|
|
kSuccess = 0, // CL_SUCCESS
|
|
|
|
kTempBufferAllocFailure = -4, // CL_MEM_OBJECT_ALLOCATION_FAILURE
|
|
|
|
kBuildProgramFailure = -11, // CL_BUILD_PROGRAM_FAILURE: OpenCL compilation error
|
|
|
|
kInvalidBinary = -42, // CL_INVALID_BINARY
|
|
|
|
kInvalidKernel = -48, // CL_INVALID_KERNEL
|
|
|
|
kInvalidLocalNumDimensions = -53, // CL_INVALID_WORK_DIMENSION: Too many thread dimensions
|
|
|
|
kInvalidLocalThreadsTotal = -54, // CL_INVALID_WORK_GROUP_SIZE: Too many threads in total
|
|
|
|
kInvalidLocalThreadsDim = -55, // CL_INVALID_WORK_ITEM_SIZE: ... or for a specific dimension
|
|
|
|
kInvalidTempBufferSize = -61, // CL_INVALID_BUFFER_SIZE
|
|
|
|
|
|
|
|
// Status codes in common with the clBLAS library
|
|
|
|
kNotImplemented = -1024, // Routine or functionality not implemented yet
|
|
|
|
kInvalidMatrixA = -1022, // Matrix A is not a valid OpenCL buffer
|
|
|
|
kInvalidMatrixB = -1021, // Matrix B is not a valid OpenCL buffer
|
|
|
|
kInvalidMatrixC = -1020, // Matrix C is not a valid OpenCL buffer
|
|
|
|
kInvalidVectorX = -1019, // Vector X is not a valid OpenCL buffer
|
|
|
|
kInvalidVectorY = -1018, // Vector Y is not a valid OpenCL buffer
|
|
|
|
kInvalidDimension = -1017, // Dimensions M, N, and K have to be larger than zero
|
|
|
|
kInvalidLeadDimA = -1016, // LD of A is smaller than the matrix's first dimension
|
|
|
|
kInvalidLeadDimB = -1015, // LD of B is smaller than the matrix's first dimension
|
|
|
|
kInvalidLeadDimC = -1014, // LD of C is smaller than the matrix's first dimension
|
|
|
|
kInvalidIncrementX = -1013, // Increment of vector X cannot be zero
|
|
|
|
kInvalidIncrementY = -1012, // Increment of vector Y cannot be zero
|
|
|
|
kInsufficientMemoryA = -1011, // Matrix A's OpenCL buffer is too small
|
|
|
|
kInsufficientMemoryB = -1010, // Matrix B's OpenCL buffer is too small
|
|
|
|
kInsufficientMemoryC = -1009, // Matrix C's OpenCL buffer is too small
|
|
|
|
kInsufficientMemoryX = -1008, // Vector X's OpenCL buffer is too small
|
|
|
|
kInsufficientMemoryY = -1007, // Vector Y's OpenCL buffer is too small
|
|
|
|
|
|
|
|
// Custom additional status codes for CLBlast
|
|
|
|
kKernelLaunchError = -2048, // Problem occurred when enqueuing the kernel
|
|
|
|
kKernelRunError = -2047, // Problem occurred while running the kernel
|
|
|
|
kInvalidLocalMemUsage = -2046, // Not enough local memory available on this device
|
|
|
|
kNoHalfPrecision = -2045, // Half precision (16-bits) not supported by the device
|
|
|
|
kNoDoublePrecision = -2044, // Double precision (64-bits) not supported by the device
|
2015-09-14 16:57:00 +02:00
|
|
|
kInvalidVectorDot = -2043, // Vector dot is not a valid OpenCL buffer
|
|
|
|
kInsufficientMemoryDot = -2042, // Vector dot's OpenCL buffer is too small
|
2015-05-30 12:30:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Matrix layout and transpose types
|
2016-04-27 11:37:55 +02:00
|
|
|
enum class Layout { kRowMajor = 101, kColMajor = 102 };
|
|
|
|
enum class Transpose { kNo = 111, kYes = 112, kConjugate = 113 };
|
|
|
|
enum class Triangle { kUpper = 121, kLower = 122 };
|
|
|
|
enum class Diagonal { kNonUnit = 131, kUnit = 132 };
|
|
|
|
enum class Side { kLeft = 141, kRight = 142 };
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
// Precision scoped enum (values in bits)
|
|
|
|
enum class Precision { kHalf = 16, kSingle = 32, kDouble = 64,
|
|
|
|
kComplexSingle = 3232, kComplexDouble = 6464 };
|
|
|
|
|
|
|
|
// =================================================================================================
|
|
|
|
// BLAS level-1 (vector-vector) routines
|
2015-08-22 17:11:20 +02:00
|
|
|
// =================================================================================================
|
|
|
|
|
2016-03-30 17:32:13 +02:00
|
|
|
// Generate givens plane rotation: SROTG/DROTG
|
2016-03-30 16:17:16 +02:00
|
|
|
template <typename T>
|
2016-03-30 17:32:13 +02:00
|
|
|
StatusCode Rotg(cl_mem sa_buffer, const size_t sa_offset,
|
|
|
|
cl_mem sb_buffer, const size_t sb_offset,
|
|
|
|
cl_mem sc_buffer, const size_t sc_offset,
|
|
|
|
cl_mem ss_buffer, const size_t ss_offset,
|
2016-03-30 16:17:16 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
|
|
|
|
2016-03-30 17:32:13 +02:00
|
|
|
// Generate modified givens plane rotation: SROTMG/DROTMG
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Rotmg(cl_mem sd1_buffer, const size_t sd1_offset,
|
|
|
|
cl_mem sd2_buffer, const size_t sd2_offset,
|
|
|
|
cl_mem sx1_buffer, const size_t sx1_offset,
|
2016-04-02 07:36:39 +02:00
|
|
|
const cl_mem sy1_buffer, const size_t sy1_offset,
|
2016-03-30 17:32:13 +02:00
|
|
|
cl_mem sparam_buffer, const size_t sparam_offset,
|
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
|
|
|
|
|
|
|
// Apply givens plane rotation: SROT/DROT
|
2016-03-30 16:17:16 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Rot(const size_t n,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 17:32:13 +02:00
|
|
|
const T cos,
|
|
|
|
const T sin,
|
2016-03-30 16:17:16 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
|
|
|
|
2016-03-30 17:32:13 +02:00
|
|
|
// Apply modified givens plane rotation: SROTM/DROTM
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Rotm(const size_t n,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem sparam_buffer, const size_t sparam_offset,
|
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
|
|
|
|
2015-08-22 17:11:20 +02:00
|
|
|
// Swap two vectors: SSWAP/DSWAP/CSWAP/ZSWAP
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Swap(const size_t n,
|
2015-09-17 10:14:33 +02:00
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2015-08-22 17:11:20 +02:00
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-08-22 17:11:20 +02:00
|
|
|
|
|
|
|
// Vector scaling: SSCAL/DSCAL/CSCAL/ZSCAL
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Scal(const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2015-08-22 17:11:20 +02:00
|
|
|
// Vector copy: SCOPY/DCOPY/CCOPY/ZCOPY
|
2015-05-30 12:30:43 +02:00
|
|
|
template <typename T>
|
2015-08-22 17:11:20 +02:00
|
|
|
StatusCode Copy(const size_t n,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-08-22 17:11:20 +02:00
|
|
|
|
|
|
|
// Vector-times-constant plus vector: SAXPY/DAXPY/CAXPY/ZAXPY
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Axpy(const size_t n,
|
|
|
|
const T alpha,
|
2015-05-30 12:30:43 +02:00
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2015-09-14 16:57:00 +02:00
|
|
|
// Dot product of two vectors: SDOT/DDOT
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Dot(const size_t n,
|
|
|
|
cl_mem dot_buffer, const size_t dot_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-14 16:57:00 +02:00
|
|
|
|
|
|
|
// Dot product of two complex vectors: CDOTU/ZDOTU
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Dotu(const size_t n,
|
|
|
|
cl_mem dot_buffer, const size_t dot_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-14 16:57:00 +02:00
|
|
|
|
|
|
|
// Dot product of two complex vectors, one conjugated: CDOTC/ZDOTC
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Dotc(const size_t n,
|
|
|
|
cl_mem dot_buffer, const size_t dot_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-14 16:57:00 +02:00
|
|
|
|
2016-03-25 10:30:38 +01:00
|
|
|
// Euclidian norm of a vector: SNRM2/DNRM2/ScNRM2/DzNRM2
|
2016-03-25 10:00:40 +01:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Nrm2(const size_t n,
|
|
|
|
cl_mem nrm2_buffer, const size_t nrm2_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-31 06:37:56 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2016-03-25 10:00:40 +01:00
|
|
|
|
2016-04-14 05:44:49 +02:00
|
|
|
// Absolute sum of values in a vector: SASUM/DASUM/ScASUM/DzASUM
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Asum(const size_t n,
|
|
|
|
cl_mem asum_buffer, const size_t asum_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
|
|
|
|
2016-04-27 18:07:30 +02:00
|
|
|
// Sum of values in a vector (non-BLAS function): SSUM/DSUM/ScSUM/DzSUM
|
2016-04-27 17:06:19 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Sum(const size_t n,
|
2016-04-27 18:07:30 +02:00
|
|
|
cl_mem sum_buffer, const size_t sum_offset,
|
2016-04-27 17:06:19 +02:00
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
|
|
|
|
|
|
|
// Index of absolute maximum value in a vector: iSAMAX/iDAMAX/iCAMAX/iZAMAX
|
2016-04-21 05:11:33 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Amax(const size_t n,
|
|
|
|
cl_mem imax_buffer, const size_t imax_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2016-04-27 17:06:19 +02:00
|
|
|
|
2016-04-27 18:07:30 +02:00
|
|
|
// Index of maximum value in a vector (non-BLAS function): iSMAX/iDMAX/iCMAX/iZMAX
|
2016-04-27 17:06:19 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Max(const size_t n,
|
|
|
|
cl_mem imax_buffer, const size_t imax_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2016-04-21 05:11:33 +02:00
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
// =================================================================================================
|
|
|
|
// BLAS level-2 (matrix-vector) routines
|
2015-08-22 17:11:20 +02:00
|
|
|
// =================================================================================================
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2015-09-17 17:05:45 +02:00
|
|
|
// General matrix-vector multiplication: SGEMV/DGEMV/CGEMV/ZGEMV
|
2015-06-13 11:01:20 +02:00
|
|
|
template <typename T>
|
2015-06-30 07:36:11 +02:00
|
|
|
StatusCode Gemv(const Layout layout, const Transpose a_transpose,
|
2015-06-13 11:01:20 +02:00
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-07-31 17:35:42 +02:00
|
|
|
|
2015-09-17 17:05:45 +02:00
|
|
|
// General banded matrix-vector multiplication: SGBMV/DGBMV/CGBMV/ZGBMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Gbmv(const Layout layout, const Transpose a_transpose,
|
|
|
|
const size_t m, const size_t n, const size_t kl, const size_t ku,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Hermitian matrix-vector multiplication: CHEMV/ZHEMV
|
2015-07-31 17:35:42 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Hemv(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-06-13 11:01:20 +02:00
|
|
|
|
2015-09-17 17:05:45 +02:00
|
|
|
// Hermitian banded matrix-vector multiplication: CHBMV/ZHBMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Hbmv(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n, const size_t k,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Hermitian packed matrix-vector multiplication: CHPMV/ZHPMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Hpmv(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem ap_buffer, const size_t ap_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Symmetric matrix-vector multiplication: SSYMV/DSYMV
|
2015-07-31 17:13:41 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Symv(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-07-31 17:13:41 +02:00
|
|
|
|
2015-09-17 17:05:45 +02:00
|
|
|
// Symmetric banded matrix-vector multiplication: SSBMV/DSBMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Sbmv(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n, const size_t k,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Symmetric packed matrix-vector multiplication: SSPMV/DSPMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Spmv(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem ap_buffer, const size_t ap_offset,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const T beta,
|
|
|
|
cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Triangular matrix-vector multiplication: STRMV/DTRMV/CTRMV/ZTRMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Trmv(const Layout layout, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
|
|
|
const size_t n,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Triangular banded matrix-vector multiplication: STBMV/DTBMV/CTBMV/ZTBMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Tbmv(const Layout layout, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
|
|
|
const size_t n, const size_t k,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Triangular packed matrix-vector multiplication: STPMV/DTPMV/CTPMV/ZTPMV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Tpmv(const Layout layout, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
|
|
|
const size_t n,
|
|
|
|
const cl_mem ap_buffer, const size_t ap_offset,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Solves a triangular system of equations: STRSV/DTRSV/CTRSV/ZTRSV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Trsv(const Layout layout, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
|
|
|
const size_t n,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Solves a banded triangular system of equations: STBSV/DTBSV/CTBSV/ZTBSV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Tbsv(const Layout layout, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
|
|
|
const size_t n, const size_t k,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Solves a packed triangular system of equations: STPSV/DTPSV/CTPSV/ZTPSV
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Tpsv(const Layout layout, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
|
|
|
const size_t n,
|
|
|
|
const cl_mem ap_buffer, const size_t ap_offset,
|
|
|
|
cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// General rank-1 matrix update: SGER/DGER
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Ger(const Layout layout,
|
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// General rank-1 complex matrix update: CGERU/ZGERU
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Geru(const Layout layout,
|
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// General rank-1 complex conjugated matrix update: CGERC/ZGERC
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Gerc(const Layout layout,
|
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Hermitian rank-1 matrix update: CHER/ZHER
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Her(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Hermitian packed rank-1 matrix update: CHPR/ZHPR
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Hpr(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem ap_buffer, const size_t ap_offset,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Hermitian rank-2 matrix update: CHER2/ZHER2
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Her2(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Hermitian packed rank-2 matrix update: CHPR2/ZHPR2
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Hpr2(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem ap_buffer, const size_t ap_offset,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Symmetric rank-1 matrix update: SSYR/DSYR
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Syr(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Symmetric packed rank-1 matrix update: SSPR/DSPR
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Spr(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
cl_mem ap_buffer, const size_t ap_offset,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Symmetric rank-2 matrix update: SSYR2/DSYR2
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Syr2(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
|
|
|
// Symmetric packed rank-2 matrix update: SSPR2/DSPR2
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Spr2(const Layout layout, const Triangle triangle,
|
|
|
|
const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem x_buffer, const size_t x_offset, const size_t x_inc,
|
|
|
|
const cl_mem y_buffer, const size_t y_offset, const size_t y_inc,
|
|
|
|
cl_mem ap_buffer, const size_t ap_offset,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
// =================================================================================================
|
|
|
|
// BLAS level-3 (matrix-matrix) routines
|
2015-08-22 17:11:20 +02:00
|
|
|
// =================================================================================================
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2015-09-17 17:05:45 +02:00
|
|
|
// General matrix-matrix multiplication: SGEMM/DGEMM/CGEMM/ZGEMM
|
2015-05-30 12:30:43 +02:00
|
|
|
template <typename T>
|
2015-06-30 07:36:11 +02:00
|
|
|
StatusCode Gemm(const Layout layout, const Transpose a_transpose, const Transpose b_transpose,
|
2015-05-30 12:30:43 +02:00
|
|
|
const size_t m, const size_t n, const size_t k,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem b_buffer, const size_t b_offset, const size_t b_ld,
|
|
|
|
const T beta,
|
|
|
|
cl_mem c_buffer, const size_t c_offset, const size_t c_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Symmetric matrix-matrix multiplication: SSYMM/DSYMM/CSYMM/ZSYMM
|
2015-05-30 12:30:43 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Symm(const Layout layout, const Side side, const Triangle triangle,
|
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem b_buffer, const size_t b_offset, const size_t b_ld,
|
|
|
|
const T beta,
|
|
|
|
cl_mem c_buffer, const size_t c_offset, const size_t c_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-05-30 12:30:43 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Hermitian matrix-matrix multiplication: CHEMM/ZHEMM
|
2015-07-12 15:11:50 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Hemm(const Layout layout, const Side side, const Triangle triangle,
|
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem b_buffer, const size_t b_offset, const size_t b_ld,
|
|
|
|
const T beta,
|
|
|
|
cl_mem c_buffer, const size_t c_offset, const size_t c_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-07-12 15:11:50 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Rank-K update of a symmetric matrix: SSYRK/DSYRK/CSYRK/ZSYRK
|
2015-06-21 12:44:03 +02:00
|
|
|
template <typename T>
|
2015-06-30 07:36:11 +02:00
|
|
|
StatusCode Syrk(const Layout layout, const Triangle triangle, const Transpose a_transpose,
|
2015-06-21 12:44:03 +02:00
|
|
|
const size_t n, const size_t k,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2015-07-10 07:19:59 +02:00
|
|
|
const T beta,
|
|
|
|
cl_mem c_buffer, const size_t c_offset, const size_t c_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-07-10 07:19:59 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Rank-K update of a hermitian matrix: CHERK/ZHERK
|
2015-07-10 07:19:59 +02:00
|
|
|
template <typename T>
|
|
|
|
StatusCode Herk(const Layout layout, const Triangle triangle, const Transpose a_transpose,
|
|
|
|
const size_t n, const size_t k,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
2015-06-21 12:44:03 +02:00
|
|
|
const T beta,
|
|
|
|
cl_mem c_buffer, const size_t c_offset, const size_t c_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-06-21 12:44:03 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Rank-2K update of a symmetric matrix: SSYR2K/DSYR2K/CSYR2K/ZSYR2K
|
2015-06-21 12:44:03 +02:00
|
|
|
template <typename T>
|
2015-06-30 07:36:11 +02:00
|
|
|
StatusCode Syr2k(const Layout layout, const Triangle triangle, const Transpose ab_transpose,
|
2015-06-21 12:44:03 +02:00
|
|
|
const size_t n, const size_t k,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem b_buffer, const size_t b_offset, const size_t b_ld,
|
|
|
|
const T beta,
|
|
|
|
cl_mem c_buffer, const size_t c_offset, const size_t c_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-06-21 12:44:03 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Rank-2K update of a hermitian matrix: CHER2K/ZHER2K
|
2015-07-10 20:59:20 +02:00
|
|
|
template <typename T, typename U>
|
|
|
|
StatusCode Her2k(const Layout layout, const Triangle triangle, const Transpose ab_transpose,
|
|
|
|
const size_t n, const size_t k,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
const cl_mem b_buffer, const size_t b_offset, const size_t b_ld,
|
|
|
|
const U beta,
|
|
|
|
cl_mem c_buffer, const size_t c_offset, const size_t c_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-07-10 20:59:20 +02:00
|
|
|
|
2015-09-17 10:14:33 +02:00
|
|
|
// Triangular matrix-matrix multiplication: STRMM/DTRMM/CTRMM/ZTRMM
|
2015-06-30 07:36:11 +02:00
|
|
|
template <typename T>
|
2015-09-17 10:14:33 +02:00
|
|
|
StatusCode Trmm(const Layout layout, const Side side, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
2015-06-30 07:36:11 +02:00
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
cl_mem b_buffer, const size_t b_offset, const size_t b_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-06-30 07:36:11 +02:00
|
|
|
|
2015-09-17 17:05:45 +02:00
|
|
|
// Solves a triangular system of equations: STRSM/DTRSM/CTRSM/ZTRSM
|
|
|
|
template <typename T>
|
|
|
|
StatusCode Trsm(const Layout layout, const Side side, const Triangle triangle, const Transpose a_transpose, const Diagonal diagonal,
|
|
|
|
const size_t m, const size_t n,
|
|
|
|
const T alpha,
|
|
|
|
const cl_mem a_buffer, const size_t a_offset, const size_t a_ld,
|
|
|
|
cl_mem b_buffer, const size_t b_offset, const size_t b_ld,
|
2016-03-30 15:31:45 +02:00
|
|
|
cl_command_queue* queue, cl_event* event = nullptr);
|
2015-09-17 17:05:45 +02:00
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
// =================================================================================================
|
2016-04-27 16:02:13 +02:00
|
|
|
|
|
|
|
// CLBlast stores binaries of compiled kernels into a cache in case the same kernel is used later on
|
|
|
|
// for the same device. This cache can be cleared to free up system memory or in case of debugging.
|
2016-04-28 21:14:17 +02:00
|
|
|
StatusCode ClearCache();
|
2016-04-27 16:02:13 +02:00
|
|
|
|
|
|
|
// =================================================================================================
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
} // namespace clblast
|
|
|
|
|
|
|
|
// CLBLAST_CLBLAST_H_
|
|
|
|
#endif
|