From 9dff128d42540facd7860a3afa81a16b3eef0002 Mon Sep 17 00:00:00 2001 From: Kevin Petit Date: Wed, 31 Jul 2019 15:22:35 +0100 Subject: [PATCH] Extend version checks in subgroup test to support all cases To prepare for merging the cl20_trunk branch. Signed-off-by: Kevin Petit --- test_common/harness/testHarness.h | 2 ++ test_conformance/subgroups/main.cpp | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test_common/harness/testHarness.h b/test_common/harness/testHarness.h index 4668d68d..e34b0ab6 100644 --- a/test_common/harness/testHarness.h +++ b/test_common/harness/testHarness.h @@ -39,6 +39,8 @@ public: Version() : m_major(0), m_minor(0) {} Version(int major, int minor) : m_major(major), m_minor(minor) {} bool operator>(const Version& rhs) const { return to_int() > rhs.to_int(); } + bool operator<(const Version& rhs) const { return to_int() < rhs.to_int(); } + bool operator==(const Version& rhs) const { return to_int() == rhs.to_int(); } int to_int() const { return m_major * 10 + m_minor; } std::string to_string() const { diff --git a/test_conformance/subgroups/main.cpp b/test_conformance/subgroups/main.cpp index c216f418..6863634e 100644 --- a/test_conformance/subgroups/main.cpp +++ b/test_conformance/subgroups/main.cpp @@ -33,7 +33,22 @@ const int test_num = ARRAY_SIZE( test_list ); static test_status checkSubGroupsExtension(cl_device_id device) { - if (!is_extension_available(device, "cl_khr_subgroups")) { + // The extension is optional in OpenCL 2.0 (minimum required version) and + // required in later versions. + auto version = get_device_cl_version(device); + + if (version < Version(2, 0)) { + return TEST_SKIP; + } + + bool hasExtension = is_extension_available(device, "cl_khr_subgroups"); + + if ((version == Version(2, 0)) && !hasExtension) { + log_info("Device does not support 'cl_khr_subgroups'. Skipping the test.\n"); + return TEST_SKIP; + } + + if ((version > Version(2, 0)) && !hasExtension) { log_error("'cl_khr_subgroups' is a required extension, failing.\n"); return TEST_FAIL; }