SWDEV-547589 - Add hipDeviceMallocUncached to hipMemCreate (#815)

Co-authored-by: Jimbo Xie <jiabaxie@amd.com>

[ROCm/clr commit: bd1e489f1f]
이 커밋은 다음에 포함됨:
Xie, Jiabao(Jimbo)그리고Jimbo Xie 작성하고 GitHub가 2025-08-15 16:02:26 -07:00를 커밋함
1 부모 9bb6fb0b79
커밋 5ce7103555
2 파일이 변경됨
+15 -3

검색과 일치하는 파일 없음

+4
파일 보기
@@ -21,6 +21,10 @@ Full documentation for HIP is available at [rocm.docs.amd.com](https://rocm.docs
- `hipMemcpy3DBatchAsync` Performs a batch of 3D memory copied asynchronously
- `hipMemcpy3DPeer` Copies memory between devices
- `hipMemcpy3DPeerAsync`Copied memory between devices asynchronously
- `hipMemsetD2D32Async` Used for setting 2D memory range with specified 32-bit values
asynchronously
* Changed HIP APIs
- `hipMemCreate` now can take hipDeviceMallocUncached as a flag to allocate uncached memory
## HIP 7.0 for ROCm 7.0
+11 -3
파일 보기
@@ -85,11 +85,15 @@ hipError_t hipMemCreate(hipMemGenericAllocationHandle_t* handle, size_t size,
HIP_INIT_API(hipMemCreate, handle, size, prop, flags);
// Currently we do not support Pinned memory
if (handle == nullptr || size == 0 || flags != 0 || prop == nullptr ||
if (handle == nullptr || size == 0 || prop == nullptr ||
prop->type != hipMemAllocationTypePinned || prop->location.type != hipMemLocationTypeDevice) {
HIP_RETURN(hipErrorInvalidValue);
}
if (flags != hipDeviceMallocUncached && flags != 0) {
HIP_RETURN(hipErrorInvalidValue);
}
if (prop->location.id < 0 || prop->location.id >= g_devices.size()) {
HIP_RETURN(hipErrorInvalidDevice);
}
@@ -112,8 +116,12 @@ hipError_t hipMemCreate(hipMemGenericAllocationHandle_t* handle, size_t size,
amd::Context* amdContext = g_devices[prop->location.id]->asContext();
// When ROCCLR_MEM_PHYMEM is set, ROCr impl gets and stores unique hsa handle. Flag no-op on PAL.
void* ptr = amd::SvmBuffer::malloc(*amdContext, ROCCLR_MEM_PHYMEM, size,
dev_info.memBaseAddrAlign_, nullptr);
uint64_t ihipFlags = ROCCLR_MEM_PHYMEM;
if (flags == hipDeviceMallocUncached) {
ihipFlags |= ROCCLR_MEM_HSA_UNCACHED | CL_MEM_SVM_ATOMICS;
}
void* ptr =
amd::SvmBuffer::malloc(*amdContext, ihipFlags, size, dev_info.memBaseAddrAlign_, nullptr);
// Handle out of memory cases,
if (ptr == nullptr) {