-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Start fully-qualifying our inline kernel names in forward decl… #4220
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
Merged
romanovvlad
merged 4 commits into
intel:sycl
from
erichkeane:better_qualified_kernel_names
Aug 3, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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
124 changes: 124 additions & 0 deletions
124
clang/test/CodeGenSYCL/int_header_namespaced_inline_decls.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,124 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -fsycl-int-header=%t.h %s -o %t.out | ||
// RUN: FileCheck -input-file=%t.h %s | ||
|
||
// This test validates the behavior of inline-kernel-names to try to put them in | ||
// the 'closest' possible namespace. | ||
|
||
#include "Inputs/sycl.hpp" | ||
|
||
using namespace sycl; | ||
|
||
// Forward declarations of templated kernel function types: | ||
|
||
namespace TopLevel { | ||
void use() { | ||
kernel_single_task<class DirectTopLevel>([]() {}); | ||
// CHECK: namespace TopLevel { | ||
// CHECK-NEXT: class DirectTopLevel; | ||
// CHECK-NEXT: } | ||
} | ||
|
||
struct TypeName { | ||
void member_func() { | ||
kernel_single_task<class DirectTopLevelMemFunc>([]() {}); | ||
// CHECK: namespace TopLevel { | ||
// CHECK-NEXT: class DirectTopLevelMemFunc; | ||
// CHECK-NEXT: } | ||
} | ||
}; | ||
|
||
extern "C" { | ||
void use1() { | ||
kernel_single_task<class DirectTopLevelLinkage>([]() {}); | ||
// CHECK: namespace TopLevel { | ||
// CHECK-NEXT: class DirectTopLevelLinkage; | ||
// CHECK-NEXT: } | ||
} | ||
struct LinkageTypeName { | ||
void member_func() { | ||
kernel_single_task<class DirectTopLevelLinkageMemFunc>([]() {}); | ||
// CHECK: namespace TopLevel { | ||
// CHECK-NEXT: class DirectTopLevelLinkageMemFunc; | ||
// CHECK-NEXT: } | ||
} | ||
}; | ||
} | ||
} // namespace TopLevel | ||
|
||
namespace { | ||
void use2() { | ||
kernel_single_task<class TopLevelAnonNS>([]() {}); | ||
// CHECK: namespace { | ||
// CHECK-NEXT: class TopLevelAnonNS; | ||
// CHECK-NEXT: } | ||
} | ||
|
||
struct LinkageTypeName { | ||
void member_func() { | ||
kernel_single_task<class AnonNSMemFunc>([]() {}); | ||
// CHECK: namespace { | ||
// CHECK-NEXT: class AnonNSMemFunc; | ||
// CHECK-NEXT: } | ||
} | ||
}; | ||
} // namespace | ||
|
||
inline namespace InlineTopLevel { | ||
void use3() { | ||
kernel_single_task<class InlineDirectTopLevel>([]() {}); | ||
// CHECK: inline namespace InlineTopLevel { | ||
// CHECK-NEXT: class InlineDirectTopLevel; | ||
// CHECK-NEXT: } | ||
} | ||
struct LinkageTypeName { | ||
void member_func() { | ||
kernel_single_task<class InlineNSMemFunc>([]() {}); | ||
// CHECK: inline namespace InlineTopLevel { | ||
// CHECK-NEXT: class InlineNSMemFunc; | ||
// CHECK-NEXT: } | ||
} | ||
}; | ||
|
||
inline namespace { | ||
void use4() { | ||
kernel_single_task<class AnonNS>([]() {}); | ||
// CHECK: inline namespace { | ||
// CHECK-NEXT: class AnonNS; | ||
// CHECK-NEXT: } | ||
} | ||
|
||
extern "C" { | ||
void use5() { | ||
kernel_single_task<class AnonNSLinkage>([]() {}); | ||
// CHECK: inline namespace { | ||
// CHECK-NEXT: class AnonNSLinkage; | ||
// CHECK-NEXT: } | ||
} | ||
} | ||
struct LinkageTypeName { | ||
void member_func() { | ||
kernel_single_task<class InlineAnonNSMemFunc>([]() {}); | ||
// CHECK: inline namespace { | ||
// CHECK-NEXT: class InlineAnonNSMemFunc; | ||
// CHECK-NEXT: } | ||
} | ||
}; | ||
} // namespace | ||
} // namespace TopLevel | ||
|
||
namespace A { | ||
namespace B { | ||
namespace { | ||
namespace C::D { | ||
struct DeepStruct { | ||
void member_func() { | ||
kernel_single_task<class WoahDeep>([]() {}); | ||
// CHECK: namespace A { namespace B { namespace { namespace C { namespace D { | ||
// CHECK-NEXT: class WoahDeep; | ||
// CHECK-NEXT: }}}}} | ||
} | ||
}; | ||
} // namespace C::D | ||
} // namespace | ||
} // namespace B | ||
} // namespace A |
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
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
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
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
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
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
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
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.
Can you point me to where this 'technically violates SYCL rules'? Also, what happens when the declarations are in the same namespace but the context is technically different? For e.g.
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.
I think this is supposed to be part of this line:
here: https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:naming.kernels
That at least prohibits your example (since they are the same name in the same enclosing namespace), but I don't know what prevents something like:
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.
@AlexeySachkov : Can you help with the above standards interpretation there?
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.
Ok. Thank you for clarification