OpenCL™规范 3.1平台模型

3.1. Platform Model

3.1平台模型

The Platform model for OpenCL is defined below. The model consists of a host connected to one or more OpenCL devices. An OpenCL device is divided into one or more compute units (CUs) which are further divided into one or more processing elements (PEs). Computations on a device occur within the processing elements.

​OpenCL的平台模型定义如下。该模型由连接到一个或多个OpenCL设备的主机组成。OpenCL设备被划分为一个或多个计算单元(CU),这些计算单元被进一步划分为一种或多种处理元件(PE)。设备上的计算发生在处理元件内。

An OpenCL application is implemented as both host code and device kernel code. The host code portion of an OpenCL application runs on a host processor according to the models native to the host platform. The OpenCL application host code submits the kernel code as commands from the host to OpenCL devices. An OpenCL device executes the commands computation on the processing elements within the device.

OpenCL应用程序实现为主机代码和设备内核代码。OpenCL应用程序的主机代码部分根据主机平台固有的模型在主机处理器上运行。OpenCL应用程序主机代码将内核代码作为命令从主机提交给OpenCL设备。OpenCL设备在设备内的处理元件上执行命令计算。

An OpenCL device has considerable latitude on how computations are mapped onto the devices processing elements. When processing elements within a compute unit execute the same sequence of statements across the processing elements, the control flow is said to be converged. Hardware optimized for executing a single stream of instructions over multiple processing elements is well suited to converged control flows. When the control flow varies from one processing element to another, it is said to be diverged. While a kernel always begins execution with a converged control flow, due to branching statements within a kernel, converged and diverged control flows may occur within a single kernel. This provides a great deal of flexibility in the algorithms that can be implemented with OpenCL.

OpenCL设备在如何将计算映射到设备处理元件上具有相当大的自由度。当计算单元内的处理元件在处理元件之间执行相同的语句序列时,控制流被称为收敛的。为在多个处理元件上执行单个指令流而优化的硬件非常适合于聚合控制流。当控制流从一个处理元件变化到另一个处理单元时,称之为分流。虽然内核总是以收敛的控制流开始执行,但由于内核内的分支语句,收敛和发散的控制流可能发生在单个内核内。这为可以使用OpenCL实现的算法提供了很大的灵活性。

Figure 1. Platform Model …​ one host plus one or more compute devices each with one or more compute units composed of one or more processing elements.

图1 平台模型…​一个主机加上一个或多个计算设备,每个计算设备具有由一个或更多个处理元件组成的一个或更少个计算单元。

Programmers may provide programs in the form of OpenCL C source strings, the SPIR-V intermediate language, or as implementation-defined binary objects. An OpenCL platform provides a compiler to translate programs of these forms into executable program objects. The device code compiler may be online or offline. An online compiler is available during host program execution using standard APIs. An offline compiler is invoked outside of host program control, using platform-specific methods. The OpenCL runtime allows developers to get a previously compiled device program executable and be able to load and execute a previously compiled device program executable.

程序员可以以OpenCL C源字符串、SPIR-V中间语言或实现定义的二进制对象的形式提供程序。OpenCL平台提供了一个编译器,用于将这些形式的程序转换为可执行程序对象。设备代码编译器可以是联机的,也可以是脱机的。在线编译器在使用标准API执行主机程序期间可用。离线编译器是在主机程序控制之外调用的,使用特定于平台的方法。OpenCL运行时允许开发人员获得先前编译的设备程序可执行文件,并能够加载和执行先前编译的可执行设备程序。

OpenCL defines two kinds of platform profiles: a full profile and a reduced-functionality embedded profile. A full profile platform must provide an online compiler for all its devices. An embedded platform may provide an online compiler, but is not required to do so.

OpenCL定义了两种类型的平台配置文件:完整配置文件和减少功能的嵌入式配置文件。完整配置文件平台必须为其所有设备提供在线编译器。嵌入式平台可以提供在线编译器,但不需要这样做。

A device may expose special purpose functionality as a built-in kernel. The platform provides APIs for enumerating and invoking the built-in kernels offered by a device, but otherwise does not define their construction or semantics. A custom device supports only built-in kernels, and cannot be programmed via a kernel language.

设备可能会将专用功能作为内置内核公开。该平台提供了用于枚举和调用设备提供的内置内核的API,但在其他方面没有定义它们的构造或语义。自定义设备只支持内置内核,不能通过内核语言进行编程。

Built-in kernels and custom devices are missing before version 1.2.

1.2版本之前缺少内置内核和自定义设备。

All device types support the OpenCL execution model, the OpenCL memory model, and the APIs used in OpenCL to manage devices.

所有设备类型都支持OpenCL执行模型、OpenCL内存模型以及OpenCL中用于管理设备的API。

The platform model is an abstraction describing how OpenCL views the hardware. The relationship between the elements of the platform model and the hardware in a system may be a fixed property of a device or it may be a dynamic feature of a program dependent on how a compiler optimizes code to best utilize physical hardware.

平台模型是描述OpenCL如何看待硬件的抽象。平台模型的元素和系统中的硬件之间的关系可以是设备的固定属性,也可以是程序的动态特征,这取决于编译器如何优化代码以最佳地利用物理硬件。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值