[Bf-blender-cvs] [d5f81e8e9c5] cycles-hip-binaries: Cycles: add supported device checks for HIP
Sayak Biswas
noreply at git.blender.org
Fri Oct 22 12:26:22 CEST 2021
Commit: d5f81e8e9c5193fd3980ba5fbd1a178ce984df90
Author: Sayak Biswas
Date: Thu Oct 21 20:57:17 2021 +0200
Branches: cycles-hip-binaries
https://developer.blender.org/rBd5f81e8e9c5193fd3980ba5fbd1a178ce984df90
Cycles: add supported device checks for HIP
===================================================================
M intern/cycles/blender/addon/properties.py
M intern/cycles/device/hip/device.cpp
M intern/cycles/device/hip/device_impl.cpp
M intern/cycles/device/hip/util.h
===================================================================
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 2a51e0be2a4..c7599bc58e2 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1382,7 +1382,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
col.label(text="and NVIDIA driver version 470 or newer", icon='BLANK1')
elif device_type == 'HIP':
import sys
- col.label(text="Requires discrete AMD GPU with ??? architecture", icon='BLANK1')
+ col.label(text="Requires discrete AMD GPU with RDNA2 architecture", icon='BLANK1')
if sys.platform[:3] == "win":
col.label(text="and AMD driver version ??? or newer", icon='BLANK1')
return
diff --git a/intern/cycles/device/hip/device.cpp b/intern/cycles/device/hip/device.cpp
index 90028ac7f10..39815b0f60b 100644
--- a/intern/cycles/device/hip/device.cpp
+++ b/intern/cycles/device/hip/device.cpp
@@ -131,9 +131,9 @@ void device_hip_info(vector<DeviceInfo> &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<DeviceInfo> &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 4ae714913ab..9614f61336c 100644
--- a/intern/cycles/device/hip/device_impl.cpp
+++ b/intern/cycles/device/hip/device_impl.cpp
@@ -148,12 +148,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)
@@ -404,8 +410,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 */
More information about the Bf-blender-cvs
mailing list