From 01336a7a15f29a8a76f56b80cd2a0987c240c650 Mon Sep 17 00:00:00 2001 From: John Pennycook Date: Fri, 28 Feb 2020 05:22:01 -0800 Subject: [PATCH 1/2] [SYCL] Fix mismatch between sub_group headers sub_group::store took T& for host and const T& for device. Signed-off-by: John Pennycook --- sycl/include/CL/sycl/intel/sub_group_host.hpp | 2 +- .../regression/sub-group-store-const-ref.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 sycl/test/regression/sub-group-store-const-ref.cpp diff --git a/sycl/include/CL/sycl/intel/sub_group_host.hpp b/sycl/include/CL/sycl/intel/sub_group_host.hpp index d6fade163b117..16d9514fa4333 100644 --- a/sycl/include/CL/sycl/intel/sub_group_host.hpp +++ b/sycl/include/CL/sycl/intel/sub_group_host.hpp @@ -136,7 +136,7 @@ struct sub_group { } template - void store(multi_ptr dst, T &x) const { + void store(multi_ptr dst, const T &x) const { throw runtime_error("Subgroups are not supported on host device. "); } diff --git a/sycl/test/regression/sub-group-store-const-ref.cpp b/sycl/test/regression/sub-group-store-const-ref.cpp new file mode 100644 index 0000000000000..4959210388c45 --- /dev/null +++ b/sycl/test/regression/sub-group-store-const-ref.cpp @@ -0,0 +1,19 @@ +// RUN: %clangxx -I %sycl_include -fsyntax-only -Xclang -verify %s +// expected-no-diagnostics +// +//==-- sub-group-store-const-ref.cpp ---------------------------------------==// +// +// 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 +// +//===----------------------------------------------------------------------===// +// This test checks that sub_group::store supports const reference. +//===----------------------------------------------------------------------===// +#include +using namespace sycl; + +void test(intel::sub_group sg, global_ptr ptr) +{ + sg.store(ptr, 1); +} From 57eb5ff6a638382c829d1477d083cf5aebe8c3a8 Mon Sep 17 00:00:00 2001 From: John Pennycook Date: Fri, 28 Feb 2020 05:30:00 -0800 Subject: [PATCH 2/2] Run clang-format Signed-off-by: John Pennycook --- sycl/test/regression/sub-group-store-const-ref.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sycl/test/regression/sub-group-store-const-ref.cpp b/sycl/test/regression/sub-group-store-const-ref.cpp index 4959210388c45..991f56f30a130 100644 --- a/sycl/test/regression/sub-group-store-const-ref.cpp +++ b/sycl/test/regression/sub-group-store-const-ref.cpp @@ -13,7 +13,4 @@ #include using namespace sycl; -void test(intel::sub_group sg, global_ptr ptr) -{ - sg.store(ptr, 1); -} +void test(intel::sub_group sg, global_ptr ptr) { sg.store(ptr, 1); }