-
Notifications
You must be signed in to change notification settings - Fork 752
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] Adding support for 'sycl_special_class' attribute. #3892
Conversation
This attribute is used in SYCL headers to mark SYCL classes which need additional compiler handling when passed from host to device. Attribute can be applied to struct/class and can have optional argument which indicates kind of SYCL special class, so it can be used to implement handling of some generic case of SYCL special class as well as implement different handling for each kind of SYCL special class. Usage: ``` class __attribute__((sycl_special_class(accessor))) accessor { ... } ```
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
@Fznamznon There are still some issues. I am trying to compile this test case: #include "sycl.hpp"
sycl::queue myQueue;
class __attribute__((sycl_special_class(accessor))) AccessorBase {
int A;
public:
sycl::accessor<int, 1, sycl::access::mode::read_write,
sycl::access::target::local>
acc;
};
int main() {
AccessorBase AS;
myQueue.submit([&](sycl::handler &h) {
h.single_task<class XYZ>([=]() {
AS.acc.use();
});
});
return 0;
} First is this a legal test case? If it is, I am expecting that the __init method be created. But it crashing with an assert at handleSpecialType because InitMethod is null. The same test using class AccessorBase instead, is creating the __init method. As far as I can tell, it is happening during the call to visitRecord. With the attribute sycl_special_class(accessor) , the call to the function visitRecord doesn’t happen before handleSpecialType. And this function is using the InitMethod. What am I missing? Should handleSpecialType call visitRecord? |
@erichkeane Would you mind taking a loot at this and give me some feedback. I have added the attribute, but getting a crash in the handleSpecialType because the __init function is not created. Can you please let me know if the test case I am using (comment above) is actually correct and what I am missing? thanks. |
Please keep in mind the idea described by Victor here #2091 (comment) , so the original patch needs rework.
It should be defined by the class that have |
Yep, exactly this. Any types with this attribute need to have their __init method DEFINED. The attribute then is supposed to cause the SemaSYCL visitor handling to emit a call to said __init method. |
@erichkeane Ok thanks. |
In the source code? Check out how accessor is implemented today. It needs to still have that __init method. The point of this patch is for the library code to still be more or less like it is now, except with the added attribute so that we're not detecting these 'special' types directly by name. |
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
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.
@zahiraam, you need to add // clang-format on line1597 instead of line#1588
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
I remember that i did this on one of my PR #2399 suggested by reviewer. I am not sure whether this is the norm for clang-format fails. Tagging @bader for this specific question? |
@keryell Yes that's the version I am using! |
I don't think we should apply suggestion for the test from #2399 for DCP++ runtime headers. @intel/llvm-reviewers-runtime, does this suggestion works for you? |
Do not think we should do it for runtime headers either. |
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Removing the clang-format directives and fixing lines 1575 didn't work. I am going for the more aggressive indentation fix even if it looks like an "unrelated" change. clang-format thinks that it is! |
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
The suggested change doesn't look correct to me. It seems that ifdef directive confuses clang-format. I suggest we discuss this issue in separate PR as it's not related here. I'm okay to ignore clang-format failure. |
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Actually, can you update your PR description - that will be the commit message. It is currently outdated. |
@againull, @intel/llvm-reviewers-runtime, ping. |
Special classes such as accessor, sampler, and stream need additional implementation when they are passed from host to device. Currently the compiler recognizes these classes by their name.
This patch is adding a new attribute “sycl_special_class” used to mark SYCL classes that need the additional compiler handling.
Usage: