diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-11-04 22:56:32 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-11-04 22:56:32 +0300 |
commit | df3e30398f77be985fe7c94ea061aedcb220dd01 (patch) | |
tree | 1f9326d190c08f121780fa590a5a933ebab0a79b /intern/cycles/device | |
parent | 556c71a84ac1e017883b6f0af0b4fdf8d21254c6 (diff) | |
parent | e7e3431b299448310f9c9e95d863055e3e04a8c4 (diff) |
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/hip/device.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/device/hip/device_impl.cpp | 54 | ||||
-rw-r--r-- | intern/cycles/device/hip/util.h | 9 |
3 files changed, 35 insertions, 34 deletions
diff --git a/intern/cycles/device/hip/device.cpp b/intern/cycles/device/hip/device.cpp index 41b4f3e41fd..25e932ef080 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; diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index 1ea387513d5..e7772cec262 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) @@ -240,36 +246,23 @@ string HIPDevice::compile_kernel(const uint kernel_features, hipDeviceProp_t props; hipGetDeviceProperties(&props, hipDevId); + /* gcnArchName can contain tokens after the arch name with features, ie. + "gfx1010:sramecc-:xnack-" so we tokenize it to get the first part. */ + char *arch = strtok(props.gcnArchName, ":"); + if (arch == NULL) { + arch = props.gcnArchName; + } + /* Attempt to use kernel provided with Blender. */ if (!use_adaptive_compilation()) { if (!force_ptx) { - const string fatbin = path_get(string_printf("lib/%s_%s.fatbin", name, props.gcnArchName)); + const string fatbin = path_get(string_printf("lib/%s_%s.fatbin", name, arch)); VLOG(1) << "Testing for pre-compiled kernel " << fatbin << "."; if (path_exists(fatbin)) { VLOG(1) << "Using precompiled kernel."; return fatbin; } } - - /* The driver can JIT-compile PTX generated for older generations, so find the closest one. */ - int ptx_major = major, ptx_minor = minor; - while (ptx_major >= 3) { - const string ptx = path_get( - string_printf("lib/%s_compute_%d%d.ptx", name, ptx_major, ptx_minor)); - VLOG(1) << "Testing for pre-compiled kernel " << ptx << "."; - if (path_exists(ptx)) { - VLOG(1) << "Using precompiled kernel."; - return ptx; - } - - if (ptx_minor > 0) { - ptx_minor--; - } - else { - ptx_major--; - ptx_minor = 9; - } - } } /* Try to use locally compiled kernel. */ @@ -292,12 +285,10 @@ string HIPDevice::compile_kernel(const uint kernel_features, # ifdef _DEBUG options.append(" -save-temps"); # endif - options.append(" --amdgpu-target=").append(props.gcnArchName); + options.append(" --amdgpu-target=").append(arch); const string include_path = source_path; - const char *const kernel_arch = props.gcnArchName; - const string fatbin_file = string_printf( - "cycles_%s_%s_%s", name, kernel_arch, kernel_md5.c_str()); + const string fatbin_file = string_printf("cycles_%s_%s_%s", name, arch, kernel_md5.c_str()); const string fatbin = path_cache_get(path_join("kernels", fatbin_file)); VLOG(1) << "Testing for locally compiled kernel " << fatbin << "."; if (path_exists(fatbin)) { @@ -406,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 */ |