-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ddc592
commit 96e1d8b
Showing
9 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,70 @@ | ||
#include "AMReX_Arena.H" | ||
#include "AMReX_Gpu.H" | ||
|
||
namespace amrex | ||
{ | ||
|
||
void* allocate_host (std::size_t sz) | ||
{ | ||
#if defined(AMREX_USE_CUDA) | ||
void* p; | ||
cudaHostAlloc(&p, sz, cudaHostAllocMapped); | ||
return p; | ||
#elif defined(AMREX_USE_HIP) | ||
void* p; | ||
hipHostAlloc(&p, sz, hipHostAllocMapped | hipHostMallocNonCoherent); | ||
return p; | ||
#elif defined(AMREX_USE_SYCL) | ||
return sycl::malloc_host(...); | ||
#else | ||
return std::malloc(sz); | ||
#endif | ||
} | ||
|
||
void free_host (void* pt) | ||
{ | ||
#if defined(AMREX_USE_CUDA) | ||
cudaFreeHost(pt); | ||
#elif defined(AMREX_USE_HIP) | ||
hipHostFree(pt); | ||
#elif defined(AMREX_USE_SYCL) | ||
sycl::free(...); | ||
#else | ||
std::free(pt); | ||
#endif | ||
} | ||
|
||
#ifdef AMREX_USE_GPU | ||
|
||
void* allocate_device (std::size_t sz) | ||
{ | ||
void* p; | ||
#if defined(AMREX_USE_CUDA) | ||
cudaMalloc(&p, sz); | ||
#elif defined(AMREX_USE_HIP) | ||
hipMalloc(&p, sz); | ||
#elif defined(AMREX_USE_SYCL) | ||
p = sycl::malloc_device(...); | ||
#else | ||
static_assert(false); | ||
#endif | ||
return p; | ||
} | ||
|
||
void free_device (void* pt) | ||
{ | ||
#if defined(AMREX_USE_CUDA) | ||
cudaFree(pt); | ||
#elif defined(AMREX_USE_HIP) | ||
hipFree(pt); | ||
#elif defined(AMREX_USE_SYCL) | ||
sycl::free(...); | ||
#else | ||
static_assert(false); | ||
#endif | ||
|
||
} | ||
|
||
#endif | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "AMReX_Gpu.H" | ||
|
||
#ifdef AMREX_USE_GPU | ||
|
||
namespace { | ||
#ifdef AMREX_USE_SYCL | ||
amrex::gpuStream_t gpu_stream = nullptr; | ||
#else | ||
amrex::gpuStream_t gpu_stream = 0; | ||
#endif | ||
} | ||
|
||
namespace amrex::Gpu { | ||
|
||
void setStream (gpuStream_t a_stream) | ||
{ | ||
gpu_stream = a_stream; | ||
} | ||
|
||
void htod_memcpy (void* p_d, void const* p_h, std::size_t sz) | ||
{ | ||
#if defined(AMREX_USE_CUDA) | ||
cudaMemcpyAsync(p_d, p_h, sz, cudaMemcpyHostToDevice, gpu_stream); | ||
cudaStreamSynchronize(gpu_stream); | ||
#elif defined(AMREX_USE_HIP) | ||
#elif defined(AMREX_USE_SYCL) | ||
#else | ||
static_assert(false); | ||
#endif | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
AMREX_HOME := ../.. | ||
|
||
DEBUG = FALSE | ||
|
||
DIM = 3 | ||
|
||
COMP = gcc | ||
|
||
USE_CUDA = TRUE | ||
USE_HIP = FALSE | ||
USE_SYCL = FALSE | ||
|
||
include $(AMREX_HOME)/Tools/GNUMake/Make.defs | ||
include ./Make.package | ||
include $(AMREX_HOME)/Src/Make.package | ||
include $(AMREX_HOME)/Tools/GNUMake/Make.rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CEXE_sources += main.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "AMReX_Parser.H" | ||
#include <iostream> | ||
|
||
using namespace amrex; | ||
|
||
|
||
int main (int argc, char* argv[]) | ||
{ | ||
amrex::ignore_unused(argc, argv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters