[Libomptarget] Change device free routines to accept the allocation kind
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 31 Aug 2022 20:55:14 +0000 (15:55 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 14 Sep 2022 17:14:07 +0000 (12:14 -0500)
commit23bc343855fdf6fb7668abadf2b064034b207981
treec7775b7341f190f48c9187f6eefd4589e74e4f8c
parent5631d20bfc9f77d15435badf6ce34e1a56c27e1c
[Libomptarget] Change device free routines to accept the allocation kind

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.

Reviewed By: JonChesterfield, tianshilei1992

Differential Revision: https://reviews.llvm.org/D133053
18 files changed:
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