opencl sycl bof - siggraph 2014

22
© Copyright Khronos Group 2014 SYCL™ for OpenCL™ in a N utshell Luke Iwanski, Games Technology Programmer @ Codeplay SIGGRAPH Vancouver 2014 1

Upload: the-khronos-group-inc

Post on 10-Jun-2015

300 views

Category:

Technology


0 download

DESCRIPTION

SYCL slide presentation from the 2014 SIGGRAPH BOF

TRANSCRIPT

Page 1: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

SYCL™ for OpenCL™ in a Nutshell

Luke Iwanski, Games Technology Programmer @ Codeplay !SIGGRAPH Vancouver 2014

1

Page 2: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

2

Page 3: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

SYCL for OpenCL in a nutshell

• Why?

• Where in the OpenCL ecosystem?

• Motivation

• Features overview

• Example time

• Roadmap

3

Page 4: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

• 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

Why SYCL?

4

Page 5: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

Device X Device Y Device Z

Alternative Language for

Kernels

SPIR Generator (e.g. Khronos patched Clang

open source on GitHUB)

Alternative Language for

Kernels

Alternative Language for

Kernels

High-level FrameworksHigh-level

FrameworksApps and 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 ecosystemOpenCL C Kernel

Source

5

Page 6: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

OpenCL

SYCL for OpenCL

C++ template libraries

User application code

The layering of SYCL: Building an ecosystem

6

Page 7: OpenCL SYCL BOF - SIGGRAPH 2014

© 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 innovations7

Page 8: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

SYCL features: Overview

8

Page 9: OpenCL SYCL BOF - SIGGRAPH 2014

© 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 parallelism9

Page 10: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

buffer<int> my_buffer(data, 10);   auto in_access = my_buffer.get_access<cl::sycl::access:read>(); auto 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)

WorkgroupWork item

Work item

Work item

Work item

Work item

Work item

WorkgroupWork item

Work item

Work item

Work item

Work item

Work item

WorkgroupWork item

Work item

Work item

Work item

Work item

Work item

WorkgroupWork item

Work item

Work item

Work item

Work item

Work item

Hierarchical Data Parallelism

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

Page 11: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

Example time: Simple kernel

11

Page 12: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

12

Page 13: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

13

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

Page 14: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

Example time: Templated kernel

14

Page 15: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

15

Page 16: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

16

Page 17: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

17

Page 18: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

18

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

Page 19: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

19

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! 19

Page 20: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

• GDC, March 2014

• 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

SYCL roadmap

20

Page 21: OpenCL SYCL BOF - SIGGRAPH 2014

© 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.git21

Page 22: OpenCL SYCL BOF - SIGGRAPH 2014

© Copyright Khronos Group 2014

Luke Iwanski

[email protected]

@liwanski_

Thanks!

22