© Copyright Khronos Group 2014 
SYCL™ for OpenCL™ 
in a Nutshell 
Luke Iwanski, Games Technology Programmer @ Codeplay 
! ...
2 
© Copyright Khronos Group 2014
© Copyright Khronos Group 2014 
SYCL for OpenCL 
in a nutshell 
• Why? 
• Where in the OpenCL ecosystem? 
• Motivation 
• ...
© Copyright Khronos Group 2014 
Why SYCL? 
• Modern C++ programming model for OpenCL (compiler, runtime) 
• Ease to use 
•...
© Copyright Khronos Group 2014 
Alternative 
Language for 
Alternative 
Language for 
Alternative 
Language Kernels 
for 
...
© Copyright Khronos Group 2014 
The layering of SYCL: 
Building an ecosystem 
User application code 
C++ template librarie...
© Copyright Khronos Group 2014 
Motivation 
• We want to enable C++ for the OpenCL ecosystem 
• Where more C++ developers ...
© Copyright Khronos Group 2014 
SYCL features: 
Overview 
8
© Copyright Khronos Group 2014 
• OpenCL/SYCL interoperability 
• Seamless integration of OpenCL C applications with SYCL ...
© Copyright Khronos Group 2014 
Hierarchical Data Parallelism 
buffer<int> my_buffer(data, 10); 
auto in_access = my_buffe...
© Copyright Khronos Group 2014 
Example time: 
Simple kernel 
11
12 
© Copyright Khronos Group 2014
13 
© Copyright Khronos Group 2014 
Simple kernel summary 
• Simple kernel demo source is only 20 lines of actual C++/ SYC...
© Copyright Khronos Group 2014 
Example time: 
Templated kernel 
14
15 
© Copyright Khronos Group 2014
16 
© Copyright Khronos Group 2014
17 
© Copyright Khronos Group 2014
18 
© Copyright Khronos Group 2014 
Templated kernel summary 
• Only 52 lines of code to create a templated kernel for the...
19 
© Copyright Khronos Group 2014 
Final notes about SYCL 
• Keep in mind 
• Advantages of modern C++ (lambdas, templates...
© Copyright Khronos Group 2014 
• GDC, March 2014 
SYCL roadmap 
• Released a provisional specification to enable feedback...
© Copyright Khronos Group 2014 
SYCL Useful Links 
• SYCL spec and forums: 
• http://www.khronos.org/opencl/sycl 
• triSYC...
© Copyright Khronos Group 2014 
Thanks! 
Luke Iwanski 
luke@codeplay.com 
@liwanski_ 
22
Upcoming SlideShare
Loading in …5
×

OpenCL SYCL BOF - SIGGRAPH 2014

684 views

Published on

SYCL slide presentation from the 2014 SIGGRAPH BOF

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
684
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

OpenCL SYCL BOF - SIGGRAPH 2014

  1. 1. © Copyright Khronos Group 2014 SYCL™ for OpenCL™ in a Nutshell Luke Iwanski, Games Technology Programmer @ Codeplay ! SIGGRAPH Vancouver 2014 1
  2. 2. 2 © Copyright Khronos Group 2014
  3. 3. © Copyright Khronos Group 2014 SYCL for OpenCL in a nutshell • Why? • Where in the OpenCL ecosystem? • Motivation • Features overview • Example time • Roadmap 3
  4. 4. © Copyright Khronos Group 2014 Why SYCL? • Modern C++ programming model for OpenCL (compiler, runtime) • Ease to use • High performance • Single source • Allows multi-compiler implementation. SYCL device compiler + Host compiler of your choice • Portability across platforms and compilers • Providing the full OpenCL feature set and seamless integration with existing OpenCL code • Enabling the creation of higher level programming models and C++ templated libraries based on OpenCL 4
  5. 5. © Copyright Khronos Group 2014 Alternative Language for Alternative Language for Alternative Language Kernels for SPIR Generator (e.g. Khronos patched Clang open source on GitHUB) Kernels Kernels Device X Device Y Device Z High-level HFirgahm-leewveolr ks AFprapms eawndo rks Frameworks ! OpenCL Runtime SPIR Standard Portable Intermediate Representation SPIR 1.2 Released January 2014 SYCL A programming abstraction that combines the portability and efficiency of OpenCL with the ease of use and flexibility of C++ SYCL 1.2 Provisional Released March 2014 OpenCL ecosystem OpenCL C Kernel Source 5
  6. 6. © Copyright Khronos Group 2014 The layering of SYCL: Building an ecosystem User application code C++ template libraries SYCL for OpenCL OpenCL 6
  7. 7. © Copyright Khronos Group 2014 Motivation • We want to enable C++ for the OpenCL ecosystem • Where more C++ developers can get the benefits of OpenCL • With C++ libraries supported on OpenCL platforms • C++ tools supported on OpenCL platforms • Aim to achieve long-term support for OpenCL features with C++ • Multiple Sources of implementations (multiple vendors) • Reliability by providing host fall-back • Enable future innovations 7
  8. 8. © Copyright Khronos Group 2014 SYCL features: Overview 8
  9. 9. © Copyright Khronos Group 2014 • OpenCL/SYCL interoperability • Seamless integration of OpenCL C applications with SYCL applications • OpenCL C data types and built-in functions available • SYCL / OpenGL interoperability • Based on OpenCL/OpenGL interoperability extensions • C++ exception handling • Host “fall-back” mode - using SYCL without OpenCL • Introduced in SYCL Hierarchical data parallelism 9
  10. 10. © Copyright Khronos Group 2014 Hierarchical Data Parallelism buffer<int> my_buffer(data, 10); auto in_access = my_buffer.get_access<cl::sycl::access:read>(); a!uto out_access = my_buffer.access<cl::sycl::access:write>(); command_group(my_queue, [&]() { " parallel_for_workgroup(nd_range(range(size), range(groupsize)), " " lambda<class hierarchical>([=](group group) " { " " parallel_for_workitem(group, [=](item tile) " " { " " " out_access[tile] = in_access[tile] * 2; " " }); " })); }); Task (nD-range) Workgroup Work item Work item Workgroup Work item Work item Work item Workgroup Work Work item item Work item Workgroup Work item Work item Work item Work item Work item Work item Work item Work item Work item Work item Work item Work item Work item Work item Work item Work item Advantages:! 1. Easy to understand the concept of work-groups! 2. Performance-portable between CPU and GPU! 3. Barriers are automatically deduced!! 4. Easier to compose components and algorithms 10
  11. 11. © Copyright Khronos Group 2014 Example time: Simple kernel 11
  12. 12. 12 © Copyright Khronos Group 2014
  13. 13. 13 © Copyright Khronos Group 2014 Simple kernel summary • Simple kernel demo source is only 20 lines of actual C++/ SYCL code • Equivalent of simple kernel demo in OpenCL takes over 100 lines of code • This code can be easily templated by changing 17 lines of code • Plain OpenCL C will take many, many, .. many more lines of code
  14. 14. © Copyright Khronos Group 2014 Example time: Templated kernel 14
  15. 15. 15 © Copyright Khronos Group 2014
  16. 16. 16 © Copyright Khronos Group 2014
  17. 17. 17 © Copyright Khronos Group 2014
  18. 18. 18 © Copyright Khronos Group 2014 Templated kernel summary • Only 52 lines of code to create a templated kernel for the subtract operation! • Templates on the device! • factor of 5 lines per new datatype! (including initialisation and printing) • SYCL is simple!!
  19. 19. 19 © Copyright Khronos Group 2014 Final notes about SYCL • Keep in mind • Advantages of modern C++ (lambdas, templates, struct arguments, static polymorphism) • but, limitations of current OpenCL ( recursion, dynamic allocation, static variables) • It will get better with the next OpenCL iterations!
  20. 20. © Copyright Khronos Group 2014 • GDC, March 2014 SYCL roadmap • Released a provisional specification to enable feedback • Developers can provide input into the standardisation process • Feedback via Khronos forums • Next steps • Full specification, based on feedback • Khronos test suite for implementations • Release of implementations 20
  21. 21. © Copyright Khronos Group 2014 SYCL Useful Links • SYCL spec and forums: • http://www.khronos.org/opencl/sycl • triSYCL github: • https://github.com/amd/triSYCL • Codeplay’s blogs: • http://www.codeplay.com/portal/ • Examples github • https://github.com/codeplaysoftware/Siggraph14.git 21
  22. 22. © Copyright Khronos Group 2014 Thanks! Luke Iwanski luke@codeplay.com @liwanski_ 22

×