[Openmp-commits] [PATCH] D132660: [openmp][amdgpu] Implement target_alloc_host as fine grain HSA memory
Jon Chesterfield via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Aug 25 08:01:30 PDT 2022
JonChesterfield updated this revision to Diff 455589.
JonChesterfield added a comment.
- test RUN string needs -generic suffix
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132660/new/
https://reviews.llvm.org/D132660
Files:
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
openmp/libomptarget/test/api/omp_device_managed_memory.c
openmp/libomptarget/test/api/omp_device_managed_memory_alloc.c
openmp/libomptarget/test/api/omp_host_pinned_memory.c
openmp/libomptarget/test/api/omp_host_pinned_memory_alloc.c
Index: openmp/libomptarget/test/api/omp_host_pinned_memory_alloc.c
===================================================================
--- openmp/libomptarget/test/api/omp_host_pinned_memory_alloc.c
+++ openmp/libomptarget/test/api/omp_host_pinned_memory_alloc.c
@@ -1,5 +1,4 @@
-// RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda
-// REQUIRES: nvptx64-nvidia-cuda
+// RUN: %libomptarget-compile-run-and-check-generic
#include <omp.h>
#include <stdio.h>
Index: openmp/libomptarget/test/api/omp_host_pinned_memory.c
===================================================================
--- openmp/libomptarget/test/api/omp_host_pinned_memory.c
+++ openmp/libomptarget/test/api/omp_host_pinned_memory.c
@@ -1,5 +1,4 @@
-// RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda
-// REQUIRES: nvptx64-nvidia-cuda
+// RUN: %libomptarget-compile-run-and-check-generic
#include <omp.h>
#include <stdio.h>
Index: openmp/libomptarget/test/api/omp_device_managed_memory_alloc.c
===================================================================
--- openmp/libomptarget/test/api/omp_device_managed_memory_alloc.c
+++ openmp/libomptarget/test/api/omp_device_managed_memory_alloc.c
@@ -1,5 +1,4 @@
-// RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda
-// REQUIRES: nvptx64-nvidia-cuda
+// RUN: %libomptarget-compile-run-and-check-generic
#include <omp.h>
#include <stdio.h>
Index: openmp/libomptarget/test/api/omp_device_managed_memory.c
===================================================================
--- openmp/libomptarget/test/api/omp_device_managed_memory.c
+++ openmp/libomptarget/test/api/omp_device_managed_memory.c
@@ -1,5 +1,4 @@
-// RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda
-// REQUIRES: nvptx64-nvidia-cuda
+// RUN: %libomptarget-compile-run-and-check-generic
#include <omp.h>
#include <stdio.h>
Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -2620,13 +2620,26 @@
void *Ptr = NULL;
assert(DeviceId < DeviceInfo().NumberOfDevices && "Device ID too large");
- if (Kind != TARGET_ALLOC_DEFAULT) {
+ hsa_amd_memory_pool_t MemoryPool;
+ switch (Kind) {
+ case TARGET_ALLOC_DEFAULT:
+ // GPU memory
+ MemoryPool = DeviceInfo().getDeviceMemoryPool(DeviceId);
+ break;
+ case TARGET_ALLOC_HOST:
+ // non-migratable memory accessible by host and device(s)
+ MemoryPool = DeviceInfo().getHostMemoryPool();
+ break;
+ case TARGET_ALLOC_SHARED:
+ // migratable memory accessible by host and device
+ MemoryPool = DeviceInfo().getHostMemoryPool();
+ break;
+ default:
REPORT("Invalid target data allocation kind or requested allocator not "
"implemented yet\n");
return NULL;
}
- hsa_amd_memory_pool_t MemoryPool = DeviceInfo().getDeviceMemoryPool(DeviceId);
hsa_status_t Err = hsa_amd_memory_pool_allocate(MemoryPool, Size, 0, &Ptr);
DP("Tgt alloc data %ld bytes, (tgt:%016llx).\n", Size,
(long long unsigned)(Elf64_Addr)Ptr);
@@ -2677,6 +2690,7 @@
int32_t __tgt_rtl_data_delete(int DeviceId, void *TgtPtr) {
assert(DeviceId < DeviceInfo().NumberOfDevices && "Device ID too large");
+ // HSA can free pointers allocated from different types of memory pool.
hsa_status_t Err;
DP("Tgt free data (tgt:%016llx).\n", (long long unsigned)(Elf64_Addr)TgtPtr);
Err = core::Runtime::Memfree(TgtPtr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132660.455589.patch
Type: text/x-patch
Size: 3527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220825/f7d0602d/attachment.bin>
More information about the Openmp-commits
mailing list