Skip to content

Commit

Permalink
DELME
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalroz committed Nov 17, 2024
1 parent b9cef21 commit 1dddd6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/cuda/api/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ void copy_single(T* destination, const T* source, optional<stream::handle_t> str
* of the first element, there is no array-decay.
*/
template <typename T, size_t N>
inline void copy(span<T> destination, const T(&source)[N], optional_ref<const stream_t> stream = {})
inline void copy(span<T> destination, c_array<const T,N> const& source, optional_ref<const stream_t> stream = {})
{
#ifndef NDEBUG
if (destination.size() < N) {
Expand All @@ -642,7 +642,7 @@ inline void copy(span<T> destination, const T(&source)[N], optional_ref<const st
* containing the data to be copied
*/
template <typename T, size_t N>
void copy(T(&destination)[N], span<T const> source, optional_ref<const stream_t> stream = {})
void copy(c_array<T,N>& destination, span<T const> source, optional_ref<const stream_t> stream = {})
{
#ifndef NDEBUG
if (source.size() > N) {
Expand All @@ -664,7 +664,7 @@ void copy(T(&destination)[N], span<T const> source, optional_ref<const stream_t>
* of the first element, there is no array-decay.
*/
template <typename T, size_t N>
inline void copy(void* destination, T (&source)[N], optional_ref<const stream_t> stream = {})
inline void copy(void* destination, c_array<const T,N> const& source, optional_ref<const stream_t> stream = {})
{
return copy(destination, source, sizeof(T) * N, stream);
}
Expand All @@ -687,12 +687,11 @@ inline void copy(void* destination, T (&source)[N], optional_ref<const stream_t>
* @param stream schedule the copy operation in this CUDA stream
*/
template <typename T, size_t N>
inline void copy(T(&destination)[N], T* source, optional_ref<const stream_t> stream = {})
inline void copy(c_array<T,N>& destination, T* source, optional_ref<const stream_t> stream = {})
{
return copy(destination, source, sizeof(T) * N, stream);
}


///@}

/**
Expand Down Expand Up @@ -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 <typename T, size_t N>
inline void copy(T(&destination)[N], const_region_t source, optional_ref<const stream_t> stream = {})
inline void copy(c_array<T,N>& destination, const_region_t source, optional_ref<const stream_t> stream = {})
{
#ifndef NDEBUG
size_t required_size = N * sizeof(T);
Expand Down Expand Up @@ -1135,7 +1134,7 @@ inline void copy(T(&destination)[N], const_region_t source, optional_ref<const s
* @param stream A stream on which to enqueue the copy operation
*/
template <typename T, size_t N>
inline void copy(region_t destination, const T(&source)[N], optional_ref<const stream_t> stream = {})
inline void copy(region_t destination, c_array<const T,N> const& source, optional_ref<const stream_t> stream = {})
{
#ifndef NDEBUG
if (destination.size() < N) {
Expand Down
6 changes: 6 additions & 0 deletions src/cuda/api/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T, size_t N>
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).
Expand Down

0 comments on commit 1dddd6c

Please sign in to comment.