Skip to content

Commit

Permalink
memory: Simplify names of backend functions
Browse files Browse the repository at this point in the history
  • Loading branch information
stotko committed Nov 18, 2024
1 parent 8a0abf1 commit d621e2b
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 76 deletions.
20 changes: 10 additions & 10 deletions src/stdgpu/cuda/impl/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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;

Expand All @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/stdgpu/cuda/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ 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
* \param[in] type The type of the memory to deallocate
* \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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/stdgpu/hip/impl/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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;

Expand All @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/stdgpu/hip/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ 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
* \param[in] type The type of the memory to deallocate
* \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
Expand All @@ -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
Expand Down
28 changes: 3 additions & 25 deletions src/stdgpu/impl/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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&
Expand Down
20 changes: 10 additions & 10 deletions src/stdgpu/openmp/impl/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/stdgpu/openmp/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ 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
* \param[in] type The type of the memory to deallocate
* \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
Expand All @@ -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
Expand Down

0 comments on commit d621e2b

Please sign in to comment.