Implement hipMemAllocationTypeUncached in hipMemCreate (#747)
* Revert "SWDEV-547589 - Add hipDeviceMallocUncached to hipMemCreate (#815)" This reverts commit5ce7103555. * Revert "SWDEV-547589 - comment for flag hipDeviceMallocUncached in hipMemcreate (#339)" This reverts commit04dac5eae3. * SWDEV-551942 - implement hipMemAllocationTypeUncached in hipMemCreate
Αυτή η υποβολή περιλαμβάνεται σε:
@@ -27,7 +27,9 @@ Full documentation for HIP is available at [rocm.docs.amd.com](https://rocm.docs
|
||||
- `hipMemAdvise_v2` advise about the usage of a given memory range
|
||||
- `hipGetDriverEntryPoint ` gets function pointer of a HIP API.
|
||||
* Changed HIP APIs
|
||||
- `hipMemCreate` now can take hipDeviceMallocUncached as a flag to allocate uncached memory
|
||||
- `hipMemAllocationType` now has hip exclusive enum hipMemAllocationTypeUncached
|
||||
- `hipMemCreate` now checks for hipMemAllocationTypeUncached enum from
|
||||
hipMemAllocationType and allocates uncached memory if so
|
||||
|
||||
### Optimized
|
||||
|
||||
|
||||
@@ -85,12 +85,9 @@ 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 || prop == nullptr ||
|
||||
prop->type != hipMemAllocationTypePinned || prop->location.type != hipMemLocationTypeDevice) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
if (flags != hipDeviceMallocUncached && flags != 0) {
|
||||
if (handle == nullptr || size == 0 || flags != 0 || prop == nullptr ||
|
||||
(prop->type != hipMemAllocationTypePinned && prop->type != hipMemAllocationTypeUncached) ||
|
||||
prop->location.type != hipMemLocationTypeDevice) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
@@ -103,6 +100,12 @@ hipError_t hipMemCreate(hipMemGenericAllocationHandle_t* handle, size_t size,
|
||||
HIP_RETURN(hipErrorNotSupported);
|
||||
}
|
||||
|
||||
// When ROCCLR_MEM_PHYMEM is set, ROCr impl gets and stores unique hsa handle. Flag no-op on PAL.
|
||||
unsigned int ihipFlags = ROCCLR_MEM_PHYMEM;
|
||||
if (prop->type == hipMemAllocationTypeUncached) {
|
||||
ihipFlags |= CL_MEM_SVM_ATOMICS | ROCCLR_MEM_HSA_UNCACHED;
|
||||
}
|
||||
|
||||
// Device info validation
|
||||
const auto& dev_info = g_devices[prop->location.id]->devices()[0]->info();
|
||||
|
||||
@@ -115,13 +118,8 @@ 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.
|
||||
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);
|
||||
void* ptr = amd::SvmBuffer::malloc(*amdContext, ihipFlags, size,
|
||||
dev_info.memBaseAddrAlign_, nullptr);
|
||||
|
||||
// Handle out of memory cases,
|
||||
if (ptr == nullptr) {
|
||||
|
||||
@@ -1194,6 +1194,7 @@ typedef enum hipMemAllocationType {
|
||||
* location while the application is actively using it
|
||||
*/
|
||||
hipMemAllocationTypePinned = 0x1,
|
||||
hipMemAllocationTypeUncached = 0x40000000,
|
||||
hipMemAllocationTypeMax = 0x7FFFFFFF
|
||||
} hipMemAllocationType;
|
||||
/**
|
||||
@@ -9137,7 +9138,7 @@ hipError_t hipMemAddressReserve(void** ptr, size_t size, size_t alignment, void*
|
||||
* @param [out] handle - value of the returned handle.
|
||||
* @param [in] size - size of the allocation.
|
||||
* @param [in] prop - properties of the allocation.
|
||||
* @param [in] flags - hipDeviceMallocUncached for uncached allocation, or 0 for default
|
||||
* @param [in] flags - currently unused, must be zero.
|
||||
* @returns #hipSuccess, #hipErrorInvalidValue, #hipErrorNotSupported
|
||||
* @warning This API is marked as Beta. While this feature is complete, it can
|
||||
* change and might have outstanding issues.
|
||||
|
||||
Αναφορά σε νέο ζήτημα
Block a user