[Openmp-commits] [PATCH] D133053: [Libomptarget] Change device free routines to accept the allocation kind

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 31 14:04:03 PDT 2022


jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, jdoerfert, tianshilei1992, ye-luo, ronlieb, saiislam.
Herald added subscribers: kosarev, kerbowa, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

Previous support for device memory allocators used a single free
routine and did not provide the original kind of the allocation. This is
problematic as some of these memory types required different handling.
Previously this was worked around using a map in runtime to record the
original kind of each pointer. Instead, this patch introduces new free
routines similar to the existing allocation routines. This allows us to
avoid a map traversal every time we free a device pointer.

The only interfaces defined by the standard are `omp_target_alloc` and
`omp_target_free`, these do not take a kind as `omp_alloc` does. The
standard dictates the following:

"The omp_target_alloc routine returns a device pointer that references
the device address of a storage location of size bytes. The storage
location is dynamically allocated in the device data environment of the
device specified by device_num."

Which suggests that these routines only allocate the default device
memory for the kind. So this has been changed to reflect this. This
change is somewhat breaking if users were using `omp_target_free` as
previously shown in the tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133053

Files:
  openmp/libomptarget/include/device.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/include/omptargetplugin.h
  openmp/libomptarget/include/rtl.h
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins/common/MemoryManager/MemoryManager.h
  openmp/libomptarget/plugins/cuda/src/rtl.cpp
  openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp
  openmp/libomptarget/plugins/remote/src/rtl.cpp
  openmp/libomptarget/plugins/ve/src/rtl.cpp
  openmp/libomptarget/src/api.cpp
  openmp/libomptarget/src/device.cpp
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/test/api/omp_device_managed_memory.c
  openmp/libomptarget/test/api/omp_host_pinned_memory.c
  openmp/runtime/src/kmp_alloc.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133053.457085.patch
Type: text/x-patch
Size: 18593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220831/1235a841/attachment-0001.bin>


More information about the Openmp-commits mailing list