summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorJhonatan Cléto <52751492+cl3to@users.noreply.github.com>2024-05-08 00:21:32 -0300
committerGitHub <noreply@github.com>2024-05-07 22:21:32 -0500
commitb438a817bd863699715116ee7d85b454f3289c08 (patch)
treeab15d3d6fc8ab6a5c49230e1a14265098f3b2cf2 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent31b45a9d0d91cc3a78446ee379abc6f2a3000065 (diff)
[Offload] Fix dataDelete op for TARGET_ALLOC_HOST memory type (#91134)
Summary: The `GenericDeviceTy::dataDelete` method doesn't verify the `TargetAllocTy` of the of the device pointer. Because of this, it can use the `MemoryManager` to free the ptr. However, the `TARGET_ALLOC_HOST` and `TARGET_ALLOC_SHARED` types are not allocated using the `MemoryManager` in the `GenericDeviceTy::dataAlloc` method. Since the `MemoryManager` uses the `DeviceAllocatorTy::free` operation without specifying the type of the ptr, some plugins may use incorrect operations to free ptrs of certain types. In particular, this bug causes the CUDA plugin to use the `cuMemFree` operation on ptrs of type `TARGET_ALLOC_HOST`, resulting in an unchecked error, as shown in the output snippet of the test `offload/test/api/omp_host_pinned_memory_alloc.c`: ``` omptarget --> Notifying about an unmapping: HstPtr=0x00007c6114200000 omptarget --> Call to llvm_omp_target_free_host for device 0 and address 0x00007c6114200000 omptarget --> Call to omp_get_num_devices returning 1 omptarget --> Call to omp_get_initial_device returning 1 PluginInterface --> MemoryManagerTy::free: target memory 0x00007c6114200000. PluginInterface --> Cannot find its node. Delete it on device directly. TARGET CUDA RTL --> Failure to free memory: Error in cuMemFree[Host]: invalid argument omptarget --> omp_target_free deallocated device ptr ``` This patch fixes this by adding the check of the device pointer type before calling the appropriate operation for each type.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions