【问题标题】:Does the official OpenCL 2.2 standard support the WaveFront?官方 OpenCL 2.2 标准是否支持 WaveFront?
【发布时间】:2017-02-15 22:58:08
【问题描述】:

众所周知,AMD-OpenCL 支持 WaveFront(2015 年 8 月):http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/AMD_OpenCL_Programming_Optimization_Guide2.pdf

例如,AMD Radeon HD 7770 GPU 支持超过 25,000 飞行中的工作项,并且可以切换到新的 wavefront(包含 最多 64 个工作项)。


但为什么在 OpenCL 标准 1.0/2.0/2.2 中没有提及 WaveFront?

没有一个PDF没有一个词WaveFronthttps://www.khronos.org/registry/OpenCL/specs/

我还发现:

OpenCL 是一个开放标准。它仍然不支持这种混搭 概念。它甚至还不支持波前/扭曲。

这就是为什么 OpenCL 规范本身没有这个概念。

标准 OpenCL 没有“波前”的概念

确实,官方的 OpenCL 2.2 标准还不支持 WaveFront?


结论

OpenCL 标准中没有 WaveFront,但在 OpenCL-2.0 中有类似于 WaveFronts 的 SIMD 执行模型的子组

6.4.2 工作组/子组级功能

OpenCL 2.0 引入了 Khronos 子组扩展。子组是一个 硬件 SIMD 执行模型的逻辑抽象类似于 波前,扭曲或矢量,并允许编程更接近 硬件以独立于供应商的方式。此扩展包括一组 匹配的集合的跨子组内置函数 上面指定的跨工作组内置函数。

【问题讨论】:

    标签: multithreading concurrency opencl gpgpu amd


    【解决方案1】:

    他们一定采用了一种更动态的方法,称为sub-grouphttps://www.khronos.org/registry/OpenCL/specs/opencl-2.2.pdf

    Sub-group: Sub-groups are an implementation-dependent grouping of work-items within a
    work-group. The size and number of sub-groups is implementation-defined.
    

    Work-groups are further divided into sub-groups,
    which provide an additional level of control over execution.
    

    The mapping of work-items to
    sub-groups is implementation-defined and may be queried at runtime. 
    

    所以即使它不被称为波前,它现在可以在运行时查询并且

    在没有同步功能(例如屏障)的情况下, 子组内的工作项可以序列化。在......的存在下 子组功能,子组内的工作项可以序列化 在任何给定的子组函数之前,动态遇到之间 成对的子组函数和一个工作组函数和 内核结束。

    有时甚至会失去同步的方式。

    除此之外,

     sub_group_all() and
    sub_group_broadcast() and are described in OpenCL C++ kernel language and IL specifications.
    The use of these sub-group functions implies sequenced-before relationships between statements
    within the execution of a single work-item in order to satisfy data dependencies.
    

    说存在某种子组内通信。因为现在 opencl 有子内核定义:

    Device-side enqueue: A mechanism whereby a kernel-instance is enqueued by a kernel-instance
    running on a device without direct involvement by the host program. This produces nested
    parallelism; i.e. additional levels of concurrency are nested inside a running kernel-instance.
    The kernel-instance executing on a device (the parent kernel) enqueues a kernel-instance (the
    child kernel) to a device-side command queue. Child and parent kernels execute asynchronously
    though a parent kernel does not complete until all of its child-kernels have completed. 
    

    最终,像

    kernel void launcher()
    {
        ndrange_t ndrange = ndrange_1D(1);
        enqueue_kernel(get_default_queue(), CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange,
        ^{
        size_t id = get_global_id(0);
        }
        );
    }
    

    您应该能够生成您自己的(升级的?)波前,具有您需要的任何大小,并且它们与父内核同时工作(并且可以在子组内进行通信),但它们不被称为波前,因为它们没有硬编码通过硬件恕我直言。


    2.0 api 规范说:

    Extreme care should be exercised when writing code that uses
    subgroups if the goal is to write portable OpenCL applications.
    

    这让人想起 amd 的 16 宽 simd 和 nvidia 的 32 宽 simd 与一些虚构的 fpga 的 95 宽计算核心。可能是伪波前?

    【讨论】:

    • 谢谢!但这是什么意思,可能是什么问题:Extreme care should be exercised when writing code that uses subgroups if the goal is to write portable OpenCL applications?正如那里所说:**Sub-groups are a logical abstraction of the hardware SIMD execution model** akin to wavefronts: page-100: amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/…
    • 如果子组是硬件 SIMD 的逻辑抽象,并且如果在运行时我可以使用 get_sub_group_size()/@987654336 获取当前设备的子组 (SIMD) 的宽度@,哪里会出现问题?第 160 页:amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/…
    • get_max_sub_group_size: 它说This value will be invariant for a given set of dispatch dimensions and a kernel object compiled for a given device 所以它会工作
    • @Alex 我不是 100% 确定,但我认为警告可能意味着,来自给定子组的所有线程必须完全执行相同的说明:转到相同的 if 分支,在循环中执行相同数量的步骤等以遵守 SIMD 合同(当然,除非您使用屏障,但我想重点是尽可能避免它)。在这方面,某些硬件可能比其他硬件更宽容,这可能是潜在可移植性问题的原因。
    • @Alex 我之前的想法似乎是不正确的,因为 GPU 实际上使用 SIMT,这允许线程之间的执行路径存在差异(差异使其速度慢得多,因为在后台所有线程都执行所有路径在这种情况下)。
    猜你喜欢
    • 1970-01-01
    • 2010-10-19
    • 2015-01-03
    • 2014-03-29
    • 1970-01-01
    • 2011-03-16
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多