summaryrefslogtreecommitdiff
path: root/flang/runtime/CUDA
diff options
context:
space:
mode:
authorFlorian Mayer <fmayer@google.com>2024-08-07 14:00:59 -0700
committerFlorian Mayer <fmayer@google.com>2024-08-07 14:00:59 -0700
commit890289dfb61757cc3f8fd5feb093131ebc3b7477 (patch)
treeb9b69f1881544d20a2c05f84c42a0a5805128f4e /flang/runtime/CUDA
parentb58d0717d588624eae77aea330e94f52607448c9 (diff)
parent6a3604ef8592edf39fedd6af8100aefafd6d931d (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/fmayer/spr/main.compiler-rt-tsan-leave-bufferedstacktrace-uninit
Created using spr 1.3.4 [skip ci]
Diffstat (limited to 'flang/runtime/CUDA')
-rw-r--r--flang/runtime/CUDA/CMakeLists.txt1
-rw-r--r--flang/runtime/CUDA/allocator.cpp16
-rw-r--r--flang/runtime/CUDA/descriptor.cpp28
3 files changed, 43 insertions, 2 deletions
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index de1104f07ce6..88243536139e 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -11,6 +11,7 @@ find_library(CUDA_RUNTIME_LIBRARY cuda HINTS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTOR
add_flang_library(CufRuntime
allocator.cpp
+ descriptor.cpp
)
target_link_libraries(CufRuntime
PRIVATE
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
diff --git a/flang/runtime/CUDA/descriptor.cpp b/flang/runtime/CUDA/descriptor.cpp
new file mode 100644
index 000000000000..1031b1e601b6
--- /dev/null
+++ b/flang/runtime/CUDA/descriptor.cpp
@@ -0,0 +1,28 @@
+//===-- runtime/CUDA/descriptor.cpp ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Runtime/CUDA/descriptor.h"
+#include "flang/Runtime/CUDA/allocator.h"
+
+namespace Fortran::runtime::cuda {
+extern "C" {
+RT_EXT_API_GROUP_BEGIN
+
+Descriptor *RTDEF(CUFAllocDesciptor)(
+ std::size_t sizeInBytes, const char *sourceFile, int sourceLine) {
+ return reinterpret_cast<Descriptor *>(CUFAllocManaged(sizeInBytes));
+}
+
+void RTDEF(CUFFreeDesciptor)(
+ Descriptor *desc, const char *sourceFile, int sourceLine) {
+ CUFFreeManaged(reinterpret_cast<void *>(desc));
+}
+
+RT_EXT_API_GROUP_END
+}
+} // namespace Fortran::runtime::cuda