From 37ab62b7086359ab3ce7c551d82bdfd403dfb2f1 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Tue, 2 May 2017 11:29:13 -0500 Subject: [PATCH] Adding export definitions to hipblas header (#7) --- cmake/build-version.cmake | 4 +- library/include/hipblas.h | 80 +++++++++++++++++++------------------- library/src/CMakeLists.txt | 22 +++++++---- 3 files changed, 57 insertions(+), 49 deletions(-) diff --git a/cmake/build-version.cmake b/cmake/build-version.cmake index 1faca7272..9e390975a 100644 --- a/cmake/build-version.cmake +++ b/cmake/build-version.cmake @@ -19,7 +19,7 @@ macro( project_version ) endif( ) if( POLICY CMP0048 ) cmake_policy( SET CMP0048 NEW ) - project( ${PV_NAME} VERSION 0.1.0.0 LANGUAGES ${PV_LANGUAGES} ) + project( ${PV_NAME} VERSION 0.2.0.0 LANGUAGES ${PV_LANGUAGES} ) else( ) project( ${PV_NAME} ${PV_LANGUAGES} ) @@ -29,7 +29,7 @@ macro( project_version ) endif( ) if( NOT DEFINED ${PV_NAME}_VERSION_MINOR ) - set( ${PV_NAME}_VERSION_MINOR 1 ) + set( ${PV_NAME}_VERSION_MINOR 2 ) endif( ) if( NOT DEFINED ${PV_NAME}_VERSION_PATCH ) diff --git a/library/include/hipblas.h b/library/include/hipblas.h index 489461b7d..f99f25739 100644 --- a/library/include/hipblas.h +++ b/library/include/hipblas.h @@ -4,7 +4,7 @@ //! HIP = Heterogeneous-compute Interface for Portability //! -//! Define a extremely thin runtime layer that allows source code to be compiled unmodified +//! Define a extremely thin runtime layer that allows source code to be compiled unmodified //! through either AMD HCC or NVCC. Key features tend to be in the spirit //! and terminology of CUDA, but with a portable path to other accelerators as well. //! @@ -14,6 +14,8 @@ #define HIPBLAS_H #pragma once #include +#include "hipblas-export.h" +#include "hipblas-version.h" typedef void * hipblasHandle_t; @@ -27,7 +29,7 @@ enum hipblasStatus_t { HIPBLAS_STATUS_INTERNAL_ERROR, // an internal HIPBLAS operation failed HIPBLAS_STATUS_NOT_SUPPORTED // function not implemented }; - + enum hipblasOperation_t { HIPBLAS_OP_N, HIPBLAS_OP_T, @@ -38,56 +40,56 @@ enum hipblasOperation_t { extern "C" { #endif -hipblasStatus_t hipblasCreate(hipblasHandle_t* handle); +HIPBLAS_EXPORT hipblasStatus_t hipblasCreate(hipblasHandle_t* handle); -hipblasStatus_t hipblasDestroy(hipblasHandle_t handle); +HIPBLAS_EXPORT hipblasStatus_t hipblasDestroy(hipblasHandle_t handle); -hipblasStatus_t hipblasSetStream(hipblasHandle_t handle, hipStream_t streamId); +HIPBLAS_EXPORT hipblasStatus_t hipblasSetStream(hipblasHandle_t handle, hipStream_t streamId); -hipblasStatus_t hipblasGetStream(hipblasHandle_t handle, hipStream_t *streamId); +HIPBLAS_EXPORT hipblasStatus_t hipblasGetStream(hipblasHandle_t handle, hipStream_t *streamId); -hipblasStatus_t hipblasSetVector(int n, int elemSize, const void *x, int incx, void *y, int incy); +HIPBLAS_EXPORT hipblasStatus_t hipblasSetVector(int n, int elemSize, const void *x, int incx, void *y, int incy); -hipblasStatus_t hipblasGetVector(int n, int elemSize, const void *x, int incx, void *y, int incy); +HIPBLAS_EXPORT hipblasStatus_t hipblasGetVector(int n, int elemSize, const void *x, int incx, void *y, int incy); -hipblasStatus_t hipblasSetMatrix(int rows, int cols, int elemSize, const void *A, int lda, void *B, int ldb); +HIPBLAS_EXPORT hipblasStatus_t hipblasSetMatrix(int rows, int cols, int elemSize, const void *A, int lda, void *B, int ldb); -hipblasStatus_t hipblasGetMatrix(int rows, int cols, int elemSize, const void *A, int lda, void *B, int ldb); +HIPBLAS_EXPORT hipblasStatus_t hipblasGetMatrix(int rows, int cols, int elemSize, const void *A, int lda, void *B, int ldb); -hipblasStatus_t hipblasSasum(hipblasHandle_t handle, int n, const float *x, int incx, float *result); +HIPBLAS_EXPORT hipblasStatus_t hipblasSasum(hipblasHandle_t handle, int n, const float *x, int incx, float *result); -hipblasStatus_t hipblasDasum(hipblasHandle_t handle, int n, const double *x, int incx, double *result); +HIPBLAS_EXPORT hipblasStatus_t hipblasDasum(hipblasHandle_t handle, int n, const double *x, int incx, double *result); -hipblasStatus_t hipblasSasumBatched(hipblasHandle_t handle, int n, float *x, int incx, float *result, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasSasumBatched(hipblasHandle_t handle, int n, float *x, int incx, float *result, int batchCount); -hipblasStatus_t hipblasDasumBatched(hipblasHandle_t handle, int n, double *x, int incx, double *result, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasDasumBatched(hipblasHandle_t handle, int n, double *x, int incx, double *result, int batchCount); -hipblasStatus_t hipblasSaxpy(hipblasHandle_t handle, int n, const float *alpha, const float *x, int incx, float *y, int incy); +HIPBLAS_EXPORT hipblasStatus_t hipblasSaxpy(hipblasHandle_t handle, int n, const float *alpha, const float *x, int incx, float *y, int incy); -hipblasStatus_t hipblasDaxpy(hipblasHandle_t handle, int n, const double *alpha, const double *x, int incx, double *y, int incy) ; +HIPBLAS_EXPORT hipblasStatus_t hipblasDaxpy(hipblasHandle_t handle, int n, const double *alpha, const double *x, int incx, double *y, int incy) ; -hipblasStatus_t hipblasSaxpyBatched(hipblasHandle_t handle, int n, const float *alpha, const float *x, int incx, float *y, int incy, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasSaxpyBatched(hipblasHandle_t handle, int n, const float *alpha, const float *x, int incx, float *y, int incy, int batchCount); -hipblasStatus_t hipblasScopy(hipblasHandle_t handle, int n, const float *x, int incx, float *y, int incy); +HIPBLAS_EXPORT hipblasStatus_t hipblasScopy(hipblasHandle_t handle, int n, const float *x, int incx, float *y, int incy); -hipblasStatus_t hipblasDcopy(hipblasHandle_t handle, int n, const double *x, int incx, double *y, int incy); +HIPBLAS_EXPORT hipblasStatus_t hipblasDcopy(hipblasHandle_t handle, int n, const double *x, int incx, double *y, int incy); -hipblasStatus_t hipblasScopyBatched(hipblasHandle_t handle, int n, const float *x, int incx, float *y, int incy, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasScopyBatched(hipblasHandle_t handle, int n, const float *x, int incx, float *y, int incy, int batchCount); -hipblasStatus_t hipblasDcopyBatched(hipblasHandle_t handle, int n, const double *x, int incx, double *y, int incy, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasDcopyBatched(hipblasHandle_t handle, int n, const double *x, int incx, double *y, int incy, int batchCount); -hipblasStatus_t hipblasSdot (hipblasHandle_t handle, int n, const float *x, int incx, const float *y, int incy, float *result); +HIPBLAS_EXPORT hipblasStatus_t hipblasSdot (hipblasHandle_t handle, int n, const float *x, int incx, const float *y, int incy, float *result); -hipblasStatus_t hipblasDdot (hipblasHandle_t handle, int n, const double *x, int incx, const double *y, int incy, double *result); +HIPBLAS_EXPORT hipblasStatus_t hipblasDdot (hipblasHandle_t handle, int n, const double *x, int incx, const double *y, int incy, double *result); -hipblasStatus_t hipblasSdotBatched (hipblasHandle_t handle, int n, const float *x, int incx, const float *y, int incy, float *result, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasSdotBatched (hipblasHandle_t handle, int n, const float *x, int incx, const float *y, int incy, float *result, int batchCount); -hipblasStatus_t hipblasDdotBatched (hipblasHandle_t handle, int n, const double *x, int incx, const double *y, int incy, double *result, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasDdotBatched (hipblasHandle_t handle, int n, const double *x, int incx, const double *y, int incy, double *result, int batchCount); -hipblasStatus_t hipblasSscal(hipblasHandle_t handle, int n, const float *alpha, float *x, int incx); +HIPBLAS_EXPORT hipblasStatus_t hipblasSscal(hipblasHandle_t handle, int n, const float *alpha, float *x, int incx); -hipblasStatus_t hipblasDscal(hipblasHandle_t handle, int n, const double *alpha, double *x, int incx); +HIPBLAS_EXPORT hipblasStatus_t hipblasDscal(hipblasHandle_t handle, int n, const double *alpha, double *x, int incx); /* not implementes, requires complex support hipblasStatus_t hipblasCscal(hipblasHandle_t handle, int n, const hipComplex *alpha, hipComplex *x, int incx); @@ -95,29 +97,29 @@ hipblasStatus_t hipblasCscal(hipblasHandle_t handle, int n, const hipComplex *a hipblasStatus_t hipblasZscal(hipblasHandle_t handle, int n, const hipDoubleComplex *alpha, hipDoubleComplex *x, int incx); */ -hipblasStatus_t hipblasSscalBatched(hipblasHandle_t handle, int n, const float *alpha, float *x, int incx, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasSscalBatched(hipblasHandle_t handle, int n, const float *alpha, float *x, int incx, int batchCount); -hipblasStatus_t hipblasDscalBatched(hipblasHandle_t handle, int n, const double *alpha, double *x, int incx, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasDscalBatched(hipblasHandle_t handle, int n, const double *alpha, double *x, int incx, int batchCount); -hipblasStatus_t hipblasSgemv(hipblasHandle_t handle, hipblasOperation_t trans, int m, int n, const float *alpha, const float *A, int lda, +HIPBLAS_EXPORT hipblasStatus_t hipblasSgemv(hipblasHandle_t handle, hipblasOperation_t trans, int m, int n, const float *alpha, const float *A, int lda, const float *x, int incx, const float *beta, float *y, int incy); -hipblasStatus_t hipblasDgemv(hipblasHandle_t handle, hipblasOperation_t trans, int m, int n, const double *alpha, const double *A, int lda, +HIPBLAS_EXPORT hipblasStatus_t hipblasDgemv(hipblasHandle_t handle, hipblasOperation_t trans, int m, int n, const double *alpha, const double *A, int lda, const double *x, int incx, const double *beta, double *y, int incy); -hipblasStatus_t hipblasSgemvBatched(hipblasHandle_t handle, hipblasOperation_t trans, int m, int n, const float *alpha, float *A, int lda, +HIPBLAS_EXPORT hipblasStatus_t hipblasSgemvBatched(hipblasHandle_t handle, hipblasOperation_t trans, int m, int n, const float *alpha, float *A, int lda, float *x, int incx, const float *beta, float *y, int incy, int batchCount); -hipblasStatus_t hipblasSger(hipblasHandle_t handle, int m, int n, const float *alpha, const float *x, int incx, const float *y, int incy, float *A, int lda); +HIPBLAS_EXPORT hipblasStatus_t hipblasSger(hipblasHandle_t handle, int m, int n, const float *alpha, const float *x, int incx, const float *y, int incy, float *A, int lda); -hipblasStatus_t hipblasDger(hipblasHandle_t handle, int m, int n, const double *alpha, const double *x, int incx, const double *y, int incy, double *A, int lda); +HIPBLAS_EXPORT hipblasStatus_t hipblasDger(hipblasHandle_t handle, int m, int n, const double *alpha, const double *x, int incx, const double *y, int incy, double *A, int lda); -hipblasStatus_t hipblasSgerBatched(hipblasHandle_t handle, int m, int n, const float *alpha, const float *x, int incx, const float *y, int incy, float *A, int lda, int batchCount); +HIPBLAS_EXPORT hipblasStatus_t hipblasSgerBatched(hipblasHandle_t handle, int m, int n, const float *alpha, const float *x, int incx, const float *y, int incy, float *A, int lda, int batchCount); -hipblasStatus_t hipblasSgemm(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, +HIPBLAS_EXPORT hipblasStatus_t hipblasSgemm(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, int m, int n, int k, const float *alpha, const float *A, int lda, const float *B, int ldb, const float *beta, float *C, int ldc); -hipblasStatus_t hipblasDgemm(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, +HIPBLAS_EXPORT hipblasStatus_t hipblasDgemm(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, int m, int n, int k, const double *alpha, const double *A, int lda, const double *B, int ldb, const double *beta, double *C, int ldc); /* not implementes, requires complex support @@ -131,10 +133,10 @@ hipblasStatus_t hipblasHgemm(hipblasHandle_t handle, hipblasOperation_t transa, int m, int n, int k, const __half *alpha, __half *A, int lda, __half *B, int ldb, const __half *beta, __half *C, int ldc); */ -hipblasStatus_t hipblasSgemmBatched(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, +HIPBLAS_EXPORT hipblasStatus_t hipblasSgemmBatched(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, int m, int n, int k, const float *alpha, const float *A[], int lda, const float *B[], int ldb, const float *beta, float *C[], int ldc, int batchCount); -hipblasStatus_t hipblasDgemmBatched(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, +HIPBLAS_EXPORT hipblasStatus_t hipblasDgemmBatched(hipblasHandle_t handle, hipblasOperation_t transa, hipblasOperation_t transb, int m, int n, int k, const double *alpha, const double *A[], int lda, const double *B[], int ldb, const double *beta, double *C[], int ldc, int batchCount); /* not implementes, requires complex support diff --git a/library/src/CMakeLists.txt b/library/src/CMakeLists.txt index bdbcf8ea7..b9ef4c629 100644 --- a/library/src/CMakeLists.txt +++ b/library/src/CMakeLists.txt @@ -74,16 +74,14 @@ elseif (${PLATFORM} MATCHES "nvcc") endif() -set_target_properties( hipblas PROPERTIES VERSION ${hipblas_VERSION} SOVERSION ${hipblas_SOVERSION} ) - -install(TARGETS hipblas - EXPORT hipblas-targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ +target_include_directories( hipblas + PUBLIC $ + $ + $ ) +set_target_properties( hipblas PROPERTIES VERSION ${hipblas_VERSION} SOVERSION ${hipblas_SOVERSION} ) + # Package that helps me set visibility for function names exported from shared library include( GenerateExportHeader ) if( CMAKE_VERSION VERSION_LESS "3.0" ) @@ -93,6 +91,14 @@ else() endif( ) GENERATE_EXPORT_HEADER( hipblas EXPORT_FILE_NAME hipblas-export.h ) +install(TARGETS hipblas + EXPORT hipblas-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ +) + # The following is cmake code to generate a config file package for hipblas # Documentation for how to use the following package: # https://cmake.org/cmake/help/v3.0/module/CMakePackageConfigHelpers.html