没有合适的资源?快使用搜索试试~ 我知道了~
opencl 2.0 语言标准协议
需积分: 10 19 下载量 11 浏览量
2017-04-14
19:42:29
上传
评论
收藏 1.93MB PDF 举报
温馨提示
试读
205页
opencl 2.0语言标准协议,看了下语言真的很简单。合适FPGA开发选择。
资源推荐
资源详情
资源评论
Last Revision Date: April 13, 2016 Page 1
The OpenCL C Specification
Version: 2.0
Document Revision: 33
Khronos OpenCL Working Group
Editor: Aaftab Munshi, Lee Howes and Bartosz Sochacki
Last Revision Date: April 13, 2016 Page 2
6. The OpenCL C Programming Language ................................................................................. 6
6.1 Supported Data Types ...................................................................................................................... 6
6.1.1 Built-in Scalar Data Types.......................................................................................................................... 6
6.1.1.1 The half data type ................................................................................................................................................... 8
6.1.2 Built-in Vector Data Types......................................................................................................................... 9
6.1.3 Other Built-in Data Types ........................................................................................................................ 10
6.1.4 Reserved Data Types ................................................................................................................................. 11
6.1.5 Alignment of Types ..................................................................................................................................... 12
6.1.6 Vector Literals .............................................................................................................................................. 13
6.1.7 Vector Components .................................................................................................................................... 14
6.1.8 Aliasing Rules ................................................................................................................................................ 18
6.1.9 Keywords ........................................................................................................................................................ 18
6.2 Conversions and Type Casting ..................................................................................................... 19
6.2.1 Implicit Conversions .................................................................................................................................. 19
6.2.2 Explicit Casts ................................................................................................................................................. 19
6.2.3 Explicit Conversions ................................................................................................................................... 20
6.2.3.1 Data Types .............................................................................................................................................................. 21
6.2.3.2 Rounding Modes .................................................................................................................................................. 21
6.2.3.3 Out-of-Range Behavior and Saturated Conversions ............................................................................ 22
6.2.3.4 Explicit Conversion Examples ....................................................................................................................... 22
6.2.4 Reinterpreting Data As Another Type ................................................................................................ 23
6.2.4.1 Reinterpreting Types Using Unions ............................................................................................................ 23
6.2.4.2 Reinterpreting Types Using as_type() and as_typen() ....................................................................... 24
6.2.5 Pointer Casting ............................................................................................................................................. 25
6.2.6 Usual Arithmetic Conversions ............................................................................................................... 26
6.3 Operators ............................................................................................................................................ 27
6.4 Vector Operations ............................................................................................................................ 33
6.5 Address Space Qualifiers ............................................................................................................... 34
6.5.1 __global (or global) ...................................................................................................................................... 35
6.5.2 __local (or local) ........................................................................................................................................... 37
6.5.3 __constant (or constant) ........................................................................................................................... 37
6.5.4 __private (or private) ................................................................................................................................. 38
6.5.5 The generic address space ....................................................................................................................... 38
6.5.6 Changes to ISO/IEC 9899:1999 ............................................................................................................. 40
6.6 Access Qualifiers ............................................................................................................................... 46
6.7 Function Qualifiers .......................................................................................................................... 47
6.7.1 __kernel (or kernel) .................................................................................................................................... 47
6.7.2 Optional Attribute Qualifiers .................................................................................................................. 47
6.8 Storage-Class Specifiers ................................................................................................................. 50
6.9 Restrictions ........................................................................................................................................ 51
6.10 Preprocessor Directives and Macros ........................................................................................ 54
6.11 Attribute Qualifiers ......................................................................................................................... 56
6.11.1 Specifying Attributes of Types .......................................................................................................... 57
6.11.2 Specifying Attributes of Functions .................................................................................................. 59
6.11.3 Specifying Attributes of Variables ................................................................................................... 59
6.11.4 Specifying Attributes of Blocks and Control-Flow-Statements ........................................... 61
6.11.5 Specifying Attribute For Unrolling Loops .................................................................................... 61
6.11.6 Extending Attribute Qualifiers.......................................................................................................... 63
6.12 Blocks ................................................................................................................................................... 64
Last Revision Date: April 13, 2016 Page 3
6.12.1 Declaring and Using a Block .............................................................................................................. 64
6.12.2 Declaring a Block Reference .............................................................................................................. 65
6.12.3 Block Literal Expressions ................................................................................................................... 65
6.12.4 Control Flow ............................................................................................................................................. 67
6.12.5 Restrictions ............................................................................................................................................... 67
6.13 Built-in Functions ............................................................................................................................. 71
6.13.1 Work-Item Functions ........................................................................................................................... 71
6.13.2 Math Functions ....................................................................................................................................... 74
6.13.2.1 Floating-point macros and pragmas ........................................................................................................... 81
6.13.3 Integer Functions ................................................................................................................................... 84
6.13.4 Common Functions ............................................................................................................................... 88
6.13.5 Geometric Functions ............................................................................................................................. 90
6.13.6 Relational Functions ............................................................................................................................. 92
6.13.7 Vector Data Load and Store Functions .......................................................................................... 95
6.13.8 Synchronization Functions ................................................................................................................ 99
6.13.9 Address Space Qualifier Functions .............................................................................................. 101
6.13.10 Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch
102
6.13.11 Atomic Functions ................................................................................................................................ 105
6.13.11.1 The ATOMIC_VAR_INIT macro .............................................................................................................. 106
6.13.11.2 The atomic_init function........................................................................................................................... 106
6.13.11.3 Order and Consistency .............................................................................................................................. 107
6.13.11.4 Memory Scope .............................................................................................................................................. 107
6.13.11.5 Fences ............................................................................................................................................................... 107
6.13.11.6 Atomic integer and floating-point types ........................................................................................... 108
6.13.11.7 Operations on atomic types .................................................................................................................... 109
6.13.11.8 Restrictions .................................................................................................................................................... 114
6.13.12 Miscellaneous Vector Functions ................................................................................................... 115
6.13.13 printf ......................................................................................................................................................... 117
6.13.13.1 printf output synchronization ............................................................................................................... 117
6.13.13.2 printf format string ..................................................................................................................................... 117
6.13.13.3 Differences between OpenCL C and C99 printf .............................................................................. 123
6.13.14 Image Read and Write Functions ................................................................................................. 125
6.13.14.1 Samplers .......................................................................................................................................................... 125
6.13.14.2 Built-in Image Read Functions .............................................................................................................. 129
6.13.14.3 Built-in Image Sampler-less Read Functions .................................................................................. 138
6.13.14.4 Built-in Image Write Functions ............................................................................................................. 145
6.13.14.5 Built-in Image Query Functions ............................................................................................................ 151
6.13.14.6 Reading and writing to the same image in a kernel ..................................................................... 153
6.13.14.7 Mapping image channels to color values returned by read_image and color values
passed to write_image to image channels...................................................................................................................... 154
6.13.15 Work-group Functions ...................................................................................................................... 156
6.13.16 Pipe Functions ...................................................................................................................................... 159
6.13.16.1 Restrictions .................................................................................................................................................... 159
6.13.16.2 Built-in Pipe Read and Write Functions ............................................................................................ 160
6.13.16.3 Built-in Work-group Pipe Read and Write Functions ................................................................. 161
6.13.16.4 Built-in Pipe Query Functions................................................................................................................ 162
6.13.16.5 Restrictions .................................................................................................................................................... 163
6.13.17 Enqueuing Kernels ............................................................................................................................. 164
6.13.17.1 Built-in Functions – Enqueuing a kernel ........................................................................................... 164
6.13.17.2 Arguments that are a pointer type to local address space ........................................................ 167
6.13.17.3 A Complete Example .................................................................................................................................. 169
Last Revision Date: April 13, 2016 Page 4
6.13.17.4 Determining when a child kernel begins execution ..................................................................... 170
6.13.17.5 Determining when a parent kernel has finished execution ..................................................... 171
6.13.17.6 Built-in Functions – Kernel Query Functions.................................................................................. 171
6.13.17.7 Built-in Functions – Queuing other commands ............................................................................. 172
6.13.17.8 Built-in Functions – Event Functions ................................................................................................. 173
6.13.17.9 Built-in Functions – Helper Functions ............................................................................................... 176
7. OpenCL Numerical Compliance ........................................................................................... 178
7.1 Rounding Modes ............................................................................................................................ 178
7.2 INF, NaN and Denormalized Numbers ................................................................................... 178
7.3 Floating-Point Exceptions .......................................................................................................... 179
7.4 Relative Error as ULPs ................................................................................................................. 179
7.5 Edge Case Behavior ....................................................................................................................... 186
7.5.1 Additional Requirements Beyond C99 TC2 ................................................................................... 186
7.5.2 Changes to C99 TC2 Behavior ............................................................................................................. 190
7.5.3 Edge Case Behavior in Flush To Zero Mode .................................................................................. 190
8. Image Addressing and Filtering .......................................................................................... 191
8.1 Image Coordinates ........................................................................................................................ 191
8.2 Addressing and Filter Modes .................................................................................................... 191
8.3 Conversion Rules ........................................................................................................................... 198
8.3.1 Conversion rules for normalized integer channel data types ............................................... 198
8.3.1.1 Converting normalized integer channel data types to floating-point values ......................... 198
8.3.1.2 Converting floating-point values to normalized integer channel data types ......................... 200
8.3.2 Conversion rules for half precision floating-point channel data type ................................ 201
8.3.3 Conversion rules for floating-point channel data type ............................................................. 202
8.3.4 Conversion rules for signed and unsigned 8-bit, 16-bit and 32-bit integer channel data
types 202
8.3.5 Conversion rules for sRGBA and sBGRA images ......................................................................... 203
8.4 Selecting an Image from an Image Array .............................................................................. 204
Last Revision Date: April 13, 2016 Page 5
Copyright (c) 2008-2014 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 otherwise 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 re-formatted 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 version of this specification on the Khronos Group web-site should be included whenever
possible with specification distributions.
Khronos Group makes no, and expressly disclaims any, representations or warranties, express or
implied, regarding 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, Contributors 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, StreamInput, WebGL, COLLADA, OpenKODE, OpenVG, OpenWF, OpenSL ES,
OpenMAX, OpenMAX AL, OpenMAX IL and OpenMAX DL are trademarks and WebCL is a
certification mark 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.
剩余204页未读,继续阅读
资源评论
加班猫
- 粉丝: 28
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功