From 1dddd6cfe2da272957d61a193dcac5186a10930a Mon Sep 17 00:00:00 2001 From: Eyal Rozenberg Date: Sat, 16 Nov 2024 21:52:53 +0200 Subject: [PATCH] DELME --- src/cuda/api/memory.hpp | 13 ++++++------- src/cuda/api/types.hpp | 6 ++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cuda/api/memory.hpp b/src/cuda/api/memory.hpp index 2a92d56a..f41efadd 100644 --- a/src/cuda/api/memory.hpp +++ b/src/cuda/api/memory.hpp @@ -622,7 +622,7 @@ void copy_single(T* destination, const T* source, optional str * of the first element, there is no array-decay. */ template -inline void copy(span destination, const T(&source)[N], optional_ref stream = {}) +inline void copy(span destination, c_array const& source, optional_ref stream = {}) { #ifndef NDEBUG if (destination.size() < N) { @@ -642,7 +642,7 @@ inline void copy(span destination, const T(&source)[N], optional_ref -void copy(T(&destination)[N], span source, optional_ref stream = {}) +void copy(c_array& destination, span source, optional_ref stream = {}) { #ifndef NDEBUG if (source.size() > N) { @@ -664,7 +664,7 @@ void copy(T(&destination)[N], span source, optional_ref * of the first element, there is no array-decay. */ template -inline void copy(void* destination, T (&source)[N], optional_ref stream = {}) +inline void copy(void* destination, c_array const& source, optional_ref stream = {}) { return copy(destination, source, sizeof(T) * N, stream); } @@ -687,12 +687,11 @@ inline void copy(void* destination, T (&source)[N], optional_ref * @param stream schedule the copy operation in this CUDA stream */ template -inline void copy(T(&destination)[N], T* source, optional_ref stream = {}) +inline void copy(c_array& destination, T* source, optional_ref stream = {}) { return copy(destination, source, sizeof(T) * N, stream); } - ///@} /** @@ -1098,7 +1097,7 @@ void copy(void* destination, void const* source, size_t num_bytes, optional_ref< * @param stream schedule the copy operation in this CUDA stream */ template -inline void copy(T(&destination)[N], const_region_t source, optional_ref stream = {}) +inline void copy(c_array& destination, const_region_t source, optional_ref stream = {}) { #ifndef NDEBUG size_t required_size = N * sizeof(T); @@ -1135,7 +1134,7 @@ inline void copy(T(&destination)[N], const_region_t source, optional_ref -inline void copy(region_t destination, const T(&source)[N], optional_ref stream = {}) +inline void copy(region_t destination, c_array const& source, optional_ref stream = {}) { #ifndef NDEBUG if (destination.size() < N) { diff --git a/src/cuda/api/types.hpp b/src/cuda/api/types.hpp index cc5889b0..bbcac245 100644 --- a/src/cuda/api/types.hpp +++ b/src/cuda/api/types.hpp @@ -60,6 +60,12 @@ /// @brief Definitions and functionality wrapping CUDA APIs. namespace cuda { +// This alias for plain C arrays is required due to an MSVC bug, making it fail to +// accept straight up C array reference parameters to functions under some circumstances; +// see: https://developercommunity.visualstudio.com/t/MSVC-rejects-syntax-of-reference-to-C-ar/10792039 +template +using c_array = T[N]; + /** * Indicates either the result (success or error index) of a CUDA Runtime or Driver API call, * or the overall status of the API (which is typically the last triggered error).