diff --git a/SYCL/Basic/info_ocl_version.cpp b/SYCL/Basic/info_ocl_version.cpp deleted file mode 100644 index 23e19affc0..0000000000 --- a/SYCL/Basic/info_ocl_version.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -// RUN: env %CPU_RUN_PLACEHOLDER %t.out -// RUN: env %GPU_RUN_PLACEHOLDER %t.out -// RUN: env %ACC_RUN_PLACEHOLDER %t.out - -//==--------info_ocl_version.cpp - SYCL objects get_info() test ------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include -#include -#include -#include - -using namespace sycl; - -// This test checks that sycl::info::device::version -// is returned in a form: . - -int main() { - default_selector selector; - device dev(selector.select_device()); - auto ocl_version = dev.get_info(); - std::cout << ocl_version << std::endl; - const std::regex oclVersionRegex("[0-9]\\.[0-9]"); - if (!std::regex_match(ocl_version, oclVersionRegex)) { - std::cout << "Failed" << std::endl; - return 1; - } - std::cout << "Passed" << std::endl; - return 0; -} diff --git a/SYCL/GroupAlgorithm/SYCL2020/support.h b/SYCL/GroupAlgorithm/SYCL2020/support.h index 9a37708eb6..0df7afb7c9 100644 --- a/SYCL/GroupAlgorithm/SYCL2020/support.h +++ b/SYCL/GroupAlgorithm/SYCL2020/support.h @@ -11,11 +11,10 @@ bool isSupportedDevice(device D) { if (PlatformName.find("OpenCL") != std::string::npos) { std::string Version = D.get_info(); - size_t Offset = Version.find("OpenCL"); - if (Offset == std::string::npos) - return false; - Version = Version.substr(Offset + 7, 3); - if (Version >= std::string("2.0")) + + // Group collectives are mandatory in OpenCL 2.0 but optional in 3.0. + Version = Version.substr(7, 3); + if (Version >= "2.0" && Version < "3.0") return true; } diff --git a/SYCL/GroupAlgorithm/support.h b/SYCL/GroupAlgorithm/support.h index b793713f57..ef3be0138d 100644 --- a/SYCL/GroupAlgorithm/support.h +++ b/SYCL/GroupAlgorithm/support.h @@ -15,11 +15,10 @@ bool isSupportedDevice(device D) { if (PlatformName.find("OpenCL") != std::string::npos) { std::string Version = D.get_info(); - size_t Offset = Version.find("OpenCL"); - if (Offset == std::string::npos) - return false; - Version = Version.substr(Offset + 7, 3); - if (Version >= std::string("2.0")) + + // Group collectives are mandatory in OpenCL 2.0 but optional in 3.0. + Version = Version.substr(7, 3); + if (Version >= "2.0" && Version < "3.0") return true; } diff --git a/SYCL/SubGroup/helper.hpp b/SYCL/SubGroup/helper.hpp index 5c45a28978..bb5be40f21 100644 --- a/SYCL/SubGroup/helper.hpp +++ b/SYCL/SubGroup/helper.hpp @@ -169,5 +169,16 @@ bool core_sg_supported(const device &Device) { auto Vec = Device.get_info(); if (std::find(Vec.begin(), Vec.end(), "cl_khr_subgroups") != std::end(Vec)) return true; - return Device.get_info() >= "2.1"; + + if (Device.get_backend() == sycl::backend::opencl) { + // Extract the numerical version from the version string, OpenCL version + // string have the format "OpenCL . ". + std::string ver = Device.get_info().substr(7, 3); + + // cl_khr_subgroups was core in OpenCL 2.1 and 2.2, but went back to + // optional in 3.0 + return ver >= "2.1" && ver < "3.0"; + } + + return false; }