Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -11060,10 +11060,10 @@ def err_sycl_invalid_accessor_property_list_template_param : Error<
"%select{parameter pack|type|non-negative integer}1">;
def warn_sycl_pass_by_value_deprecated
: Warning<"Passing kernel functions by value is deprecated in SYCL 2020">,
InGroup<Sycl2020Compat>;
InGroup<Sycl2020Compat>, ShowInSystemHeader;
def warn_sycl_pass_by_reference_future
: Warning<"Passing of kernel functions by reference is a SYCL 2020 extension">,
InGroup<Sycl2017Compat>;
InGroup<Sycl2017Compat>, ShowInSystemHeader;
def warn_sycl_attibute_function_raw_ptr
: Warning<"SYCL 1.2.1 specification does not allow %0 attribute applied "
"to a function with a raw pointer "
Expand All @@ -11073,7 +11073,7 @@ def warn_sycl_implicit_decl
: Warning<"SYCL 1.2.1 specification requires an explicit forward "
"declaration for a kernel type name; your program may not "
"be portable">,
InGroup<SyclStrict>, DefaultIgnore;
InGroup<SyclStrict>, ShowInSystemHeader, DefaultIgnore;
def warn_sycl_restrict_recursion
: Warning<"SYCL kernel cannot call a recursive function">,
InGroup<SyclStrict>, DefaultError;
Expand Down
15 changes: 15 additions & 0 deletions clang/test/CodeGenSYCL/Inputs/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ ATTR_SYCL_KERNEL void kernel_single_task(const KernelType &kernelFunc) {
kernelFunc();
}

template <typename KernelName = auto_name, typename KernelType>
ATTR_SYCL_KERNEL void kernel_single_task_2017(KernelType kernelFunc) {
kernelFunc();
}

template <typename KernelName, typename KernelType, int Dims>
ATTR_SYCL_KERNEL void
kernel_parallel_for(const KernelType &KernelFunc) {
Expand Down Expand Up @@ -323,6 +328,16 @@ class handler {
kernel_single_task<NameT>(kernelFunc);
#else
kernelFunc();
#endif
}

template <typename KernelName = auto_name, typename KernelType>
void single_task_2017(KernelType kernelFunc) {
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
#ifdef __SYCL_DEVICE_ONLY__
kernel_single_task_2017<NameT>(kernelFunc);
#else
kernelFunc();
#endif
}
};
Expand Down
45 changes: 20 additions & 25 deletions clang/test/CodeGenSYCL/kernel-by-reference.cpp
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2017 -DSYCL2017 %s
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2020 -DSYCL2020 %s
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -Wno-sycl-strict -DNODIAG %s
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2020 -Wno-sycl-strict -DNODIAG %s
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -sycl-std=2017 -DSYCL2017 %s
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -sycl-std=2020 -DSYCL2020 %s
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -sycl-std=2020 -Wno-sycl-strict -DNODIAG %s
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -sycl-std=2020 -Wno-sycl-strict -DNODIAG %s

// SYCL 1.2/2017 - kernel functions passed directly. (Also no const requirement, though mutable lambdas never supported)
template <typename name, typename Func>
#if defined(SYCL2020)
// expected-warning@+2 {{Passing kernel functions by value is deprecated in SYCL 2020}}
#endif
__attribute__((sycl_kernel)) void sycl_2017_single_task(Func kernelFunc) {
kernelFunc();
}
#include "Inputs/sycl.hpp"

// SYCL 2020 - kernel functions are passed by reference.
template <typename name, typename Func>
#if defined(SYCL2017)
// expected-warning@+2 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
#endif
__attribute__((sycl_kernel)) void sycl_2020_single_task(const Func &kernelFunc) {
kernelFunc();
}
using namespace cl::sycl;

