tiled_partition
产 品 支 持 情 况
- Ascend 950PR/Ascend 950DT:支 持
- Atlas A3 训 练 系 列 产 品/Atlas A3 推 理 系 列 产 品:不 支 持
- Atlas A2 训 练 系 列 产 品/Atlas A2 推 理 系 列 产 品:不 支 持
- Atlas 200I/500 A2 推 理 产 品:不 支 持
- Atlas 推 理 系 列 产 品AI Core:不 支 持
- Atlas 推 理 系 列 产 品Vector Core:不 支 持
- Atlas 训 练 系 列 产 品:不 支 持
功 能 说 明
tiled_partition API用 于 将 一 个 线 程 组 划 分 为 多 个 更 小、固 定 大 小 的 子 组,以 便 线 程 在 以 更 精 细 的 粒 度 上 进 行 协 作。提 供 模 板 和 非 模 板 两 个 版 本 的 接 口,分 别 用 于 编 译 时 确 定 划 分 大 小 以 及 运 行 时 确 定 划 分 大 小 的 场 景。
函 数 原 型
C++
template <unsigned int Size, typename ParentT>
thread_block_tile<Size, ParentT> tiled_partition(const ParentT& g)
C++
thread_group tiled_partition(const thread_group& parent, unsigned int tilesz)
C++
thread_group tiled_partition(const thread_block& parent, unsigned int tilesz)
C++
coalesced_group tiled_partition(const coalesced_group& parent, unsigned int tilesz)
参 数 说 明
表 1 模 板 版 本 参 数 说 明
| 参 数 名 | 输 入/输 出 | 描 述 |
|---|---|---|
| g | 输 入 | 被 划 分 的 父 组,类 型 只 能 是thread_block或thread_block_tile。 |
| Size | 输 入 | 模 板 参 数,指 定 划 分 出 的thread_block_tile组 大 小。 |
表 2 非 模 板 版 本 参 数 说 明
| 参 数 名 | 输 入/输 出 | 描 述 |
|---|---|---|
| parent | 输 入 | 被 划 分 的 父 组,类 型 只 能 是thread_block或coalesced_group。 |
| tilesz | 输 入 | 指 定 划 分 出 的 子 组 大 小。 |
返 回 值 说 明
返 回 划 分 出 的 子 组 对 象。
约 束 说 明
Size必 须 是$2^n$,并 且 必 须 小 于 等 于32(warpSize),当 前 可 选 值 范 围:1、2、4、8、16、32。- 对 于 模 板 版 本 的 接 口,父 组 中 的 线 程 数 必 须 能 被
Size整 除。并 且 如 果 父 组 是thread_block_tile,则Size必 须 小 于 父 组 大 小。
调 用 示 例
SIMT编 程 场 景:
C++using namespace cooperative_groups; __global__ void simt_kernel(...) { ... thread_block block = this_thread_block(); auto tile4 = tiled_partition<4>(block); ... }SIMD与SIMT混 合 编 程 场 景:
C++using namespace cooperative_groups; __simt_vf__ inline void simt_kernel(...) { ... thread_block block = this_thread_block(); auto tile4 = tiled_partition<4>(block); ... }