[Bf-blender-cvs] [15c146091de] cycles_oneapi: Cycles: avoid using OpenCL for oneAPI devices enumeration

Xavier Hallade noreply at git.blender.org
Fri May 13 11:29:39 CEST 2022


Commit: 15c146091def58c6f1bd156611cda3efff982687
Author: Xavier Hallade
Date:   Wed May 11 14:57:06 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB15c146091def58c6f1bd156611cda3efff982687

Cycles: avoid using OpenCL for oneAPI devices enumeration

to also simplify and improve device filtering and branding
and remove dependency on pi_opencl library.

===================================================================

M	intern/cycles/kernel/device/oneapi/device_id.h
M	intern/cycles/kernel/device/oneapi/kernel.cpp

===================================================================

diff --git a/intern/cycles/kernel/device/oneapi/device_id.h b/intern/cycles/kernel/device/oneapi/device_id.h
index 02129ca1676..d27c553497e 100644
--- a/intern/cycles/kernel/device/oneapi/device_id.h
+++ b/intern/cycles/kernel/device/oneapi/device_id.h
@@ -3,31 +3,9 @@
 
 #pragma once
 
-// NOTE(sirgienko) List of PCI device ids, which correspond to allowed Intel GPUs
-// public source of device IDs :
+// from public source :
 // https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/include/pci_ids/iris_pci_ids.h
-const static std::set<uint32_t> oneapi_allowed_gpu_devices = {
-    // Alchemist dGPU, called DG2 before.
-#if 1
-    0x4f80,
-    0x4f81,
-    0x4f82,
-    0x4f83,
-    0x4f84,
-    0x4f87,
-    0x4f88,
-    0x5690,
-    0x5691,
-    0x5692,
-    0x5693,
-    0x5694,
-    0x5695,
-    0x56a0,
-    0x56a1,
-    0x56a2,
-    0x56a5,
-    0x56a6,
-    0x56b0,
-    0x56b1,
-#endif
-};
+const static std::set<uint32_t> intel_arc_alchemist_device_ids = {
+    0x4f80, 0x4f81, 0x4f82, 0x4f83, 0x4f84, 0x4f87, 0x4f88, 0x5690, 0x5691,
+    0x5692, 0x5693, 0x5694, 0x5695, 0x5696, 0x5697, 0x56a0, 0x56a1, 0x56a2,
+    0x56a3, 0x56a4, 0x56a5, 0x56a6, 0x56b0, 0x56b1, 0x56b2, 0x56b3};
diff --git a/intern/cycles/kernel/device/oneapi/kernel.cpp b/intern/cycles/kernel/device/oneapi/kernel.cpp
index bc521029d9b..2f8608da819 100644
--- a/intern/cycles/kernel/device/oneapi/kernel.cpp
+++ b/intern/cycles/kernel/device/oneapi/kernel.cpp
@@ -24,8 +24,7 @@
 static OneAPIErrorCallback s_error_cb = nullptr;
 static void *s_error_user_ptr = nullptr;
 
