Skip to content

Commit

Permalink
Add some more SYCL quick refs
Browse files Browse the repository at this point in the history
  • Loading branch information
hdelan committed Aug 26, 2022
1 parent 0d8faf0 commit bc90e50
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Code_Exercises/Exercise_12_Temporary_Data/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@
You should have received a copy of the license along with this
work. If not, see <http://creativecommons.org/licenses/by-sa/4.0/>.
* SYCL Quick Reference
* ~~~~~~~~~~~~~~~~~~~~
*
* // Default construct a queue
* auto q = sycl::queue{};
*
* // Declare a buffer pointing to ptr
* auto buf = sycl::buffer{ptr, sycl::range{n}};
*
* // Declare a buffer using host ptr
* auto buf = sycl::buffer{ptr, sycl::range{n},
* {sycl::property::buffer::use_host_ptr{}}};
*
* // Declare a buffer relating to no host memory
* auto buf = sycl::buffer{sycl::range{n}};
*
* // Set final data of a buffer
* buf.set_final_data(host_ptr);
*
* // Set final data of a buffer to nullptr
* buf.set_final_data(nullptr);
*
* // Submit work to the queue
* q.submit([&](sycl::handler &cgh) {
* // COMMAND GROUP
* });
*
* // Within the command group you can
* // 1. Declare an accessor to a buffer
* 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};
* // 2. Enqueue a parallel for:
* cgh.parallel_for<class mykernel>(sycl::range{n}, [=](sycl::id<1> i) {
* // Do something
* });
*
*/

#define CATCH_CONFIG_MAIN
Expand Down
34 changes: 34 additions & 0 deletions Code_Exercises/Exercise_13_Load_Balancing/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,40 @@
You should have received a copy of the license along with this
work. If not, see <http://creativecommons.org/licenses/by-sa/4.0/>.
* SYCL Quick Reference
* ~~~~~~~~~~~~~~~~~~~~
*
* // Get all available devices
* auto devs = sycl::device::get_devices();
*
* // Construct a queue with a device
* auto q = sycl::queue{my_device};
*
* // Declare a buffer pointing to ptr
* auto buf = sycl::buffer{ptr, sycl::range{n}};
*
* // Submit work to the queue
* q.submit([&](sycl::handler &cgh) {
* // COMMAND GROUP
* });
*
* // Within the command group you can
* // 1. Declare an accessor to a buffer
* 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};
* // 2. Enqueue a single task:
* cgh.single_task<class mykernel>([=]() {
* // Do something
* });
* // 3. Enqueue a parallel for:
* cgh.parallel_for<class mykernel>(sycl::range{n}, [=](sycl::id<1> i) {
* // Do something
* });
*
*/

#define CATCH_CONFIG_MAIN
Expand Down

0 comments on commit bc90e50

Please sign in to comment.