Khronos Group SYCL 1.2.1 Specification
Total Page:16
File Type:pdf, Size:1020Kb
SYCL™ Specification SYCL™ integrates OpenCL™ devices with modern C++ Version 1.2.1 Document Revision: 6 Revision Date: May 14, 2019 Git revision: heads/travis-0-g4f9a12d-dirty Khronos® OpenCL™ Working Group — SYCL™ subgroup Editors: Ronan Keryell, Maria Rovatsou & Lee Howes Copyright 2011-2019 The Khronos® Group Inc. All Rights Reserved SYCL 1.2.1 Copyright© 2013-2019 The Khronos® Group Inc. All Rights Reserved. This specification is protected by copyright laws and contains material proprietary to the Khronos® Group, Inc. It or any components may not be reproduced, republished, distributed, transmitted, displayed, broadcast, or other- wise exploited in any manner without the express prior written permission of Khronos® Group. You may use this specification for implementing the functionality therein, without altering or removing any trademark, copyright or other notice from the specification, but the receipt or possession of this specification does not convey any rights to reproduce, disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, in whole or in part. Khronos® Group grants express permission to any current Promoter, Contributor or Adopter member of Khronos® to copy and redistribute UNMODIFIED versions of this specification in any fashion, provided that NO CHARGE is made for the specification and the latest available update of the specification for any version of the API is used whenever possible. Such distributed specification may be reformatted AS LONG AS the contents of the specification are not changed in any way. The specification may be incorporated into a product that is sold as long as such product includes significant independent work developed by the seller. A link to the current ver- sion of this specification on the Khronos® Group website should be included whenever possible with specification distributions. Khronos® Group makes no, and expressly disclaims any, representations or warranties, express or implied, re- garding this specification, including, without limitation, any implied warranties of merchantability or fitness for a particular purpose or non-infringement of any intellectual property. Khronos® Group makes no, and expressly disclaims any, warranties, express or implied, regarding the correctness, accuracy, completeness, timeliness, and reliability of the specification. Under no circumstances will the Khronos® Group, or any of its Promoters, Con- tributors or Members or their respective partners, officers, directors, employees, agents, or representatives be liable for any damages, whether direct, indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in connection with these materials. Khronos® is a registered trademark and SYCL™, SPIR™, WebGL™, EGL™, COLLADA™, StreamInput™, OpenVX™, OpenKCam™, glTF™, OpenKODE™, OpenVG™, OpenWF™, OpenSL ES™, OpenMAX™, OpenMAX AL™, OpenMAX IL™ and OpenMAX DL™ and WebCL™ are trademarks of the Khronos® Group Inc. OpenCL™ is a trademark of Apple Inc. and OpenGL® and OpenML® are registered trademarks and the OpenGL ES™ and OpenGL SC™ logos are trademarks of Silicon Graphics International used under license by Khronos®. All other product names, trademarks, and/or company names are used solely for identification and belong to their respective owners. 2 Contents 1 Acknowledgements 13 2 Introduction 14 3 SYCL Architecture 16 3.1 Overview . 16 3.2 Anatomy of a SYCL application . 17 3.3 The SYCL Platform Model . 18 3.3.1 Platform Mixed Version Support . 19 3.4 SYCL Execution Model . 19 3.4.1 SYCL Application Execution Model . 19 3.4.1.1 OpenCL resources managed by SYCL Application . 19 3.4.1.2 SYCL Command Groups and Execution Order . 20 3.4.2 SYCL Kernel Execution Model . 22 3.5 Memory Model . 23 3.5.1 SYCL Application Memory Model . 23 3.5.2 SYCL Device Memory Model . 26 3.5.2.1 Access to memory . 26 3.5.2.2 Memory consistency . 27 3.5.2.3 Atomic operations . 27 3.6 The SYCL programming model . 27 3.6.1 Basic data parallel kernels . 28 3.6.2 Work-group data parallel kernels . 28 3.6.3 Hierarchical data parallel kernels . 28 3.6.4 Kernels that are not launched over parallel instances . 28 3.6.5 Synchronization . 29 3.6.5.1 Synchronization in the SYCL Application . 29 3.6.5.2 Synchronization in SYCL Kernels . 30 3.6.6 Error handling . 30 3.6.7 Fallback Mechanism . 30 3.6.8 Scheduling of kernels and data movement . 31 3.6.9 Managing object lifetimes . 31 3.6.10 Device discovery and selection . 32 3.6.11 Interfacing with OpenCL . 32 3.7 Memory objects . 33 3.8 SYCL for OpenCL Framework . 34 3.9 SYCL device compiler . 34 3.9.1 Building a SYCL program . 34 3.9.2 Naming of kernels . 35 3.10 Language restrictions in kernels . 35 3.10.1 SYCL Linker . 36 3.10.2 Functions and datatypes available in kernels . 36 3.11 Execution of kernels on the SYCL host device . 36 3 CONTENTS SYCL 1.2.1 3.12 Endianness support . 37 3.13 Example SYCL application . 37 4 SYCL Programming Interface 39 4.1 Header files and namespaces . 39 4.2 Class availability . 39 4.3 Common interface . 40 4.3.1 OpenCL interoperability . 40 4.3.2 Common reference semantics . 40 4.3.3 Common by-value semantics . 42 4.3.4 Properties . 44 4.3.4.1 Properties interface . 45 4.4 Param traits class . 46 4.5 C++ Standard library classes required for the interface . 46 4.6 SYCL runtime classes . 47 4.6.1 Device selection class . 48 4.6.1.1 Device selector interface . 48 4.6.1.2 Derived device selector classes . 49 4.6.2 Platform class . 50 4.6.2.1 Platform interface . 51 4.6.2.2 Platform information descriptors . 52 4.6.3 Context class . 53 4.6.3.1 Context interface . 53 4.6.3.2 Context information descriptors . 56 4.6.4 Device class . 56 4.6.4.1 Device interface . 57 4.6.4.2 Device information descriptors . 60 4.6.5 Queue class . 71 4.6.5.1 Queue interface . 72 4.6.5.2 Queue information descriptors . 75 4.6.5.3 Queue Properties . 76 4.6.5.4 Queue error handling . 76 4.6.6 Event class . 77 4.6.6.1 Event information and profiling descriptors . 80 4.7 Data access and storage in SYCL . 81 4.7.1 Host allocation . 81 4.7.1.1 Default Allocators . 82 4.7.2 Buffers . 82 4.7.2.1 Buffer Interface . 83 4.7.2.2 Buffer Properties . 91 4.7.2.3 Buffer Synchronization Rules . 92 4.7.3 Images . 93 4.7.3.1 Image Interface . 94 4.7.3.2 Image Properties . ..