Skip to content

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

Merged
merged 5 commits into from
Sep 7, 2022
Merged

Conversation

hdelan
Copy link
Contributor

@hdelan hdelan commented Aug 25, 2022

Add a few SYCL quick references to make the exercises a bit more manageable.

@hdelan hdelan changed the base branch from cppcon22 to main August 26, 2022 08:54
@hdelan
Copy link
Contributor Author

hdelan commented Aug 26, 2022

If we think this is a good idea I can add sycl quick refs for all exercises.

Copy link
Contributor

@AerialMantis AerialMantis left a 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!

@hdelan
Copy link
Contributor Author

hdelan commented Aug 26, 2022

Haven't included:

Ex 3: covered by https://github.com/codeplaysoftware/syclacademy/pull/178/files
Ex 4: Due a redesign
Ex 7, 8: Need to be removed/changed if https://github.com/codeplaysoftware/syclacademy/pull/178/files goes through

Copy link
Contributor

@keryell keryell left a 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{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* auto q = sycl::queue{};
* sycl::queue q;

* SYCL Quick Reference
* ~~~~~~~~~~~~~~~~~~~~
*
* // Make a child class of sycl::device_selector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete. Use lambda instead.

Copy link
Contributor Author

@hdelan hdelan Aug 29, 2022

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.

Copy link
Contributor Author

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

Copy link
Contributor

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{};
Copy link
Contributor

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};
Copy link
Contributor

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... ;-)

Copy link
Contributor Author

@hdelan hdelan Aug 26, 2022

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! :)

Copy link
Contributor Author

@hdelan hdelan Aug 26, 2022

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!

Copy link
Contributor

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.

@joeatodd joeatodd merged commit a4d7736 into codeplaysoftware:main Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants