[Beignet] [PATCH 06/14] Utest: Add check subgroup short helper function

Xiuli Pan xiuli.pan at intel.com
Wed Oct 12 08:56:36 UTC 2016


From: Pan Xiuli <xiuli.pan at intel.com>

Check if the device support intel_subgroups_short extension, also check
if the device support intel_subgroups extension first.

Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
 utests/utest_helper.cpp | 20 ++++++++++++++++++++
 utests/utest_helper.hpp |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index d3fc069..f1f5af4 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -899,6 +899,26 @@ int cl_check_subgroups(void)
   return 1;
 }
 
+int cl_check_subgroups_short(void)
+{
+  if (!cl_check_subgroups())
+    return 0;
+  std::string extStr;
+  size_t param_value_size;
+  OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_EXTENSIONS, 0, 0, &param_value_size);
+  std::vector<char> param_value(param_value_size);
+  OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_EXTENSIONS, param_value_size,
+           param_value.empty() ? NULL : &param_value.front(), &param_value_size);
+  if (!param_value.empty())
+    extStr = std::string(&param_value.front(), param_value_size-1);
+
+  if (std::strstr(extStr.c_str(), "cl_intel_subgroups_short") == NULL) {
+    printf("No cl_intel_subgroups_short, Skip!");
+    return 0;
+  }
+  return 1;
+}
+
 int cl_check_ocl20(void)
 {
   size_t param_value_size;
diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp
index 034a411..0f4a1ef 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -318,4 +318,6 @@ extern uint32_t __half_to_float(uint16_t h, bool* isInf = NULL, bool* infSign =
 extern uint16_t __float_to_half(uint32_t x);
 extern float as_float(uint32_t i);
 extern uint32_t as_uint(float f);
+/* Check is intel subgroups short enabled. */
+extern int cl_check_subgroups_short(void);
 #endif /* __UTEST_HELPER_HPP__ */
-- 
2.7.4



More information about the Beignet mailing list