From 4960ad420bcfd79db2884ec7a42c2bf01c1c2b85 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 4 Nov 2021 20:29:07 +0100 Subject: Cycles: add code to check for supported HIP device architectures RDNA2 only for now to be conservative, but testing more hardware is underway. Ref T92393 Differential Revision: https://developer.blender.org/D12958 --- intern/cycles/device/hip/device.cpp | 8 ++++---- intern/cycles/device/hip/device_impl.cpp | 19 +++++++++++++------ intern/cycles/device/hip/util.h | 9 +++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) (limited to 'intern/cycles/device/hip') diff --git a/intern/cycles/device/hip/device.cpp b/intern/cycles/device/hip/device.cpp index f71732d14bb..29304e50247 100644 --- a/intern/cycles/device/hip/device.cpp +++ b/intern/cycles/device/hip/device.cpp @@ -131,9 +131,9 @@ void device_hip_info(vector &devices) continue; } - int major; - hipDeviceGetAttribute(&major, hipDeviceAttributeComputeCapabilityMajor, num); - // TODO : (Arya) What is the last major version we are supporting? + if (!hipSupportsDevice(num)) { + continue; + } DeviceInfo info; @@ -141,7 +141,7 @@ void device_hip_info(vector &devices) info.description = string(name); info.num = num; - info.has_half_images = (major >= 3); + info.has_half_images = true; info.has_nanovdb = true; info.denoisers = 0; diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index a71fc4b888b..db93ecd8474 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -146,12 +146,18 @@ HIPDevice::~HIPDevice() bool HIPDevice::support_device(const uint /*kernel_features*/) { - int major, minor; - hipDeviceGetAttribute(&major, hipDeviceAttributeComputeCapabilityMajor, hipDevId); - hipDeviceGetAttribute(&minor, hipDeviceAttributeComputeCapabilityMinor, hipDevId); + if (hipSupportsDevice(hipDevId)) { + return true; + } + else { + /* We only support Navi and above. */ + hipDeviceProp_t props; + hipGetDeviceProperties(&props, hipDevId); - // TODO : (Arya) What versions do we plan to support? - return true; + set_error(string_printf("HIP backend requires AMD RDNA2 graphics card or up, but found %s.", + props.name)); + return false; + } } bool HIPDevice::check_peer_access(Device *peer_device) @@ -391,8 +397,9 @@ bool HIPDevice::load_kernels(const uint kernel_features) return false; /* check if GPU is supported */ - if (!support_device(kernel_features)) + if (!support_device(kernel_features)) { return false; + } /* get kernel */ const char *kernel_name = "kernel"; diff --git a/intern/cycles/device/hip/util.h b/intern/cycles/device/hip/util.h index 0db5174a3db..f3194ecaa77 100644 --- a/intern/cycles/device/hip/util.h +++ b/intern/cycles/device/hip/util.h @@ -58,6 +58,15 @@ const char *hipewCompilerPath(); int hipewCompilerVersion(); # endif /* WITH_HIP_DYNLOAD */ +static inline bool hipSupportsDevice(const int hipDevId) +{ + int major, minor; + hipDeviceGetAttribute(&major, hipDeviceAttributeComputeCapabilityMajor, hipDevId); + hipDeviceGetAttribute(&minor, hipDeviceAttributeComputeCapabilityMinor, hipDevId); + + return (major > 10) || (major == 10 && minor >= 3); +} + CCL_NAMESPACE_END #endif /* WITH_HIP */ -- cgit v1.2.3