-
Notifications
You must be signed in to change notification settings - Fork 797
[SYCL] Free function kernels bugfix #19535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlexeySachkov
wants to merge
3
commits into
intel:sycl
Choose a base branch
from
AlexeySachkov:private/asachkov/custom-types-printer-for-int-header
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
clang/test/CodeGenSYCL/free-function-kernel-templated-arg-with-enum.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -sycl-std=2020 -fsycl-int-header=%t.h %s | ||
// RUN: FileCheck -input-file=%t.h %s | ||
// | ||
// The purpose of this test is to ensure that forward declarations of free | ||
// function kernels are emitted properly. | ||
// However, this test checks a specific scenario: | ||
// - free function kernel is a function template | ||
// - its argument is templated and has non-type template parameter (with default | ||
// value) that is an enumeration defined within a namespace | ||
|
||
namespace ns { | ||
|
||
enum class enum_A { A, B, C }; | ||
|
||
template<typename T, enum_A V = enum_A::B> | ||
class feature_A {}; | ||
|
||
namespace nested { | ||
enum class enum_B { A, B, C }; | ||
|
||
template<typename T, int V, enum_B V2 = enum_B::A, enum_A V3 = enum_A::C> | ||
struct feature_B {}; | ||
} | ||
|
||
inline namespace nested_inline { | ||
namespace nested2 { | ||
enum class enum_C { A, B, C }; | ||
|
||
template<int V = 42, enum_C V2 = enum_C::B> | ||
struct feature_C {}; | ||
} | ||
} // namespace nested_inline | ||
} // namespace ns | ||
|
||
template<typename T> | ||
[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] | ||
void templated_on_A(ns::feature_A<T> Arg) {} | ||
template void templated_on_A(ns::feature_A<int>); | ||
|
||
// CHECK: template <typename T> void templated_on_A(ns::feature_A<T, ns::enum_A::B>); | ||
|
||
template<typename T, int V = 42> | ||
[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] | ||
void templated_on_B(ns::nested::feature_B<T, V> Arg) {} | ||
template void templated_on_B(ns::nested::feature_B<int, 12>); | ||
|
||
// CHECK: template <typename T, int V> void templated_on_B(ns::nested::feature_B<T, V, ns::nested::enum_B::A, ns::enum_A::C>); | ||
|
||
template<int V> | ||
[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] | ||
void templated_on_C(ns::nested2::feature_C<V> Arg) {} | ||
template void templated_on_C(ns::nested2::feature_C<42>); | ||
|
||
// CHECK: template <int V> void templated_on_C(ns::nested2::feature_C<V, ns::nested2::enum_C::B>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,17 +267,17 @@ namespace Testing::Tests { | |
// CHECK-NEXT: return (void (*)(struct ns::Arg<class ns::ns1::hasDefaultArg<struct ns::notatuple>, int, 12, struct ns::notatuple>))simple1; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple> , T end); | ||
// CHECK: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple, <>>, T); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two changes here:
|
||
// CHECK-NEXT: static constexpr auto __sycl_shim3() { | ||
// CHECK-NEXT: return (void (*)(struct ns::Arg<int, float, 3, struct ns::notatuple>, int))templated<int>; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename T> void templated2(ns::Arg<T, ns::notatuple, 12, ns::notatuple> , T end); | ||
// CHECK: template <typename T> void templated2(ns::Arg<T, ns::notatuple, 12, ns::notatuple, <>>, T); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim4() { | ||
// CHECK-NEXT: return (void (*)(struct ns::Arg<int, struct ns::notatuple, 12, struct ns::notatuple>, int))templated2<int>; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename T, int a> void templated3(ns::Arg<T, ns::notatuple, a, ns::ns1::hasDefaultArg<ns::notatuple>, int, int> , T end); | ||
// CHECK: template <typename T, int a> void templated3(ns::Arg<T, ns::notatuple, a, ns::ns1::hasDefaultArg<ns::notatuple>, int, int>, T); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim5() { | ||
// CHECK-NEXT: return (void (*)(struct ns::Arg<int, struct ns::notatuple, 3, class ns::ns1::hasDefaultArg<struct ns::notatuple>, int, int>, int))templated3<int, 3>; | ||
// CHECK-NEXT: } | ||
|
@@ -297,7 +297,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: } | ||
|
||
// CHECK: namespace TestNamespace { | ||
// CHECK-NEXT: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple> , T end); | ||
// CHECK-NEXT: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple, <>>, T); | ||
// CHECK-NEXT: } // namespace TestNamespace | ||
|
||
// CHECK: static constexpr auto __sycl_shim8() { | ||
|
@@ -316,7 +316,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: namespace TestNamespace { | ||
// CHECK-NEXT: inline namespace _V1 { | ||
// CHECK-NEXT: template <typename T, int a> void templated1(ns::Arg<T, float, a, ns::notatuple> , T end); | ||
// CHECK-NEXT: template <typename T, int a> void templated1(ns::Arg<T, float, a, ns::notatuple, <>>, T); | ||
// CHECK-NEXT: } // inline namespace _V1 | ||
// CHECK-NEXT: } // namespace TestNamespace | ||
// CHECK: static constexpr auto __sycl_shim9() { | ||
|
@@ -335,7 +335,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: namespace TestNamespace { | ||
// CHECK-NEXT: inline namespace _V2 { | ||
// CHECK-NEXT: template <typename T, int a> void templated1(ns::Arg<T, T, a, ns::notatuple> , T end); | ||
// CHECK-NEXT: template <typename T, int a> void templated1(ns::Arg<T, T, a, ns::notatuple, <>>, T); | ||
// CHECK-NEXT: } // inline namespace _V2 | ||
// CHECK-NEXT: } // namespace TestNamespace | ||
// CHECK: static constexpr auto __sycl_shim10() { | ||
|
@@ -353,7 +353,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: } | ||
|
||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim11() { | ||
// CHECK-NEXT: return (void (*)(float, float))templated<float>; | ||
|
@@ -370,7 +370,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: } | ||
|
||
// CHECK: struct TestStruct; | ||
// CHECK: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple> , T end); | ||
// CHECK: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple, <>>, T); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim12() { | ||
// CHECK-NEXT: return (void (*)(struct ns::Arg<struct TestStruct, float, 3, struct ns::notatuple>, struct TestStruct))templated<struct TestStruct>; | ||
// CHECK-NEXT:} | ||
|
@@ -387,7 +387,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: class BaseClass; | ||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim13() { | ||
// CHECK-NEXT: return (void (*)(class BaseClass, class BaseClass))templated<class BaseClass>; | ||
|
@@ -405,7 +405,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: class ChildOne; | ||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim14() { | ||
// CHECK-NEXT: return (void (*)(class ChildOne, class ChildOne))templated<class ChildOne>; | ||
|
@@ -423,7 +423,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: class ChildTwo; | ||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim15() { | ||
// CHECK-NEXT: return (void (*)(class ChildTwo, class ChildTwo))templated<class ChildTwo>; | ||
|
@@ -441,7 +441,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: class ChildThree; | ||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim16() { | ||
// CHECK-NEXT: return (void (*)(class ChildThree, class ChildThree))templated<class ChildThree>; | ||
|
@@ -461,7 +461,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: template <int dim> struct id; | ||
// CHECK-NEXT: }} | ||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim17() { | ||
// CHECK-NEXT: return (void (*)(struct sycl::id<2>, struct sycl::id<2>))templated<struct sycl::id<2>>; | ||
|
@@ -481,7 +481,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: template <int dim> struct range; | ||
// CHECK-NEXT: }} | ||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim18() { | ||
// CHECK-NEXT: return (void (*)(struct sycl::range<3>, struct sycl::range<3>))templated<struct sycl::range<3>>; | ||
|
@@ -498,7 +498,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: } | ||
|
||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim19() { | ||
// CHECK-NEXT: return (void (*)(int *, int *))templated<int *>; | ||
|
@@ -515,7 +515,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: } | ||
|
||
// CHECK: namespace { | ||
// CHECK-NEXT: template <typename T> void templated(T start, T end); | ||
// CHECK-NEXT: template <typename T> void templated(T, T); | ||
// CHECK-NEXT: } // namespace | ||
// CHECK: static constexpr auto __sycl_shim20() { | ||
// CHECK-NEXT: return (void (*)(struct sycl::X<class ChildTwo>, struct sycl::X<class ChildTwo>))templated<struct sycl::X<class ChildTwo>>; | ||
|
@@ -536,7 +536,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: }}} | ||
// CHECK: namespace TestNamespace { | ||
// CHECK-NEXT: inline namespace _V1 { | ||
// CHECK-NEXT: template <typename T, int a> void templated1(ns::Arg<T, float, a, ns::notatuple> , T end); | ||
// CHECK-NEXT: template <typename T, int a> void templated1(ns::Arg<T, float, a, ns::notatuple, <>>, T); | ||
// CHECK-NEXT: } // inline namespace _V1 | ||
// CHECK-NEXT: } // namespace TestNamespace | ||
// CHECK: static constexpr auto __sycl_shim21() { | ||
|
@@ -553,7 +553,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: }; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename ... Args> void variadic_templated(Args... args); | ||
// CHECK: template <typename ... Args> void variadic_templated(Args...); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim22() { | ||
// CHECK-NEXT: return (void (*)(int, float, char))variadic_templated<int, float, char>; | ||
// CHECK-NEXT: } | ||
|
@@ -568,7 +568,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: }; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename ... Args> void variadic_templated(Args... args); | ||
// CHECK: template <typename ... Args> void variadic_templated(Args...); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim23() { | ||
// CHECK-NEXT: return (void (*)(int, float, char, int))variadic_templated<int, float, char, int>; | ||
// CHECK-NEXT: } | ||
|
@@ -583,7 +583,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: }; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename ... Args> void variadic_templated(Args... args); | ||
// CHECK: template <typename ... Args> void variadic_templated(Args...); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim24() { | ||
// CHECK-NEXT: return (void (*)(float, float))variadic_templated<float, float>; | ||
// CHECK-NEXT: } | ||
|
@@ -598,7 +598,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: }; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename T, typename ... Args> void variadic_templated1(T b, Args... args); | ||
// CHECK: template <typename T, typename ... Args> void variadic_templated1(T, Args...); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim25() { | ||
// CHECK-NEXT: return (void (*)(float, char, char))variadic_templated1<float, char, char>; | ||
// CHECK-NEXT: } | ||
|
@@ -613,7 +613,7 @@ namespace Testing::Tests { | |
// CHECK-NEXT: }; | ||
// CHECK-NEXT: } | ||
|
||
// CHECK: template <typename T, typename ... Args> void variadic_templated1(T b, Args... args); | ||
// CHECK: template <typename T, typename ... Args> void variadic_templated1(T, Args...); | ||
// CHECK-NEXT: static constexpr auto __sycl_shim26() { | ||
// CHECK-NEXT: return (void (*)(int, float, char))variadic_templated1<int, float, char>; | ||
// CHECK-NEXT: } | ||
|
@@ -630,7 +630,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: namespace Testing { | ||
// CHECK-NEXT: namespace Tests { | ||
// CHECK-NEXT: template <typename T, typename ... Args> void variadic_templated(T b, Args... args); | ||
// CHECK-NEXT: template <typename T, typename ... Args> void variadic_templated(T, Args...); | ||
// CHECK-NEXT: } // namespace Tests | ||
// CHECK-NEXT: } // namespace Testing | ||
// CHECK: static constexpr auto __sycl_shim27() { | ||
|
@@ -649,7 +649,7 @@ namespace Testing::Tests { | |
|
||
// CHECK: namespace Testing { | ||
// CHECK-NEXT: namespace Tests { | ||
// CHECK-NEXT: template <typename T, typename ... Args> void variadic_templated(T b, Args... args); | ||
// CHECK-NEXT: template <typename T, typename ... Args> void variadic_templated(T, Args...); | ||
// CHECK-NEXT: } // namespace Tests | ||
// CHECK-NEXT: } // namespace Testing | ||
// CHECK: static constexpr auto __sycl_shim28() { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewers: the exact thing which was missing is
ns::nested::
forenum_B::A
andns::
forenum_A::C
.