[compiler-rt][asan] Add Linux HSA/ROCm GPU memory support via HSA API… - #3856
Open
ampandey-AMD wants to merge 1 commit into
Open
[compiler-rt][asan] Add Linux HSA/ROCm GPU memory support via HSA API…#3856ampandey-AMD wants to merge 1 commit into
ampandey-AMD wants to merge 1 commit into
Conversation
… interceptors Add AddressSanitizer support for ROCm/HSA GPU memory on Linux by intercepting host-side HSA APIs (init/shutdown, memory pool allocate/free, IPC attach/detach, vmem reserve/free, memory copies, and pointer queries). Build / platform: - `SANITIZER_AMDHSA` is enabled by default on Linux (non-Android). The HSA path is inert at runtime until `libhsa-runtime64.so` is dlopen'd; no ROCm install is required to build compiler-rt. - Vendored HSA headers are shared with the AMDGPU offload plugin (`offload/plugins-nextgen/amdgpu/dynamic_hsa/`), avoiding drift and removing the old CMake ROCm HSA/COMgr header discovery. Allocator architecture: - Keep `CombinedAllocator` host-only for all sanitizers. - Add `DeviceCombinedAllocator` as an ASan-only wrapper that composes the host allocator with `AmdgpuDeviceAllocatorT`. Host `malloc`/`free` still use the inner `CombinedAllocator`; Device allocations go through a separate `AllocateDevice()` path used by HSA interceptors. - ROCr entry points are resolved via dlopen/dlsym on the ROCr handle after `hsa_init`, avoiding RTLD_NEXT recursion. - GPU-only vmem reservations (without `HSA_AMD_VMEM_ADDRESS_NO_REGISTER`) are tracked separately via `VmemGpuReserveTracker` because the reserved VA is not host-writable for ASan chunk metadata. - Tests under `test/asan/TestCases/AMDGPU/` gate on Linux + ROCm runtime detection; VMEM tests additionally require the `hsa-vmem` lit feature when `HSA_VMEM_SUPPORTED` is set. Co-authored-by: Brian Sumner <Brian.Sumner@amd.com> Co-authored-by: Bing Ma <Bing.Ma@amd.com>
Collaborator
|
Can this go upstream? Or can we get something in the description on why it has to be downstream only? Or is it just for testing? |
Author
There is already an upstreamed version of this patch , PR 192240. The downstream PR is there to avoid any merge conflicts with current downstream HEAD. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… interceptors
Add AddressSanitizer support for ROCm/HSA GPU memory on Linux by intercepting host-side HSA APIs (init/shutdown, memory pool allocate/free, IPC attach/detach, vmem reserve/free, memory copies, and pointer queries).
Build / platform:
SANITIZER_AMDHSAis enabled by default on Linux (non-Android). The HSA path is inert at runtime untillibhsa-runtime64.sois dlopen'd; no ROCm install is required to build compiler-rt.offload/plugins-nextgen/amdgpu/dynamic_hsa/), avoiding drift and removing the old CMake ROCm HSA/COMgr header discovery.Allocator architecture:
Keep
CombinedAllocatorhost-only for all sanitizers.Add
DeviceCombinedAllocatoras an ASan-only wrapper that composes the host allocator withAmdgpuDeviceAllocatorT. Hostmalloc/freestill use the innerCombinedAllocator; Device allocations go through a separateAllocateDevice()path used by HSA interceptors.ROCr entry points are resolved via dlopen/dlsym on the ROCr handle after
hsa_init, avoiding RTLD_NEXT recursion.GPU-only vmem reservations (without
HSA_AMD_VMEM_ADDRESS_NO_REGISTER) are tracked separately viaVmemGpuReserveTrackerbecause the reserved VA is not host-writable for ASan chunk metadata.Tests under
test/asan/TestCases/AMDGPU/gate on Linux + ROCm runtime detection; VMEM tests additionally require thehsa-vmemlit feature whenHSA_VMEM_SUPPORTEDis set.