From 7daf62b2aebfb280499f3b49c87a9453d704ef55 Mon Sep 17 00:00:00 2001 From: Patrick Stotko Date: Mon, 18 Nov 2024 13:13:37 +0100 Subject: [PATCH] memory: Simplify names of backend functions --- src/stdgpu/cuda/impl/memory.cpp | 20 ++++++++++---------- src/stdgpu/cuda/memory.h | 14 +++++++------- src/stdgpu/hip/impl/memory.cpp | 20 ++++++++++---------- src/stdgpu/hip/memory.h | 14 +++++++------- src/stdgpu/impl/memory.cpp | 28 +++------------------------- src/stdgpu/openmp/impl/memory.cpp | 20 ++++++++++---------- src/stdgpu/openmp/memory.h | 14 +++++++------- 7 files changed, 54 insertions(+), 76 deletions(-) diff --git a/src/stdgpu/cuda/impl/memory.cpp b/src/stdgpu/cuda/impl/memory.cpp index ab9cf52dd..1f82270a2 100644 --- a/src/stdgpu/cuda/impl/memory.cpp +++ b/src/stdgpu/cuda/impl/memory.cpp @@ -23,7 +23,7 @@ namespace stdgpu::cuda { void -dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes) +malloc(const dynamic_memory_type type, void** array, index64_t bytes) { switch (type) { @@ -48,14 +48,14 @@ dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes) case dynamic_memory_type::invalid: default: { - printf("stdgpu::cuda::dispatch_malloc : Unsupported dynamic memory type\n"); + printf("stdgpu::cuda::malloc : Unsupported dynamic memory type\n"); return; } } } void -dispatch_free(const dynamic_memory_type type, void* array) +free(const dynamic_memory_type type, void* array) { switch (type) { @@ -80,18 +80,18 @@ dispatch_free(const dynamic_memory_type type, void* array) case dynamic_memory_type::invalid: default: { - printf("stdgpu::cuda::dispatch_free : Unsupported dynamic memory type\n"); + printf("stdgpu::cuda::free : Unsupported dynamic memory type\n"); return; } } } void -dispatch_memcpy(void* destination, - const void* source, - index64_t bytes, - dynamic_memory_type destination_type, - dynamic_memory_type source_type) +memcpy(void* destination, + const void* source, + index64_t bytes, + dynamic_memory_type destination_type, + dynamic_memory_type source_type) { cudaMemcpyKind kind; @@ -116,7 +116,7 @@ dispatch_memcpy(void* destination, } else { - printf("stdgpu::cuda::dispatch_memcpy : Unsupported dynamic source or destination memory type\n"); + printf("stdgpu::cuda::memcpy : Unsupported dynamic source or destination memory type\n"); return; } diff --git a/src/stdgpu/cuda/memory.h b/src/stdgpu/cuda/memory.h index e8f649282..de49a4b4d 100644 --- a/src/stdgpu/cuda/memory.h +++ b/src/stdgpu/cuda/memory.h @@ -29,7 +29,7 @@ namespace stdgpu::cuda * \param[in] bytes The size of the allocated array */ void -dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes); +malloc(const dynamic_memory_type type, void** array, index64_t bytes); /** * \brief Performs platform-specific memory deallocation @@ -37,7 +37,7 @@ dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes); * \param[in] array The allocated array */ void -dispatch_free(const dynamic_memory_type type, void* array); +free(const dynamic_memory_type type, void* array); /** * \brief Performs platform-specific memory copy @@ -48,11 +48,11 @@ dispatch_free(const dynamic_memory_type type, void* array); * \param[in] source_type The type of the source array */ void -dispatch_memcpy(void* destination, - const void* source, - index64_t bytes, - dynamic_memory_type destination_type, - dynamic_memory_type source_type); +memcpy(void* destination, + const void* source, + index64_t bytes, + dynamic_memory_type destination_type, + dynamic_memory_type source_type); /** * \brief Workarounds a synchronization issue with older GPUs diff --git a/src/stdgpu/hip/impl/memory.cpp b/src/stdgpu/hip/impl/memory.cpp index 2dcfba9af..cf17fc9cf 100644 --- a/src/stdgpu/hip/impl/memory.cpp +++ b/src/stdgpu/hip/impl/memory.cpp @@ -23,7 +23,7 @@ namespace stdgpu::hip { void -dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes) +malloc(const dynamic_memory_type type, void** array, index64_t bytes) { switch (type) { @@ -48,14 +48,14 @@ dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes) case dynamic_memory_type::invalid: default: { - printf("stdgpu::hip::dispatch_malloc : Unsupported dynamic memory type\n"); + printf("stdgpu::hip::malloc : Unsupported dynamic memory type\n"); return; } } } void -dispatch_free(const dynamic_memory_type type, void* array) +free(const dynamic_memory_type type, void* array) { switch (type) { @@ -80,18 +80,18 @@ dispatch_free(const dynamic_memory_type type, void* array) case dynamic_memory_type::invalid: default: { - printf("stdgpu::hip::dispatch_free : Unsupported dynamic memory type\n"); + printf("stdgpu::hip::free : Unsupported dynamic memory type\n"); return; } } } void -dispatch_memcpy(void* destination, - const void* source, - index64_t bytes, - dynamic_memory_type destination_type, - dynamic_memory_type source_type) +memcpy(void* destination, + const void* source, + index64_t bytes, + dynamic_memory_type destination_type, + dynamic_memory_type source_type) { hipMemcpyKind kind; @@ -116,7 +116,7 @@ dispatch_memcpy(void* destination, } else { - printf("stdgpu::hip::dispatch_memcpy : Unsupported dynamic source or destination memory type\n"); + printf("stdgpu::hip::memcpy : Unsupported dynamic source or destination memory type\n"); return; } diff --git a/src/stdgpu/hip/memory.h b/src/stdgpu/hip/memory.h index aacd091ec..d74fa31b8 100644 --- a/src/stdgpu/hip/memory.h +++ b/src/stdgpu/hip/memory.h @@ -29,7 +29,7 @@ namespace stdgpu::hip * \param[in] bytes The size of the allocated array */ void -dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes); +malloc(const dynamic_memory_type type, void** array, index64_t bytes); /** * \brief Performs platform-specific memory deallocation @@ -37,7 +37,7 @@ dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes); * \param[in] array The allocated array */ void -dispatch_free(const dynamic_memory_type type, void* array); +free(const dynamic_memory_type type, void* array); /** * \brief Performs platform-specific memory copy @@ -48,11 +48,11 @@ dispatch_free(const dynamic_memory_type type, void* array); * \param[in] source_type The type of the source array */ void -dispatch_memcpy(void* destination, - const void* source, - index64_t bytes, - dynamic_memory_type destination_type, - dynamic_memory_type source_type); +memcpy(void* destination, + const void* source, + index64_t bytes, + dynamic_memory_type destination_type, + dynamic_memory_type source_type); /** * \brief Workarounds a synchronization issue with older GPUs diff --git a/src/stdgpu/impl/memory.cpp b/src/stdgpu/impl/memory.cpp index dd027d3f6..045055f8d 100644 --- a/src/stdgpu/impl/memory.cpp +++ b/src/stdgpu/impl/memory.cpp @@ -255,28 +255,6 @@ dispatch_allocation_manager(const dynamic_memory_type type) } } -void -dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes) -{ - stdgpu::STDGPU_BACKEND_NAMESPACE::dispatch_malloc(type, array, bytes); -} - -void -dispatch_free(const dynamic_memory_type type, void* array) -{ - stdgpu::STDGPU_BACKEND_NAMESPACE::dispatch_free(type, array); -} - -void -dispatch_memcpy(void* destination, - const void* source, - index64_t bytes, - dynamic_memory_type destination_type, - dynamic_memory_type source_type) -{ - stdgpu::STDGPU_BACKEND_NAMESPACE::dispatch_memcpy(destination, source, bytes, destination_type, source_type); -} - void workaround_synchronize_managed_memory() { @@ -294,7 +272,7 @@ allocate(index64_t bytes, dynamic_memory_type type) void* array = nullptr; - dispatch_malloc(type, &array, bytes); + stdgpu::STDGPU_BACKEND_NAMESPACE::malloc(type, &array, bytes); // Update pointer management after allocation dispatch_allocation_manager(type).register_memory(array, bytes); @@ -319,7 +297,7 @@ deallocate(void* p, index64_t bytes, dynamic_memory_type type) // Update pointer management before freeing dispatch_allocation_manager(type).deregister_memory(p, bytes); - dispatch_free(type, p); + stdgpu::STDGPU_BACKEND_NAMESPACE::free(type, p); } void @@ -347,7 +325,7 @@ memcpy(void* destination, } } - dispatch_memcpy(destination, source, bytes, destination_type, source_type); + stdgpu::STDGPU_BACKEND_NAMESPACE::memcpy(destination, source, bytes, destination_type, source_type); } memory_manager& diff --git a/src/stdgpu/openmp/impl/memory.cpp b/src/stdgpu/openmp/impl/memory.cpp index a5cbd7405..6789b4257 100644 --- a/src/stdgpu/openmp/impl/memory.cpp +++ b/src/stdgpu/openmp/impl/memory.cpp @@ -23,7 +23,7 @@ namespace stdgpu::openmp { void -dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes) +malloc(const dynamic_memory_type type, void** array, index64_t bytes) { switch (type) { @@ -39,14 +39,14 @@ dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes) case dynamic_memory_type::invalid: default: { - printf("stdgpu::openmp::dispatch_malloc : Unsupported dynamic memory type\n"); + printf("stdgpu::openmp::malloc : Unsupported dynamic memory type\n"); return; } } } void -dispatch_free(const dynamic_memory_type type, void* array) +free(const dynamic_memory_type type, void* array) { switch (type) { @@ -61,22 +61,22 @@ dispatch_free(const dynamic_memory_type type, void* array) case dynamic_memory_type::invalid: default: { - printf("stdgpu::openmp::dispatch_free : Unsupported dynamic memory type\n"); + printf("stdgpu::openmp::free : Unsupported dynamic memory type\n"); return; } } } void -dispatch_memcpy(void* destination, - const void* source, - index64_t bytes, - dynamic_memory_type destination_type, - dynamic_memory_type source_type) +memcpy(void* destination, + const void* source, + index64_t bytes, + dynamic_memory_type destination_type, + dynamic_memory_type source_type) { if (destination_type == dynamic_memory_type::invalid || source_type == dynamic_memory_type::invalid) { - printf("stdgpu::openmp::dispatch_memcpy : Unsupported dynamic source or destination memory type\n"); + printf("stdgpu::openmp::memcpy : Unsupported dynamic source or destination memory type\n"); return; } diff --git a/src/stdgpu/openmp/memory.h b/src/stdgpu/openmp/memory.h index 44994a94d..cd1b0aa47 100644 --- a/src/stdgpu/openmp/memory.h +++ b/src/stdgpu/openmp/memory.h @@ -29,7 +29,7 @@ namespace stdgpu::openmp * \param[in] bytes The size of the allocated array */ void -dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes); +malloc(const dynamic_memory_type type, void** array, index64_t bytes); /** * \brief Performs platform-specific memory deallocation @@ -37,7 +37,7 @@ dispatch_malloc(const dynamic_memory_type type, void** array, index64_t bytes); * \param[in] array The allocated array */ void -dispatch_free(const dynamic_memory_type type, void* array); +free(const dynamic_memory_type type, void* array); /** * \brief Performs platform-specific memory copy @@ -48,11 +48,11 @@ dispatch_free(const dynamic_memory_type type, void* array); * \param[in] source_type The type of the source array */ void -dispatch_memcpy(void* destination, - const void* source, - index64_t bytes, - dynamic_memory_type destination_type, - dynamic_memory_type source_type); +memcpy(void* destination, + const void* source, + index64_t bytes, + dynamic_memory_type destination_type, + dynamic_memory_type source_type); /** * \brief Workarounds a synchronization issue with older GPUs