Skip to content

Commit

Permalink
Add DPC++ copy and clone for SUNMemory
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsexton03 committed Mar 10, 2021
1 parent 5b6f1ec commit a62af07
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Src/Extern/SUNDIALS/AMReX_SUNMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace {
mem->ptr = NULL;
mem->own = SUNTRUE;
mem->type = mem_type;


if (mem_type == SUNMEMTYPE_HOST) {
mem->ptr = The_Cpu_Arena()->alloc(memsize);
Expand All @@ -45,7 +46,7 @@ namespace {
if (mem->type == SUNMEMTYPE_HOST) {
if (mem->own) The_Cpu_Arena()->free(mem->ptr);
} else if (mem->type == SUNMEMTYPE_UVM) {
if (mem->own) The_Managed_Arena()->free(mem->ptr);
if (mem->own) The_Managed_Arena()->free(mem->ptr);
} else if (mem->type == SUNMEMTYPE_DEVICE) {
if (mem->own) The_Device_Arena()->free(mem->ptr);
} else if (mem->type == SUNMEMTYPE_PINNED) {
Expand All @@ -63,8 +64,11 @@ namespace {
return *The_SUNMemory_Helper();
}

int DestroyMemoryHelper(SUNMemoryHelper)
int DestroyMemoryHelper(SUNMemoryHelper helper)
{
helper->content = NULL;
free(helper->ops);
free(helper);
return(0);
}

Expand All @@ -85,6 +89,13 @@ namespace {
#elif defined(AMREX_USE_CUDA)
helper->ops->copy = SUNMemoryHelper_Copy_Cuda;
helper->ops->copyasync = SUNMemoryHelper_CopyAsync_Cuda;
#elif defined(AMREX_USE_DPCPP)
helper->ops->copy = SUNMemoryHelper_Copy_Sycl;
helper->ops->copyasync = SUNMemoryHelper_CopyAsync_Sycl;
helper->ops->clone = SUNMemoryHelper_Clone_Sycl;

/* Attach the sycl queue pointer as the content */
helper->content = (void*) &amrex::Gpu::Device::streamQueue();
#endif

return helper;
Expand Down

0 comments on commit a62af07

Please sign in to comment.