Skip to content

Commit 1da214c

Browse files
authored
Merge pull request #1562 from frasercrmck/gfx1031-workaround
[HIP] Add a workaround for crashes on gfx1031
2 parents 96948b1 + 633270a commit 1da214c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

source/adapters/hip/device.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,20 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
724724
}
725725

726726
case UR_DEVICE_INFO_GLOBAL_MEM_FREE: {
727+
// Work around an issue on some (unsupported) architectures,
728+
// where hipMemGetInfo fails internally and returns hipErrorInvalidValue
729+
// when trying to query the amount of available global memory. Since we
730+
// can't distinguish this condition from us doing something wrong, we can't
731+
// handle it gracefully.
732+
hipDeviceProp_t Props;
733+
UR_CHECK_ERROR(hipGetDeviceProperties(&Props, hDevice->get()));
734+
if (strcmp(Props.gcnArchName, "gfx1031") == 0) {
735+
return ReturnValue(size_t{0});
736+
}
737+
727738
size_t FreeMemory = 0;
728739
size_t TotalMemory = 0;
729-
detail::ur::assertion(hipMemGetInfo(&FreeMemory, &TotalMemory) ==
730-
hipSuccess,
731-
"failed hipMemGetInfo() API.");
740+
UR_CHECK_ERROR(hipMemGetInfo(&FreeMemory, &TotalMemory));
732741
return ReturnValue(FreeMemory);
733742
}
734743

0 commit comments

Comments
 (0)