50 template <AddressSpace DestAdrSp, AddressSpace SrcAdrSp>
51 void memcpy(
void *dest,
void const *src,
size_t count) {
55 if constexpr (DestAdrSp == Host && SrcAdrSp == Host) {
56 std::memcpy(dest, src, count);
83 template <AddressSpace DestAdrSp, AddressSpace SrcAdrSp>
84 void memcpy2D(
void *dest,
size_t dpitch,
const void *src,
size_t spitch,
size_t width,
size_t height) {
85 EXPECTS(width <= dpitch && width <= spitch);
89 if constexpr (DestAdrSp == Host && SrcAdrSp == Host) {
90 auto *desti =
static_cast<unsigned char *
>(dest);
91 auto *srci =
static_cast<const unsigned char *
>(src);
92 for (
size_t i = 0; i < height; ++i, desti += dpitch, srci += spitch) std::memcpy(desti, srci, width);
94 device_error_check(cudaMemcpy2D(dest, dpitch, src, spitch, width, height, cudaMemcpyDefault),
"cudaMemcpy2D");
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides GPU and non-GPU specific functionality.
static const auto check_adr_sp_valid
Check validity of a set of nda::mem::AddressSpace values.
static constexpr bool have_cuda
Constexpr variable that is true if the project is configured with CUDA support.
void memcpy2D(void *dest, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height)
Call CUDA's cudaMemcpy2D function or simulate its behavior on the Host based on the given address spa...
#define device_error_check(ARG1, ARG2)
Trigger a compilation error every time the nda::device_error_check function is called.
static constexpr bool have_device
Constexpr variable that is true if the project is configured with GPU support.
void memcpy(void *dest, void const *src, size_t count)
Call the correct memcpy function based on the given address spaces.
Macros used in the nda library.