summaryrefslogtreecommitdiff
path: root/flang/runtime/CUDA/allocator.cpp
diff options
context:
space:
mode:
authorFlorian Mayer <fmayer@google.com>2024-08-07 14:00:51 -0700
committerFlorian Mayer <fmayer@google.com>2024-08-07 14:00:51 -0700
commit10fbc246b146dbdf6b7cd9083bf392505c534fbc (patch)
tree898a2504a8bc941166603c77021937fd995e79ce /flang/runtime/CUDA/allocator.cpp
parent191d02015fba3458bdf6381ee93c32e485daf25e (diff)
parenta05fa131db58f2d66a1f9e68fea74068f9218c2b (diff)
Created using spr 1.3.4
Diffstat (limited to 'flang/runtime/CUDA/allocator.cpp')
-rw-r--r--flang/runtime/CUDA/allocator.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/flang/runtime/CUDA/allocator.cpp b/flang/runtime/CUDA/allocator.cpp
index 26a3c2969626..cd00d40361d2 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/flang/runtime/CUDA/allocator.cpp
@@ -17,7 +17,7 @@
#include "cuda.h"
-namespace Fortran::runtime::cuf {
+namespace Fortran::runtime::cuda {
void CUFRegisterAllocator() {
allocatorRegistry.Register(
@@ -26,6 +26,8 @@ void CUFRegisterAllocator() {
kDeviceAllocatorPos, {&CUFAllocDevice, CUFFreeDevice});
allocatorRegistry.Register(
kManagedAllocatorPos, {&CUFAllocManaged, CUFFreeManaged});
+ allocatorRegistry.Register(
+ kUnifiedAllocatorPos, {&CUFAllocUnified, CUFFreeUnified});
}
void *CUFAllocPinned(std::size_t sizeInBytes) {
@@ -57,4 +59,14 @@ void CUFFreeManaged(void *p) {
CUDA_REPORT_IF_ERROR(cuMemFree(reinterpret_cast<CUdeviceptr>(p)));
}
-} // namespace Fortran::runtime::cuf
+void *CUFAllocUnified(std::size_t sizeInBytes) {
+ // Call alloc managed for the time being.
+ return CUFAllocManaged(sizeInBytes);
+}
+
+void CUFFreeUnified(void *p) {
+ // Call free managed for the time being.
+ CUFFreeManaged(p);
+}
+
+} // namespace Fortran::runtime::cuda