-static std::vector<sycl::device> oneapi_available_devices(
-    std::map<std::string, std::string> *proper_names_map = nullptr);
+static std::vector<sycl::device> oneapi_available_devices();
 
 void oneapi_set_error_cb(OneAPIErrorCallback cb, void *user_ptr)
 {
@@ -654,207 +653,134 @@ bool oneapi_enqueue_kernel(KernelContext *kernel_context,
   return success;
 }
 
-// TODO(sirgienko) Put proper linux driver version number here, when it will be known, which
-// exactly driver will have lowerest support
-static const int windows_lowest_supported_driver_build_version = 1011660;
-static const int linux_lowest_supported_driver_build_version = 20066;
+static const int lowest_supported_driver_version_win = 1011660;
+static const int lowest_supported_driver_version_neo = 20066;
 
-// Windows: os_type == 1
-// Linux: os_type == 2
-static int parse_driver_build_version(const sycl::device &device, int &os_type)
+static int parse_driver_build_version(const sycl::device &device)
 {
-  const std::string &device_name = device.get_info<sycl::info::device::name>();
   const std::string &driver_version = device.get_info<sycl::info::device::driver_version>();
+  int driver_build_version = 0;
 
-  // NOTE(sirgienko) Windows Intel GPUs driver version look like this:
-  //   xx.x.101.1340
-  // the 7 last digits are forming the version number.
-  // For more details, see
-  // https://www.intel.com/content/www/us/en/support/articles/000005654/graphics.html
-  if (std::count(driver_version.begin(), driver_version.end(), '.') == 3) {
-    os_type = 1;
-  }
-  // Linux versions examples: 22.01.022066, 22.01.018324
-  // Last number is used as driver version number.
-  else if (std::count(driver_version.begin(), driver_version.end(), '.') == 2) {
-    os_type = 2;
+  size_t second_dot_position = driver_version.find('.', driver_version.find('.') + 1);
+  if (second_dot_position == std::string::npos) {
+    std::cerr << "Unable to parse unknown Intel GPU driver version \"" << driver_version
+              << "\" does not match xx.xx.xxxxx (Linux), x.x.xxxx (L0),"
+              << " xx.xx.xxx.xxxx (Windows) for device \""
+              << device.get_info<sycl::info::device::name>() << "\"." << std::endl;
   }
   else {
-    std::cerr << "Unable to parse incorrect/unknown Intel GPU driver version \"" << driver_version
-              << "\" - device \"" << device_name << "\" will be skipped" << std::endl;
-    os_type = 0;
-    return 0;
-  }
-
-  size_t second_dot_position = driver_version.find('.', driver_version.find('.', 0) + 1);
-  // For easier parsing, let's consider third dot as an end string position for Linux version
-  // string
-  size_t third_dot_position = os_type == 1 ? driver_version.find('.', second_dot_position + 1) :
-                                             driver_version.length();
-
-  int driver_build_version = 0;
-  try {
-    const std::string &third_number_substr = driver_version.substr(
-        second_dot_position + 1, third_dot_position - second_dot_position - 1);
-    // Windows
-    if (os_type == 1) {
-      const std::string &forth_number_substr = driver_version.substr(
-          third_dot_position + 1, driver_version.length() - third_dot_position - 1);
-      if (third_number_substr.length() == 3 && forth_number_substr.length() == 4)
-        driver_build_version = std::stoi(third_number_substr) * 10000 +
-                               std::stoi(forth_number_substr);
-      else
-        std::cerr << "Unable to parse incorrect Intel GPU driver version \"" << driver_version
-                  << "\" - " << third_number_substr << "." << forth_number_substr
-                  << " does not match template xxx.xxxx, so device \"" << device_name
-                  << "\" be skipped" << std::endl;
-    }
-    // Linux
-    else if (os_type == 2) {
-      if (third_number_substr.length() == 5 || third_number_substr.length() == 6)
+    try {
+      size_t third_dot_position = driver_version.find('.', second_dot_position + 1);
+      if (third_dot_position != std::string::npos) {
+        const std::string &third_number_substr = driver_version.substr(
+            second_dot_position + 1, third_dot_position - second_dot_position - 1);
+        const std::string &forth_number_substr = driver_version.substr(third_dot_position + 1);
+        if (third_number_substr.length() == 3 && forth_number_substr.length() == 4)
+          driver_build_version = std::stoi(third_number_substr) * 10000 +
+                                 std::stoi(forth_number_substr);
+      }
+      else {
+        const std::string &third_number_substr = driver_version.substr(second_dot_position + 1);
         driver_build_version = std::stoi(third_number_substr);
-      else
-        std::cerr << "Unable to parse unknown Intel GPU driver version \"" << driver_version
-                  << "\" - the version does not match template xx.xx.xxxxx, so device \""
-                  << device_name << "\" will be skipped" << std::endl;
+      }
+    }
+    catch (std::invalid_argument &e) {
+      std::cerr << "Unable to parse unknown Intel GPU driver version \"" << driver_version
+                << "\" does not match xx.xx.xxxxx (Linux), x.x.xxxx (L0),"
+                << " xx.xx.xxx.xxxx (Windows) for device \""
+                << device.get_info<sycl::info::device::name>() << "\"." << std::endl;
     }
-  }
-  catch (std::invalid_argument &e) {
-    std::cerr << "Unable to parse unknown Intel GPU driver version \"" << driver_version
-              << "\" - throws number parse exception \"" << e.what() << "\" so device \""
-              << device_name << "\" will be skipped" << std::endl;
   }
 
   return driver_build_version;
 }
 
-static size_t make_device_uuid(const sycl::device &device)
+static std::string make_prettier_device_name(const std::string &orig_device_name)
 {
-  size_t max_compute_units = device.get_info<sycl::info::device::max_compute_units>();
-  size_t max_work_group_size = device.get_info<sycl::info::device::max_work_group_size>();
-  // Host device for some reason doesn't support this, so we set some default value
-  size_t max_clock_frequency = device.is_host() ?
-                                   0 :
-                                   device.get_info<sycl::info::device::max_clock_frequency>();
-
-  return max_compute_units << 20 | max_work_group_size << 10 | max_clock_frequency;
+  std::string new_device_name = orig_device_name;
+
+  size_t start_pos = new_device_name.find("(R)");
+  if (start_pos != std::string::npos) {
+    new_device_name.replace(start_pos, 3, "\xC2\xAE");
+  }
+
+  start_pos = new_device_name.find("(TM)");
+  if (start_pos != std::string::npos) {
+    new_device_name.replace(start_pos, 4, "\xE2\x84\xA2");
+  }
+
+  return new_device_name;
 }
 
-static std::vector<sycl::device> oneapi_available_devices(
-    std::map<std::string, std::string> *proper_names_map)
+static std::vector<sycl::device> oneapi_available_devices()
 {
   bool allow_all_devices = false;
   if (getenv("CYCLES_ONEAPI_ALL_DEVICES") != nullptr)
     allow_all_devices = true;
 
-  bool allow_host = false;
-  // Host device useful only for debugging so we hide this device with
-  // default build settings
+    // Host device is useful only for debugging at the moment
+    // so we hide this device with default build settings
 #  ifdef WITH_ONEAPI_SYCL_HOST_ENABLED
-  allow_host = true;
+  bool allow_host = true;
+#  else
+  bool allow_host = false;
 #  endif
 
-  // There are no benefits to support OpenCL backend, while we target L0 backend.
-  // Also, presenting two platforms in UI will give user an ability to choose one device for
-  // rendering twice: via OpenCL and via Level0, which doesn't make any sense (and will
-  // have obvious performance impact).
-  const static std::string level_zero_platform_name = "Intel(R) Level-Zero";
-  const static std::string opencl_platform_name = "Intel(R) OpenCL HD Graphics";
-  const static std::set<std::string> supported_platforms = {level_zero_platform_name};
-  const static bool is_level_zero_support_enabled = supported_platforms.find(
-                                                        level_zero_platform_name) !=
-                                                    supported_platforms.end();
   const std::vector<sycl::platform> &oneapi_platforms = sycl::platform::get_platforms();
 
-  // NOTE(sirgienko) Right now only OpenCL devices report GPU system driver version
-  // and proper device name. So we need to get driver info first by scanning for OpenCL platforms.
-  // And then filter-out devices by this information (and compute proper names in the same time)
-
-  // HW characteristics w

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list