-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL][ABI Break] Remove "cl" namespace #6518
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
Conversation
2336f6e
to
75ef986
Compare
SPIRV upstream change: KhronosGroup/SPIRV-LLVM-Translator#1564 |
As part of the change, also start using "inline namespace _V1" to allow possible future ABI-affecting changes.
@@ -104,7 +104,7 @@ def __init__(self, class_type, result_type, depth): | |||
self.depth = depth | |||
|
|||
def get_arg_types(self): | |||
return gdb.lookup_type("cl::sycl::id<%s>" % self.depth) | |||
return gdb.lookup_type("sycl::_V1::id<%s>" % self.depth) |
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.
Not sure how this file is being tested, so the changes here are "blind".
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.
@stevemerr, do you know?
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 suspect any end-to-end testing that would run gdb-oneapi on a sycl sample would exercise this file.
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.
Does this need to be sycl::_V1::id
or can we just do sycl::id
?
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.
This PRs makes it sycl::_V1::id
to give us a chance to avoid ABI-breakage in the future by switching to sycl::_V2::id
while preserving the binary impl for _V1
.
/verify with intel/llvm-test-suite#1128 |
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.
FE changes look good to me.
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.
FE changes OK to me.
llvm-spirv/lib/SPIRV/SPIRVUtil.cpp
Outdated
@@ -303,7 +303,7 @@ bool isSYCLBfloat16Type(llvm::Type *Ty) { | |||
return false; | |||
StringRef Name = ST->getName(); | |||
Name.consume_front("class."); | |||
if ((Name.startswith("cl::sycl::") || | |||
if ((Name.startswith("cl::sycl::") || Name.startswith("sycl::_V1::") || |
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.
This is mostly my ignorance. can you please outline why we used sycl::_V1 here and just sycl earlier? Also, in the upstream change, I see only sycl here. Thanks
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.
This PR makes two independent changes at once, only because decoupling them would be lots of useless work with little benefit.
First change is to get rid of cl::
and put sycl
directly into the global namespace.
The second part is groundwork for possible future ABI breaking changes. The idea is that if we'd need, for example, make ABI breaking changes into sycl::queue
, we'll do something like this:
// sycl.hpp:
namespace sycl {
inline namespace _V2 {
class queue {}; // That's what new code compiled with new compiler/RT would refer to by sycl::queue
}
}
// sycl_queue_v1_compat.cpp, linked into future libsycl.so
namespace sycl {
namespace _V1 {
class queue { ... }; // Old binaries linked with new sycl.so would use this.
// Old implementation
}
}
The exact machinery for that is to be defined later when/if we'd actually need it. However, we need to introduce _V
right now because if our current queue
would be sycl::queue
instead of sycl::_V1::queue
(that's how inline namespace is being mangled) we won't have any possibility to implement the sketchy solution above.
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.
Actually, I probably misunderstood the question. The proper fix upstream is using ^sycl::
, without _V1
so that it would work if/when we'll start using sycl::_V2
symbols.
The final version will be what upstream has.
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.
Thanks for the explanation Andrei. I understand now. I think this is good as long as it is documented somewhere.
I can approve the SPIRV changes. Thanks for this.
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'm not sure I follow what problem llvm-spirv translator changes solves. What will happen when runtime will switch to sycl::_V2 symbols? Translator will leave bfloat16 types as user defined types instead of SPIR-V buillt-in types. Right?
In general, please, avoid making local changes to the translator. All changes should be committed to the Khronos repository. Ideally we should remove the copy of sources from our repository and fetch them directly from the Khronos repository.
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.
LGTM
static std::array<Util::DeclContextDesc, 3> Scopes = { | ||
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"}, | ||
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"}, | ||
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "_V1"}, |
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.
Do you we have SYCL 1.2.1 compatibility tests?
https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:headers-and-namespaces
We should have them in SYCL-CTS and make sure that DPC++ complies.
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.
Are we talking source-compatible or binary-compatible? The former is being done with namespace alias as part of this PR (I might need to add an explicit test for that though), while the latter shouldn't (can't?) be done.
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 we are talking about source-compatibility. Yes, please, add SYCL-1.2.1 compatibility test to make sure that when <CL/sycl.hpp> is included, we can still use data types defined in cl::sycl
namespace in device code.
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 we would need to account for both scopes (here and in Sema) for compatibility right?
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.
We need to remove these name based checks. Now that we're modifying namespaces, this isn't future proof at all. We should instead modify sycl_special
attribute to accept an argument and use that to do these checks where required.
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 we would need to account for both scopes (here and in Sema) for compatibility right?
I don't think we do, but I'd like to hear your reasoning why you think we might need that.
We need to remove these name based checks. ... We should instead modify
sycl_special
attribute...
That is way above my comfort level with the FE - I guess I'd need someone from FE to make that part of the change.
Also, IMO, it should be done in a separate patch (either before or after this PR).
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 don't think we do, but I'd like to hear your reasoning why you think we might need that.
If the cl/syc
l header is used as @bader mentioned above and users declare types using cl::sycl::aspect
, etc, wouldn't compiler checks like isDeviceAspectType
fail since it checks hard-coded scope which is now sycl::_V1::aspect
?
That is way above my comfort level with the FE - I guess I'd need someone from FE to make that part of the change.
Also, IMO, it should be done in a separate patch (either before or after this PR).
I can help with that. What is the timeline for this change 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.
Using cl/sycl.h
doesn't change ABI, only introduce namespace alias (https://godbolt.org/z/x17Toq5vY).
I can help with that. What is the timeline for this change like?
I don't think there are hard requirement other than the 2023 release, but this PR gets merge conflicts pretty easily and I really wouldn't want it to sit uncommitted for long.
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 Thanks for explaining. I guess this should work then, as long as we don't use older versions of cl/sycl.h
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.
ESIMD part LGTM
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.
Some minor comments, otherwise the runtime and the device headers look good.
The interfaces are simple and *very* unlikely to change. Also, changing _V1::cl_float to _V2::cl_float would work without versioning of the routines in __host_std as the arguments' types are part of the mangling already.
/verify with intel/llvm-test-suite#1128 |
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.
FE changes look good to me.
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.
SPIR-V changes look good. Thanks.
930fecd
/verify with intel/llvm-test-suite#1128 |
Given how easy it is to get into a merge conflict and how many approvals are required (and hard to get quickly enough), I don't think it will ever be green... @intel/llvm-gatekeepers , should we weaken the merge criteria here maybe? |
If your changes only remove "cl", then you have pre-approval from ESIMD (no need for explicit approval here). Otherwise, please ping @intel/dpcpp-esimd-reviewers |
They also contain corresponding changes in places where mangling matters, like ESIMDVerifier.cpp/LowerESIMD.cpp. |
1265739
/verify with intel/llvm-test-suite#1128 |
Failures on LLVM Test Suite precommit are expected and expected to pass in "verify with" testing. An exception is
which is most likely unrelated. I'd argue that (pending Jenkins/llvm-test-suite) we should proceed with merging this. If, in an unlikely event, of the failure being real I'll address it post-commit. Edit: Jenkins/precomit is clear. I believe this is as much ready for the merge as would ever be possible, despite missing some formal review approval statuses. @intel/llvm-gatekeepers would you agree to merge this in? |
As part of the change, also start using "inline namespace _V1" to allow
possible future ABI-affecting changes.