SWDEV-563752 - Allow hipMemLocationTypeHost in hipMemSetAccess even if memory was created on the device (#1620)

Co-authored-by: Rahul Manocha <rmanocha@amd.com>
This commit is contained in:
Ioannis Assiouras
2025-10-31 13:57:36 +00:00
zatwierdzone przez GitHub
rodzic 24cb8c4deb
commit 1dd0237cb2
2 zmienionych plików z 8 dodań i 7 usunięć
-4
Wyświetl plik
@@ -388,10 +388,6 @@ hipError_t hipMemSetAccess(void* ptr, size_t size, const hipMemAccessDesc* desc,
if (accessLocationType != hipMemLocationTypeDevice && accessLocationType != hipMemLocationTypeHost) {
HIP_RETURN(hipErrorInvalidValue);
}
if (accessLocationType == hipMemLocationTypeHost &&
memLocationType != hipMemLocationTypeHost) {
HIP_RETURN(hipErrorInvalidValue)
}
if (desc[desc_idx].location.id >= g_devices.size()) {
HIP_RETURN(hipErrorInvalidValue)
@@ -1489,18 +1489,23 @@ TEST_CASE("Unit_hipMemSetAccessHost_devicealloc") {
HIP_CHECK(hipMemMap(addr, mapSize, 0 /*offset*/, handle, 0 /*flags*/));
// Grant HOST access.
// Grant HOST access.
hipMemAccessDesc accHost{};
accHost.flags = hipMemAccessFlagsProtReadWrite;
accHost.location.type = hipMemLocationTypeHost;
accHost.location.id = 0;
HIP_CHECK_ERROR(hipMemSetAccess(addr, mapSize, &accHost, 1), hipErrorInvalidValue);
#if HT_AMD
// SWDEV-563752: we need to allow setAccess to the host even if location is set to
// hipMemLocationTypeDevice in hipMemCreate
HIP_CHECK(hipMemSetAccess(addr, mapSize, &accHost, 1));
#else
HIP_CHECK_ERROR(hipMemSetAccess(addr, mapSize, &accHost, 1), hipErrorNotSupported);
#endif
HIP_CHECK(hipMemUnmap(addr, mapSize));
HIP_CHECK(hipMemAddressFree(addr, mapSize));
HIP_CHECK(hipMemRelease(handle));
}
/**
* End doxygen group VirtualMemoryManagementTest.
* @}