Intel® Oneapi Programming Guide (Beta)
Total Page:16
File Type:pdf, Size:1020Kb
Intel® oneAPI Programming Guide (Beta) Copyright © 2019 Intel Corporation All Rights Reserved Intel® oneAPI Programming Guide (Beta) Notices and Disclaimers No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document. This document contains information on products, services and/or processes in development. All information provided here is subject to change without notice. Contact your Intel representative to obtain the latest forecast, schedule, specifications and roadmaps. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. No product or component can be absolutely secure. Check with your system manufacturer or retailer or learn more at [intel.com]. The products and services described may contain defects or errors which may cause deviations from published specifications. Current characterized errata are available on request. Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade. Intel, the Intel logo, Intel Atom, Intel Arria, Intel Core, VTune and Xeon are trademarks of Intel Corporation in the U.S. and/or other countries. Microsoft, Windows, and the Windows logo are trademarks, or registered trademarks of Microsoft Corporation in the United States and/or other countries. OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission of The Khronos Group. *Other names and brands may be claimed as the property of others. © Intel Corporation. This software and the related documents are Intel copyrighted materials, and your use of them is governed by the express license under which they were provided to you ("License"). Unless the License provides otherwise, you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents without Intel's prior written permission. This software and the related documents are provided as is, with no express or implied warranties, other than those that are expressly stated in the License. Optimization Notice: Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice. Notice Revision #20110804 Unless stated otherwise, the code examples in this document are provided to you under an MIT license, the terms of which are as follows: Copyright 2019 Intel Corporation 2 Introduction Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 3 Intel® oneAPI Programming Guide (Beta) Contents 1 Introduction ............................................................................................................. 8 1.1 oneAPI Programming Model Overview ................................................................................ 8 1.1.1 Data Parallel C++ (DPC++) .......................................................................... 9 1.1.2 oneAPI Toolkit Distribution .......................................................................... 10 1.2 About This Guide ................................................................................................................ 10 1.3 Related Documentation ...................................................................................................... 11 2 oneAPI Programming Model ...................................................................................... 12 2.1 Sample Program ................................................................................................................. 12 2.2 Platform Model ................................................................................................................... 16 2.3 Execution Model ................................................................................................................. 18 2.4 Memory Model ................................................................................................................... 20 2.4.1 Memory Objects ......................................................................................... 22 2.4.2 Accessors .................................................................................................. 22 2.4.3 Synchronization ......................................................................................... 23 2.4.4 Unified Shared Memory ............................................................................... 24 2.5 Kernel Programming Model................................................................................................ 24 2.5.1 C++ Language Requirements....................................................................... 25 2.5.2 Error Handling ............................................................................................ 27 2.5.3 Fall Back ................................................................................................... 27 3 Programming Interface ............................................................................................ 29 3.1 Single Source Compilation .................................................................................................. 29 3.2 Compiler Drivers ................................................................................................................. 29 3.3 Example Compilation .......................................................................................................... 29 3.3.1 API-Based Code ......................................................................................... 30 3.3.2 Direct Programming .................................................................................... 32 3.4 Compilation Model ............................................................................................................. 32 3.4.1 Compile to Object Step ............................................................................... 34 3.4.2 Link to Executable Step ............................................................................... 35 3.4.3 Execute Step ............................................................................................. 36 3.4.4 Online Compilation ..................................................................................... 36 3.5 CPU Flow ............................................................................................................................. 37 3.5.1 Example CPU Commands ............................................................................. 37 3.5.2 Online Compilation ..................................................................................... 37 3.5.3 Offline Compilation ..................................................................................... 37 3.5.4 Optimization Flags ...................................................................................... 38 3.5.5 Host and Kernel Interaction ......................................................................... 38 3.6 GPU Flow ............................................................................................................................ 38 3.6.1 Example GPU Commands ............................................................................ 38 4 Introduction 3.6.2 Offline Compilation ..................................................................................... 39 3.7 FPGA Flow ........................................................................................................................... 39 3.7.1 Example FPGA Commands ........................................................................... 41 3.7.2 Offline Compilation ..................................................................................... 41 3.7.3 Targeting Multiple FPGAs ............................................................................