SWDEV-547589 - Add hipDeviceMallocUncached to hipMemCreate (#815)
Co-authored-by: Jimbo Xie <jiabaxie@amd.com>
This commit is contained in:
committed by
GitHub
parent
b90f3c2507
commit
bd1e489f1f
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user