-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][Docs] Align kernel_args_restrict extension with SYCL 2020 to inherit critical fixes #5793
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
[SYCL][Docs] Align kernel_args_restrict extension with SYCL 2020 to inherit critical fixes #5793
Conversation
602092e
to
b23a5fc
Compare
Since you are updating this extension doc anyway, can you use the new template and follow the conventions described in README-process? |
I have now updated to the latest template, so ready for review. |
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, Mike. This looks a lot better. A couple of comments below.
callable to which the attribute was applied. The attribute can be applied | ||
to kernel lambdas or function call operators, or arbitrary functions (the | ||
effect on arbitrary functions, if any, is implementation defined), to provide | ||
the compiler with additional information for optimization. |
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'd suggest different wording here because:
-
The phrase "pointer member of any accessors" is an implementation detail. We should just talk about "accessor" here, not about a member inside that accessor.
-
There is no need to list all the ways that an application can pass a kernel argument. This is already defined in the core SYCL spec.
-
We should not say that the attribute can be applied to arbitrary functions. We only define meaning in the case when it is applied to a kernel. The core SYCL spec already says:
Applying these attributes to any language construct other than those specified in this section has implementation-defined effect.
I'd suggest something like this:
This extension adds a kernel function attribute that has similar effect as the C99
restrict
type qualifier. When a kernel is decorated with this attribute, all pointers and accessors that are captured as kernel arguments and are used to write memory are assumed to point to disjoint objects in memory.
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.
The phrase "pointer member of any accessors" is an implementation detail. We should just talk about "accessor" here, not about a member inside that accessor.
I like simplifying this, but we originally said "pointer member" because it isn't clear that applying restrict
to an object wrapping a pointer has the necessary semantic. Restrict qualifies a pointer, which an accessor is not. Thoughts otherwise?
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 agree that the C99 definition of restrict
is defined in terms of pointers, so it's not really correct to say that this C++ attribute is "equivalent" to specifying restrict
on each pointer and accessor argument. This is why I proposed the wording below that says "conceptually equivalent". I admit that this is not super precise, though.
Saying "pointer member" also seems wrong to me, though. For example, we have talked about changing the implementation of accessor, so that it internally contains two pointers. In such a case, those two internal pointers would alias each other.
I think a perfectly precise wording would require duplicating much of the wording for restrict
, but rewording to say "pointer or accessor". I'm not opposed to this, but it will make the spec more verbose. (For reference, here is the cppreference link for restrict.)
Maybe there is some middle ground where we say something like:
Hint to the compiler that is equivalent to specifying the C99
restrict
type qualifier to every pointer and accessor that is captured as an argument to this kernel function. Since the C99 definition ofrestrict
applies only to pointers, each accessor must be considered a conceptual pointer for the purpose of this definition.
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 your latest suggestion would work. We could also go with more like:
This extension adds a kernel function attribute that has similar effect as the C99 restrict type qualifier. When a kernel is decorated with this attribute, all pointers and accessors (treated as if each accessor was a pointer) that are captured as kernel arguments and are used to write memory are assumed to point to disjoint objects in memory.
Preference?
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.
Yes, that seems good.
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 updated with the new wording, with the only exception that I removed "and are used to write memory". I don't think that's actually correct - all pointers should have the qualifier.
on all pointer arguments or the pointer member of any accessors, which are a | ||
function argument, lambda capture, or function object member, of the callable | ||
to which the attribute was applied. This effect is equivalent to annotating | ||
[code]#restrict# on *all* kernel pointer arguments in an OpenCL or SPIR-V kernel. |
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'd suggest different wording here to for the same reasons I cite above. Maybe something like:
Hint to the compiler that is conceptually equivalent to specifying the C99
restrict
type qualifier on every pointer or accessor that is captured as an argument to this kernel function.
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.
Done
… SYCL2020, but didn't make it into this extension. Inherit the correct attribute location for function objects. Signed-off-by: Michael Kinsner <[email protected]>
Signed-off-by: Michael Kinsner <[email protected]>
821097e
to
4c7f2b3
Compare
Signed-off-by: Michael Kinsner <[email protected]>
attribute on all pointers and accessors (treated as if each accessor was a | ||
pointer) that are captured as kernel arguments. This effect is equivalent to | ||
annotating `restrict` on *all* kernel pointer arguments in an OpenCL or | ||
SPIR-V kernel. |
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 still don't like this last sentence:
This effect is equivalent to annotating
restrict
on all kernel pointer arguments in an OpenCL or SPIR-V kernel.
There are two reasons I don't like it:
-
It's very unclear what this really means. This is a SYCL extension, not an OpenCL or SPIR-V extension. Users don't write OpenCL or SPIR-V directly. In fact, some of our targets don't use either of those underlying technologies. The semantics of the extension should be described purely in SYCL terms, not on some implementation detail that applies to only some targets.
-
If we assume this statement is talking about the SPIR-V code that is generated from SYCL, it's not strictly true. If we were to implement accessors with two internal pointers (which we have contemplated), then those two internal pointers would alias with one another. The
[[intel::kernel_args_restrict]]
attribute should still apply in this case. It means that the accessors don't alias. It doesn't provide a guarantee about all the internal pointers used to implement accessors.
sycl/doc/extensions/supported/sycl_ext_intel_kernel_args_restrict.asciidoc
Outdated
Show resolved
Hide resolved
Signed-off-by: Michael Kinsner <[email protected]>
Align kernel_args_restrict extension with fixes that we factored into SYCL2020, but didn't make it into this extension. Inherit the correct attribute location for function objects.
Signed-off-by: Michael Kinsner [email protected]