diff --git a/projects/clr/rocclr/device/rocm/rocdevice.cpp b/projects/clr/rocclr/device/rocm/rocdevice.cpp index 16396feea8..77e6847359 100644 --- a/projects/clr/rocclr/device/rocm/rocdevice.cpp +++ b/projects/clr/rocclr/device/rocm/rocdevice.cpp @@ -2578,8 +2578,12 @@ bool Device::GetSvmAttributes(void** data, size_t* data_sizes, int* attributes, if (status != HSA_STATUS_SUCCESS) { LogError("hsa_amd_pointer_info() failed"); } + // Check if it's a legacy non-HMM allocation and update query - if (ptr_info.type != HSA_EXT_POINTER_TYPE_UNKNOWN) { + *reinterpret_cast(data[i]) = HSA_AMD_SVM_GLOBAL_FLAG_INDETERMINATE; + if (ptr_info.type == HSA_EXT_POINTER_TYPE_HSA || + ptr_info.type == HSA_EXT_POINTER_TYPE_LOCKED || + ptr_info.type == HSA_EXT_POINTER_TYPE_IPC) { if (ptr_info.global_flags & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_COARSE_GRAINED) { *reinterpret_cast(data[i]) = HSA_AMD_SVM_GLOBAL_FLAG_COARSE_GRAINED; } else if (ptr_info.global_flags & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED) { @@ -2617,7 +2621,7 @@ bool Device::GetSvmAttributes(void** data, size_t* data_sizes, int* attributes, attr.push_back({HSA_AMD_SVM_ATTRIB_PREFETCH_LOCATION, 0}); break; case amd::MemRangeAttribute::CoherencyMode: - if (ptr_info.type == HSA_EXT_POINTER_TYPE_UNKNOWN) { + if (*reinterpret_cast(data[i]) == HSA_AMD_SVM_GLOBAL_FLAG_INDETERMINATE) { attr.push_back({HSA_AMD_SVM_ATTRIB_GLOBAL_FLAG, 0}); } break; @@ -2721,7 +2725,7 @@ bool Device::GetSvmAttributes(void** data, size_t* data_sizes, int* attributes, return false; } // if ptr is HMM alloc then overwrite the values - if (ptr_info.type == HSA_EXT_POINTER_TYPE_UNKNOWN) { + if (*reinterpret_cast(data[idx]) == HSA_AMD_SVM_GLOBAL_FLAG_INDETERMINATE) { // Cast ROCr value into the hip format *reinterpret_cast(data[idx]) = static_cast(it.value); } @@ -2734,7 +2738,7 @@ bool Device::GetSvmAttributes(void** data, size_t* data_sizes, int* attributes, // Find the next location in the query ++idx; } - } else if (ptr_info.type == HSA_EXT_POINTER_TYPE_UNKNOWN) { + } else if (ptr_info.type == HSA_EXT_POINTER_TYPE_RESERVED_ADDR) { LogError("GetSvmAttributes() failed, because no HMM support"); return false; }