From 871abf83f605f9aa7c2d7bac33e54f624a292088 Mon Sep 17 00:00:00 2001 From: Timmy Date: Wed, 14 Oct 2015 10:55:10 -0500 Subject: [PATCH 1/2] add clblas to ablas matrix helper api --- src/include/ablas.h | 19 +++++++++++++++++++ src/include/ablas_types.h | 13 +++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/include/ablas.h b/src/include/ablas.h index 21949ce81..75070dc8e 100644 --- a/src/include/ablas.h +++ b/src/include/ablas.h @@ -186,6 +186,25 @@ ablas_gemm( // const cl_event *eventWaitList, // cl_event *events); + +/**@{*/ +ABLAS_EXPORT ablas_status +clblas_2_ablas_init_matrix( + const ablas_precision *precision, + const ablas_order *order, + const ablas_transpose *trans, + const ablas_uplo *uplo, + const ablas_diag *diag, + const size_t *M, + const size_t *N, + const size_t *K, + size_t offset, + size_t ldX, + void *X, + ablas_matrix *ablas_X +); +/**@}*/ + #ifdef __cplusplus } // extern C #endif diff --git a/src/include/ablas_types.h b/src/include/ablas_types.h index abb73f190..e39b8791f 100644 --- a/src/include/ablas_types.h +++ b/src/include/ablas_types.h @@ -59,6 +59,19 @@ typedef enum ablas_side_ { } ablas_side; +/*! \brief Indicate the data order of a matrix. This is only used by the help function clblas_2_ablas_gemm */ +typedef enum ablas_order_{ + ablas_row_major, + ablas_column_major +} ablas_order; + +/*! \brief Indicate the transpose form of a matrix. This is only used by the help function clblas_2_ablas_gemm */ +typedef enum ablas_transpose_{ + ablas_no_trans, + ablas_trans, + ablas_conjugate_trans +}ablas_transpose; + /*! \brief Structure to encapsulate dense matrix/vector/scalar data to aBLAS API. * \details Able to store multiple matrices (or vectors, scalars) * to facilitate high-performance batched oprations; From ab1d04e1a8019a951214a269f18d5af6e025dd1a Mon Sep 17 00:00:00 2001 From: Timmy Date: Wed, 14 Oct 2015 13:42:11 -0500 Subject: [PATCH 2/2] some implementation of clblas_2_blas --- src/include/ablas.h | 15 +++++ src/library/clblas_2_ablas_intit.cpp | 87 ++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/library/clblas_2_ablas_intit.cpp diff --git a/src/include/ablas.h b/src/include/ablas.h index 75070dc8e..1a6a6175c 100644 --- a/src/include/ablas.h +++ b/src/include/ablas.h @@ -188,6 +188,21 @@ ablas_gemm( /**@{*/ +/*! \brief + * \defgroup BLAS Level 3 BLAS + * @param[in] precision single/double, real/complex. + * @param[in] order Row/column order. + * @param[in] trans How matrix is to be transposed. NULL if does not apply. + * @param[in] uplo The triangle in matrix being referenced. NULL if does not apply. + * @param[in] diag Specify whether matrix is unit triangular. NULL if does not apply. + * @param[in] M character for matrix A, C. NULL if does not apply. + * @param[in] N character for matrix B, C. NULL if does not apply. + * @param[in] K character for matrix A, B. NULL if does not apply. + * @param[in] offset Offset of the first element of the matrix. + * @param[in] ldX Leading dimension of matrix + * @param[in] X pointer to device memory + * @param[out] ablas_X pointer to a matrix struct. + */ ABLAS_EXPORT ablas_status clblas_2_ablas_init_matrix( const ablas_precision *precision, diff --git a/src/library/clblas_2_ablas_intit.cpp b/src/library/clblas_2_ablas_intit.cpp new file mode 100644 index 000000000..19631b619 --- /dev/null +++ b/src/library/clblas_2_ablas_intit.cpp @@ -0,0 +1,87 @@ +#include "ablas.h" + +ablas_status +clblas_2_ablas_init_matrix( + const ablas_precision *precision, + const ablas_order *order, + const ablas_transpose *trans, + const ablas_uplo *uplo, + const ablas_diag *diag, + const size_t *M, + const size_t *N, + const size_t *K, + size_t offset, + size_t ldX, + void *X, + ablas_matrix *ablas_X) +{ + //unfinished + if (ablas_X == NULL) + return -1;//throw some kind of error + + ablas_X->data = X; + ablas_X->precision = *precision; + ablas_X->offset = offset; + + if ((uplo == NULL) && (diag == NULL)) + { + //not a symmetric matrix + + if (*order == ablas_column_major) + { + if (N == NULL) + { + if (trans == NULL) + { + //matrix C does not have trans + ablas_X->num_cols = *M; + ablas_X->num_rows = *K; + ablas_X->num_matrices = 1; + ablas_X->col_stride = ldX; + ablas_X->row_stride = 1; + ablas_X->matrix_stride = ldX*(*K); + return 0; + } + else if (*trans == ablas_no_trans) + { + ablas_X->num_cols = *M; + ablas_X->num_rows = *K; + ablas_X->num_matrices = 1; + ablas_X->col_stride = ldX; + ablas_X->row_stride = 1; + ablas_X->matrix_stride = ldX*(*K); + return 0; + } + else if (*trans == ablas_trans) + { + ablas_X->num_cols = *K; + ablas_X->num_rows = *M; + ablas_X->num_matrices = 1; + ablas_X->col_stride = ldX; + ablas_X->row_stride = 1; + ablas_X->matrix_stride = ldX*(*M); + return 0; + } + else if (*trans == ablas_conjugate_trans) + { + } + } + else if (M == NULL) + { + } + else if (K == NULL) + { + } + else + { + //it would be confusing to have values for all M, N and K + return -1; + } + + } + + + + return -1; + } +} \ No newline at end of file