-
Notifications
You must be signed in to change notification settings - Fork 109
Add sycl quick refs #179
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
Add sycl quick refs #179
Conversation
If we think this is a good idea I can add sycl quick refs for all exercises. |
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 a good idea, thanks!
Haven't included: Ex 3: covered by https://github.com/codeplaysoftware/syclacademy/pull/178/files |
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 code could be terser.
At the end we need to show it is terse compared to the alternative. :-)
* | ||
* | ||
* // Default construct a queue | ||
* auto q = sycl::queue{}; |
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.
* auto q = sycl::queue{}; | |
* sycl::queue q; |
* SYCL Quick Reference | ||
* ~~~~~~~~~~~~~~~~~~~~ | ||
* | ||
* // Make a child class of sycl::device_selector |
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.
Obsolete. Use lambda instead.
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.
Lambdas currently not implemented for device selection in DPC++. Will raise an issue about 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.
Sorry actually implemented here intel/llvm#6486. Will change
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.
Yeah this was introduced very recently in DPC++, so if all implementations support that now we should switch to that, if you want we could have a separate issue/PR for this as we'll likely want to update the lecture on device selection as well.
* ~~~~~~~~~~~~~~~~~~~~ | ||
* | ||
* // Default construct a queue | ||
* auto q = sycl::queue{}; |
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.
Idem
* auto read_write_acc = sycl::accessor{buf, cgh}; | ||
* auto read_acc = sycl::accessor{buf, cgh, sycl::read_only}; | ||
* auto write_acc = sycl::accessor{buf, cgh, sycl::write_only}; | ||
* auto no_init_acc = sycl::accessor{buf, cgh, sycl::no_init}; |
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.
It is not clear what is the value of using the auto
notation besides making the line longer. Otherwise there is get_access
... ;-)
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 am a little bit biased - personally I feel that this notation is the easiest to read and make sense of. If we write:
sycl::accessor read_acc {buf, cgh, sycl::read_only};
I think the name of the variable is not as readable as the above notation.
Using the notation:
auto var_name = class{...};
is very consistent and readable. The start of the var name is always at the same (relative) col and always before an equals sign. I know this is a bit pedantic but I think it is justified! :)
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.
Also for learning reasons we only want to use auto if the type of the obj is self evident. So something like:
auto acc = buf.get_access<mode>(...);
Is not very useful. Moreover using the accessor constructor instead of get_access
allows us to use CTAD, which is modern and clean!
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 you can write as you want anyway, at the end this is your code. :-)
Just that the sycl::accessor
has been improved to have CTAD in SYCL 2020 often terser than the auto
syntax with get_access
.
Co-authored-by: Ronan Keryell <[email protected]>
Add a few SYCL quick references to make the exercises a bit more manageable.