From fc3d4e2f4d13a997e6fbd42e800e36e663dc2dda Mon Sep 17 00:00:00 2001 From: Konrad Kusiak Date: Wed, 7 Aug 2024 12:22:15 +0100 Subject: [PATCH] Add ifdefs to support past DPC++ releases --- .../backends/cublas/cublas_scope_handle.cpp | 9 +++++++++ .../backends/cublas/cublas_scope_handle.hpp | 17 ++++++++++++++++- src/blas/backends/cublas/cublas_task.hpp | 12 ++++++++++-- .../backends/rocblas/rocblas_scope_handle.cpp | 13 +++++++++++-- .../backends/rocblas/rocblas_scope_handle.hpp | 16 ++++++++++++++++ src/blas/backends/rocblas/rocblas_task.hpp | 13 ++++++++++--- .../cusolver/cusolver_scope_handle.cpp | 9 +++++++++ .../cusolver/cusolver_scope_handle.hpp | 18 ++++++++++++++++-- src/lapack/backends/cusolver/cusolver_task.hpp | 8 ++++++++ .../rocsolver/rocsolver_scope_handle.cpp | 9 +++++++++ .../rocsolver/rocsolver_scope_handle.hpp | 4 ++++ .../backends/rocsolver/rocsolver_task.hpp | 7 +++++++ 12 files changed, 125 insertions(+), 10 deletions(-) diff --git a/src/blas/backends/cublas/cublas_scope_handle.cpp b/src/blas/backends/cublas/cublas_scope_handle.cpp index 168e339ad..edcfa67f5 100644 --- a/src/blas/backends/cublas/cublas_scope_handle.cpp +++ b/src/blas/backends/cublas/cublas_scope_handle.cpp @@ -35,8 +35,13 @@ namespace cublas { * takes place if no other element in the container has a key equivalent to * the one being emplaced (keys in a map container are unique). */ +#ifdef _PI_INTERFACE_REMOVED_ thread_local cublas_handle CublasScopedContextHandler::handle_helper = cublas_handle{}; +#else +thread_local cublas_handle CublasScopedContextHandler::handle_helper = + cublas_handle{}; +#endif CublasScopedContextHandler::CublasScopedContextHandler(sycl::queue queue, sycl::interop_handle &ih) : ih(ih), @@ -92,7 +97,11 @@ cublasHandle_t CublasScopedContextHandler::get_handle(const sycl::queue &queue) CUresult cuErr; CUcontext desired; CUDA_ERROR_FUNC(cuDevicePrimaryCtxRetain, cuErr, &desired, cudaDevice); +#ifdef _PI_INTERFACE_REMOVED_ auto piPlacedContext_ = reinterpret_cast(desired); +#else + auto piPlacedContext_ = reinterpret_cast(desired); +#endif CUstream streamId = get_stream(queue); cublasStatus_t err; auto it = handle_helper.cublas_handle_mapper_.find(piPlacedContext_); diff --git a/src/blas/backends/cublas/cublas_scope_handle.hpp b/src/blas/backends/cublas/cublas_scope_handle.hpp index b8e754de2..5a5f67426 100644 --- a/src/blas/backends/cublas/cublas_scope_handle.hpp +++ b/src/blas/backends/cublas/cublas_scope_handle.hpp @@ -28,12 +28,23 @@ #include #endif #include -#include #else #include #include +#endif + +// After Plugin Interface removal in DPC++ ur.hpp is the new include +#if __has_include() +#include +#ifndef _PI_INTERFACE_REMOVED_ +#define _PI_INTERFACE_REMOVED_ +#endif +#elif __has_include() +#include +#else #include #endif + #include #include #include @@ -77,7 +88,11 @@ class CublasScopedContextHandler { sycl::context *placedContext_; bool needToRecover_; sycl::interop_handle &ih; +#ifdef _PI_INTERFACE_REMOVED_ static thread_local cublas_handle handle_helper; +#else + static thread_local cublas_handle handle_helper; +#endif CUstream get_stream(const sycl::queue &queue); sycl::context get_context(const sycl::queue &queue); diff --git a/src/blas/backends/cublas/cublas_task.hpp b/src/blas/backends/cublas/cublas_task.hpp index 3c7c50b3e..8c6ad759d 100644 --- a/src/blas/backends/cublas/cublas_task.hpp +++ b/src/blas/backends/cublas/cublas_task.hpp @@ -32,13 +32,21 @@ #include "oneapi/mkl/types.hpp" #ifndef __HIPSYCL__ #include "cublas_scope_handle.hpp" +#else +#include "cublas_scope_handle_hipsycl.hpp" + +// After Plugin Interface removal in DPC++ ur.hpp is the new include #if __has_include() #include +#ifndef _PI_INTERFACE_REMOVED_ +#define _PI_INTERFACE_REMOVED_ +#endif +#elif __has_include() +#include #else #include #endif -#else -#include "cublas_scope_handle_hipsycl.hpp" + namespace sycl { using interop_handler = sycl::interop_handle; } diff --git a/src/blas/backends/rocblas/rocblas_scope_handle.cpp b/src/blas/backends/rocblas/rocblas_scope_handle.cpp index 2dc5fd765..cbc282cac 100644 --- a/src/blas/backends/rocblas/rocblas_scope_handle.cpp +++ b/src/blas/backends/rocblas/rocblas_scope_handle.cpp @@ -50,8 +50,13 @@ rocblas_handle_container::~rocblas_handle_container() noexcept(false) { * takes place if no other element in the container has a key equivalent to * the one being emplaced (keys in a map container are unique). */ -thread_local rocblas_handle_container RocblasScopedContextHandler::handle_helper = - rocblas_handle_container{}; +#ifdef _PI_INTERFACE_REMOVED_ +thread_local rocblas_handle_container + RocblasScopedContextHandler::handle_helper = rocblas_handle_container{}; +#else +thread_local rocblas_handle_container RocblasScopedContextHandler::handle_helper = + rocblas_handle_container{}; +#endif RocblasScopedContextHandler::RocblasScopedContextHandler(sycl::queue queue, sycl::interop_handle &ih) @@ -108,7 +113,11 @@ rocblas_handle RocblasScopedContextHandler::get_handle(const sycl::queue &queue) hipError_t hipErr; hipCtx_t desired; HIP_ERROR_FUNC(hipDevicePrimaryCtxRetain, hipErr, &desired, hipDevice); +#ifdef _PI_INTERFACE_REMOVED_ auto piPlacedContext_ = reinterpret_cast(desired); +#else + auto piPlacedContext_ = reinterpret_cast(desired); +#endif hipStream_t streamId = get_stream(queue); rocblas_status err; auto it = handle_helper.rocblas_handle_container_mapper_.find(piPlacedContext_); diff --git a/src/blas/backends/rocblas/rocblas_scope_handle.hpp b/src/blas/backends/rocblas/rocblas_scope_handle.hpp index d637d0905..7dfe7011a 100644 --- a/src/blas/backends/rocblas/rocblas_scope_handle.hpp +++ b/src/blas/backends/rocblas/rocblas_scope_handle.hpp @@ -26,6 +26,18 @@ #include #include "rocblas_helper.hpp" +// After Plugin Interface removal in DPC++ ur.hpp is the new include +#if __has_include() +#include +#ifndef _PI_INTERFACE_REMOVED_ +#define _PI_INTERFACE_REMOVED_ +#endif +#elif __has_include() +#include +#else +#include +#endif + namespace oneapi { namespace mkl { namespace blas { @@ -43,7 +55,11 @@ class RocblasScopedContextHandler { sycl::context *placedContext_; bool needToRecover_; sycl::interop_handle &interop_h; +#ifdef _PI_INTERFACE_REMOVED_ static thread_local rocblas_handle_container handle_helper; +#else + static thread_local rocblas_handle_container handle_helper; +#endif sycl::context get_context(const sycl::queue &queue); hipStream_t get_stream(const sycl::queue &queue); diff --git a/src/blas/backends/rocblas/rocblas_task.hpp b/src/blas/backends/rocblas/rocblas_task.hpp index 69ccd6fd8..eff7d5c68 100644 --- a/src/blas/backends/rocblas/rocblas_task.hpp +++ b/src/blas/backends/rocblas/rocblas_task.hpp @@ -30,15 +30,22 @@ #include "oneapi/mkl/types.hpp" #ifndef __HIPSYCL__ #include "rocblas_scope_handle.hpp" +#else +#include "rocblas_scope_handle_hipsycl.hpp" +#endif + +// After Plugin Interface removal in DPC++ ur.hpp is the new include #if __has_include() #include +#ifndef _PI_INTERFACE_REMOVED_ +#define _PI_INTERFACE_REMOVED_ +#endif +#elif __has_include() +#include #else #include #endif -#else -#include "rocblas_scope_handle_hipsycl.hpp" -#endif namespace oneapi { namespace mkl { namespace blas { diff --git a/src/lapack/backends/cusolver/cusolver_scope_handle.cpp b/src/lapack/backends/cusolver/cusolver_scope_handle.cpp index 4855608cd..ad5c9ac2d 100644 --- a/src/lapack/backends/cusolver/cusolver_scope_handle.cpp +++ b/src/lapack/backends/cusolver/cusolver_scope_handle.cpp @@ -35,8 +35,13 @@ namespace cusolver { * takes place if no other element in the container has a key equivalent to * the one being emplaced (keys in a map container are unique). */ +#ifdef _PI_INTERFACE_REMOVED_ thread_local cusolver_handle CusolverScopedContextHandler::handle_helper = cusolver_handle{}; +#else +thread_local cusolver_handle CusolverScopedContextHandler::handle_helper = + cusolver_handle{}; +#endif CusolverScopedContextHandler::CusolverScopedContextHandler(sycl::queue queue, sycl::interop_handle &ih) @@ -93,7 +98,11 @@ cusolverDnHandle_t CusolverScopedContextHandler::get_handle(const sycl::queue &q CUresult cuErr; CUcontext desired; CUDA_ERROR_FUNC(cuDevicePrimaryCtxRetain, cuErr, &desired, cudaDevice); +#ifdef _PI_INTERFACE_REMOVED_ auto piPlacedContext_ = reinterpret_cast(desired); +#else + auto piPlacedContext_ = reinterpret_cast(desired); +#endif CUstream streamId = get_stream(queue); cusolverStatus_t err; auto it = handle_helper.cusolver_handle_mapper_.find(piPlacedContext_); diff --git a/src/lapack/backends/cusolver/cusolver_scope_handle.hpp b/src/lapack/backends/cusolver/cusolver_scope_handle.hpp index 179dbd40d..c0bb50bc9 100644 --- a/src/lapack/backends/cusolver/cusolver_scope_handle.hpp +++ b/src/lapack/backends/cusolver/cusolver_scope_handle.hpp @@ -28,11 +28,9 @@ #include #endif #include -#include #else #include #include -#include #endif #include #include @@ -41,6 +39,18 @@ #include "cusolver_helper.hpp" #include "cusolver_handle.hpp" +// After Plugin Interface removal in DPC++ ur.hpp is the new include +#if __has_include() +#include +#ifndef _PI_INTERFACE_REMOVED_ +#define _PI_INTERFACE_REMOVED_ +#endif +#elif __has_include() +#include +#else +#include +#endif + namespace oneapi { namespace mkl { namespace lapack { @@ -82,7 +92,11 @@ class CusolverScopedContextHandler { sycl::context *placedContext_; bool needToRecover_; sycl::interop_handle &ih; +#ifdef _PI_INTERFACE_REMOVED_ static thread_local cusolver_handle handle_helper; +#else + static thread_local cusolver_handle handle_helper; +#endif CUstream get_stream(const sycl::queue &queue); sycl::context get_context(const sycl::queue &queue); diff --git a/src/lapack/backends/cusolver/cusolver_task.hpp b/src/lapack/backends/cusolver/cusolver_task.hpp index 0df59b2a6..6fc6e70ab 100644 --- a/src/lapack/backends/cusolver/cusolver_task.hpp +++ b/src/lapack/backends/cusolver/cusolver_task.hpp @@ -30,11 +30,19 @@ #endif #include "oneapi/mkl/types.hpp" #include "cusolver_scope_handle.hpp" + +// After Plugin Interface removal in DPC++ ur.hpp is the new include #if __has_include() #include +#ifndef _PI_INTERFACE_REMOVED_ +#define _PI_INTERFACE_REMOVED_ +#endif +#elif __has_include() +#include #else #include #endif + namespace oneapi { namespace mkl { namespace lapack { diff --git a/src/lapack/backends/rocsolver/rocsolver_scope_handle.cpp b/src/lapack/backends/rocsolver/rocsolver_scope_handle.cpp index 6348d042c..930e0139b 100644 --- a/src/lapack/backends/rocsolver/rocsolver_scope_handle.cpp +++ b/src/lapack/backends/rocsolver/rocsolver_scope_handle.cpp @@ -37,8 +37,13 @@ namespace rocsolver { * takes place if no other element in the container has a key equivalent to * the one being emplaced (keys in a map container are unique). */ +#ifdef _PI_INTERFACE_REMOVED_ thread_local rocsolver_handle RocsolverScopedContextHandler::handle_helper = rocsolver_handle{}; +#else +thread_local rocsolver_handle RocsolverScopedContextHandler::handle_helper = + rocsolver_handle{}; +#endif RocsolverScopedContextHandler::RocsolverScopedContextHandler(sycl::queue queue, sycl::interop_handle &ih) @@ -95,7 +100,11 @@ rocblas_handle RocsolverScopedContextHandler::get_handle(const sycl::queue &queu hipError_t hipErr; hipCtx_t desired; HIP_ERROR_FUNC(hipDevicePrimaryCtxRetain, hipErr, &desired, hipDevice); +#ifdef _PI_INTERFACE_REMOVED_ auto piPlacedContext_ = reinterpret_cast(desired); +#else + auto piPlacedContext_ = reinterpret_cast(desired); +#endif hipStream_t streamId = get_stream(queue); rocblas_status err; auto it = handle_helper.rocsolver_handle_mapper_.find(piPlacedContext_); diff --git a/src/lapack/backends/rocsolver/rocsolver_scope_handle.hpp b/src/lapack/backends/rocsolver/rocsolver_scope_handle.hpp index acabceabf..fe661f14a 100644 --- a/src/lapack/backends/rocsolver/rocsolver_scope_handle.hpp +++ b/src/lapack/backends/rocsolver/rocsolver_scope_handle.hpp @@ -43,7 +43,11 @@ class RocsolverScopedContextHandler { sycl::context *placedContext_; bool needToRecover_; sycl::interop_handle &ih; +#ifdef _PI_INTERFACE_REMOVED_ static thread_local rocsolver_handle handle_helper; +#else + static thread_local rocsolver_handle handle_helper; +#endif hipStream_t get_stream(const sycl::queue &queue); sycl::context get_context(const sycl::queue &queue); diff --git a/src/lapack/backends/rocsolver/rocsolver_task.hpp b/src/lapack/backends/rocsolver/rocsolver_task.hpp index f061d34c2..7f321500c 100644 --- a/src/lapack/backends/rocsolver/rocsolver_task.hpp +++ b/src/lapack/backends/rocsolver/rocsolver_task.hpp @@ -32,8 +32,15 @@ #endif #include "oneapi/mkl/types.hpp" #include "rocsolver_scope_handle.hpp" + +// After Plugin Interface removal in DPC++ ur.hpp is the new include #if __has_include() #include +#ifndef _PI_INTERFACE_REMOVED_ +#define _PI_INTERFACE_REMOVED_ +#endif +#elif __has_include() +#include #else #include #endif