int do_nothing(int i) {
int simple_add(int i) {
return i + 1;
}

// ensure both compile.
int main() {
sycl_2017_single_task<class sycl12>([]() {
do_nothing(10);
queue q;
#if defined(SYCL2020)
// expected-warning@Inputs/sycl.hpp:285 {{Passing kernel functions by value is deprecated in SYCL 2020}}
// expected-note@+3 {{in instantiation of function template specialization}}
#endif
q.submit([&](handler &h) {
h.single_task_2017<class sycl2017>([]() { simple_add(10); });
});

sycl_2020_single_task<class sycl2020>([]() {
do_nothing(11);
#if defined(SYCL2017)
// expected-warning@Inputs/sycl.hpp:280 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
// expected-note@+3 {{in instantiation of function template specialization}}
#endif
q.submit([&](handler &h) {
h.single_task<class sycl2020>([]() { simple_add(11); });
});

return 0;
Expand Down
39 changes: 14 additions & 25 deletions clang/test/SemaSYCL/args-size-overflow.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
// RUN: %clang_cc1 -fsycl -triple spir64 -fsycl-is-device -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsycl -triple spir64 -Werror=sycl-strict -DERROR -fsycl-is-device -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsyntax-only -Wsycl-strict -sycl-std=2020 -verify %s

#include "Inputs/sycl.hpp"
class Foo;
class kernel;

template <typename Name, typename F>
__attribute__((sycl_kernel)) void kernel(F KernelFunc) {
KernelFunc();
}
using namespace cl::sycl;

template <typename Name, typename F>
void parallel_for(F KernelFunc) {
#ifdef ERROR
// expected-error@+4 {{size of kernel arguments (7994 bytes) may exceed the supported maximum of 2048 bytes on some devices}}
#else
// expected-warning@+2 {{size of kernel arguments (7994 bytes) may exceed the supported maximum of 2048 bytes on some devices}}
#endif
kernel<Name>(KernelFunc);
}
// expected-warning@Inputs/sycl.hpp:220 {{size of kernel arguments (8068 bytes) may exceed the supported maximum of 2048 bytes on some devices}}

using Accessor =
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer>;
int main() {

void use() {
struct S {
int A;
int B;
Accessor AAcc;
Accessor BAcc;
int Array[1991];
int Array[2015];
} Args;
auto L = [=]() { (void)Args; };
// expected-note@+1 {{in instantiation of function template specialization 'parallel_for<Foo}}
parallel_for<Foo>(L);

queue myQueue;

myQueue.submit([&](handler &cgh) {
// expected-note@+1 {{in instantiation of function template specialization 'cl::sycl::handler::single_task}}
cgh.single_task<class kernel>([=]() { (void)Args; });
});
return 0;
}
117 changes: 61 additions & 56 deletions clang/test/SemaSYCL/implicit_kernel_type.cpp
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsyntax-only -verify %s -Werror=sycl-strict -DERROR
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsyntax-only -verify %s -Wsycl-strict -DWARN
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsycl-unnamed-lambda -fsyntax-only -verify %s -Werror=sycl-strict
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsycl-int-header=%t.h -fsyntax-only -verify %s -Werror=sycl-strict -DERROR
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsycl-int-header=%t.h -fsyntax-only -verify %s -Wsycl-strict -DWARN
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsycl-int-header=%t.h -fsycl-unnamed-lambda -fsyntax-only -verify %s -Werror=sycl-strict

// SYCL 1.2 Definitions
template <typename name, typename Func>
__attribute__((sycl_kernel)) void sycl_121_single_task(Func kernelFunc) {
kernelFunc();
}

class event {};
class queue {
public:
template <typename T>
event submit(T cgf) { return event{}; }
};
class auto_name {};
template <typename Name, typename Type>
struct get_kernel_name_t {
using name = Name;
};
class handler {
public:
template <typename KernelName = auto_name, typename KernelType>
void single_task(KernelType kernelFunc) {
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
#ifdef __SYCL_DEVICE_ONLY__
sycl_121_single_task<NameT>(kernelFunc);
#else
kernelFunc();
#endif
}
};
// -- /Definitions

#ifdef __SYCL_UNNAMED_LAMBDA__
// expected-no-diagnostics
#endif
#include "Inputs/sycl.hpp"

using namespace cl::sycl;

// user-defined function
void function() {
}

// user-defined class
// user-defined struct
struct myWrapper {
};

Expand All @@ -50,34 +19,70 @@ class myWrapper2;

int main() {
queue q;
#ifndef __SYCL_UNNAMED_LAMBDA__
// expected-note@+3 {{InvalidKernelName1 declared here}}
// expected-note@+4{{in instantiation of function template specialization}}
// expected-error@28 {{kernel needs to have a globally-visible name}}

#if defined(WARN)
// expected-warning@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
// expected-note@+8 {{InvalidKernelName1 declared here}}
#elif defined(ERROR)
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
// expected-note@+4 {{InvalidKernelName1 declared here}}
#elif defined(__SYCL_UNNAMED_LAMBDA__)
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
#endif
class InvalidKernelName1 {};
// expected-note@+2 {{in instantiation of function template specialization}}
q.submit([&](handler &h) {
h.single_task<InvalidKernelName1>([]() {});
});
#endif

#if defined(WARN)
// expected-warning@+6 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-note@+5 {{fake_kernel declared here}}
// expected-warning@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-warning@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
#elif defined(ERROR)
// expected-error@+3 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-note@+2 {{fake_kernel declared here}}
// expected-error@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
#elif defined(__SYCL_UNNAMED_LAMBDA__)
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
#endif
sycl_121_single_task<class fake_kernel>([]() { function(); });

q.submit([&](handler &h) {
#ifndef __SYCL_UNNAMED_LAMBDA__
// expected-note@+3 {{fake_kernel declared here}}
#endif
// expected-note@+1 {{in instantiation of function template specialization}}
h.single_task<class fake_kernel>([]() { function(); });
});

#if defined(WARN)
// expected-warning@+6 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-note@+5 {{fake_kernel2 declared here}}
// expected-warning@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-warning@Inputs/sycl.hpp:211 3{{Passing of kernel functions by reference is a SYCL 2020 extension}}
#elif defined(ERROR)
// expected-error@+3 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-note@+2 {{fake_kernel2 declared here}}
// expected-error@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
// expected-error@Inputs/sycl.hpp:211 3{{Passing of kernel functions by reference is a SYCL 2020 extension}}
#elif defined(__SYCL_UNNAMED_LAMBDA__)
// expected-error@Inputs/sycl.hpp:211 3{{Passing of kernel functions by reference is a SYCL 2020 extension}}
#endif
sycl_121_single_task<class fake_kernel2>([]() {
auto l = [](auto f) { f(); };

q.submit([&](handler &h) {
#ifndef __SYCL_UNNAMED_LAMBDA__
// expected-note@+3 {{fake_kernel2 declared here}}
#endif
// expected-note@+1 {{in instantiation of function template specialization}}
h.single_task<class fake_kernel2>([]() {
auto l = [](auto f) { f(); };
});
});

q.submit([&](handler &h) {
// expected-note@+1 {{in instantiation of function template specialization}}
h.single_task<class myWrapper>([]() { function(); });
});

q.submit([&](handler &h) {
// expected-note@+1 {{in instantiation of function template specialization}}
h.single_task<class myWrapper2>([]() { function(); });
});
sycl_121_single_task<class myWrapper>([]() { function(); });
sycl_121_single_task<class myWrapper2>([]() { function(); });
return 0;
}
21 changes: 0 additions & 21 deletions sycl/test/basic_tests/args-size-overflow.cpp

This file was deleted.