OpenCL™规范 3.4.2. 向后兼容性

3.4.2. Backwards Compatibility
3.4.2. 向后兼容性

Backwards compatibility is an important goal for the OpenCL standard. Backwards compatibility is expected such that a device will consume earlier versions of the OpenCL C programming languages and the SPIR-V intermediate language with the following minimum requirements:

向后兼容性是OpenCL标准的一个重要目标。预期具有向后兼容性,因此设备将使用具有以下最低要求的早期版本的OpenCL C编程语言和SPIR-V中间语言:

  • An OpenCL 1.x device must support at least one 1.x version of the OpenCL C programming language.

  • OpenCL 1.x设备必须至少支持一种1.x版本的OpenCL C编程语言。

  • An OpenCL 2.0 device must support all the requirements of an OpenCL 1.2 device in addition to the OpenCL C 2.0 programming language. If multiple language versions are supported, the compiler defaults to using the OpenCL C 1.2 language version. To utilize the OpenCL 2.0 Kernel programming language, a programmer must specifically pass the appropriate compiler build option (-cl-std=CL2.0). The language version must not be higher than the platform version, but may exceed the device version.

  • ​除了OpenCL C 2.0编程语言外,OpenCL 2.0设备还必须支持OpenCL 1.2设备的所有要求。如果支持多种语言版本,编译器默认使用OpenCL C 1.2语言版本。要使用OpenCL 2.0内核编程语言,程序员必须专门传递适当的编译器构建选项(-cl std=CL2.0)。语言版本不得高于平台版本,但可能超过设备版本。

  • An OpenCL 2.1 device must support all the requirements of an OpenCL 2.0 device in addition to the SPIR-V intermediate language at version 1.0 or above. Intermediate language versioning is encoded as part of the binary object and no flags are required to be passed to the compiler.

  • 除了1.0或更高版本的SPIR-V中间语言外,OpenCL 2.1设备还必须支持OpenCL 2.0设备的所有要求。中间语言版本控制作为二进制对象的一部分进行编码,不需要将任何标志传递给编译器。

  • An OpenCL 2.2 device must support all the requirements of an OpenCL 2.0 device in addition to the SPIR-V intermediate language at version 1.2 or above. Intermediate language versioning is encoded as a part of the binary object and no flags are required to be passed to the compiler.

  • 除了1.2或更高版本的SPIR-V中间语言外,OpenCL 2.2设备还必须支持OpenCL 2.0设备的所有要求。中间语言版本控制作为二进制对象的一部分进行编码,不需要将任何标志传递给编译器。

  • OpenCL 3.0 is designed to enable any OpenCL implementation supporting OpenCL 1.2 or newer to easily support and transition to OpenCL 3.0, by making many features in OpenCL 2.0, 2.1, or 2.2 optional. This means that OpenCL 3.0 is backwards compatible with OpenCL 1.2, but is not necessarily backwards compatible with OpenCL 2.0, 2.1, or 2.2.

  • OpenCL 3.0旨在通过使OpenCL 2.0、2.1或2.2中的许多功能成为可选功能,使任何支持OpenCL 1.2或更新版本的OpenCL实现都能轻松支持并过渡到OpenCL 3.0。这意味着OpenCL 3.0与OpenCL 1.2向后兼容,但不一定与OpenCL 2.0、2.1或2.2向后兼容。

    An OpenCL 3.0 platform must implement all OpenCL 3.0 APIs, but some APIs may return an error code unconditionally when a feature is not supported by any devices in the platform. Whenever a feature is optional, it will be paired with a query to determine whether the feature is supported. The queries will enable correctly written applications to selectively use all optional features without generating any OpenCL errors, if desired.


    OpenCL 3.0平台必须实现所有OpenCL 3.0 API,但当平台中的任何设备都不支持某个功能时,某些API可能会无条件返回错误代码。只要某个功能是可选的,它就会与一个查询配对,以确定是否支持该功能。如果需要,查询将使正确编写的应用程序能够选择性地使用所有可选功能,而不会产生任何OpenCL错误。

    OpenCL 3.0 also adds a new version of the OpenCL C programming language, which makes many features in OpenCL C 2.0 optional. The new version of OpenCL C is backwards compatible with OpenCL C 1.2, but is not backwards compatible with OpenCL C 2.0. The new version of OpenCL C must be explicitly requested via the -cl-std= build option, otherwise a program will continue to be compiled using the highest OpenCL C 1.x language version supported for the device.

    OpenCL 3.0还添加了一个新版本的OpenCL C编程语言,这使得OpenCL C 2.0中的许多功能都是可选的。新版本的OpenCL C向后兼容OpenCL C 1.2,但与OpenCL C 2.0不向后兼容。必须通过-cl-std=build选项显式请求新版本的OpenCL C,否则程序将继续使用设备支持的最高OpenCL C1.x语言版本进行编译。

    Whenever an OpenCL C feature is optional in the new version of the OpenCL C programming language, it will be paired with a feature macro, such as __opencl_c_feature_name, and a corresponding API query. If a feature macro is defined then the feature is supported by the OpenCL C compiler, otherwise the optional feature is not supported.

    每当OpenCL C功能在新版本的OpenCL C编程语言中是可选的时,它将与功能宏(如__opencl_c_feature_name)和相应的API查询配对。如果定义了功能宏,则OpenCL C编译器支持该功能,否则不支持可选功能。

In order to allow future versions of OpenCL to support new types of devices, minor releases of OpenCL may add new profiles where some features that are currently required for all OpenCL devices become optional. All features that are required for an OpenCL profile will also be required for that profile in subsequent minor releases of OpenCL, thereby guaranteeing backwards compatibility for applications targeting specific profiles. It is therefore strongly recommended that applications query the profile supported by the OpenCL device they are running on in order to remain robust to future changes.

​为了允许OpenCL的未来版本支持新类型的设备,OpenCL的次要版本可能会添加新的配置文件,其中所有OpenCL设备当前所需的一些功能将成为可选功能。OpenCL配置文件所需的所有功能也将在OpenCL的后续次要版本中被要求用于该配置文件,从而保证针对特定配置文件的应用程序的向后兼容性。因此,强烈建议应用程序查询其运行的OpenCL设备所支持的配置文件,以便对未来的更改保持稳健。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值