thread_rank
产 品 支 持 情 况
- Ascend 950PR/Ascend 950DT:支 持
- Atlas A3 训 练 系 列 产 品/Atlas A3 推 理 系 列 产 品:不 支 持
- Atlas A2 训 练 系 列 产 品/Atlas A2 推 理 系 列 产 品:不 支 持
- Atlas 200I/500 A2 推 理 产 品:不 支 持
- Atlas 推 理 系 列 产 品AI Core:不 支 持
- Atlas 推 理 系 列 产 品Vector Core:不 支 持
- Atlas 训 练 系 列 产 品:不 支 持
功 能 说 明
获 取 当 前 线 程 在coalesced_group组 内 的 排 名,排 名 从0开 始。
函 数 原 型
C++
unsigned long long thread_rank() const
参 数 说 明
无
返 回 值 说 明
当 前 线 程 在coalesced_group组 内 的 排 名。
约 束 说 明
无
调 用 示 例
示 例 代 码 中 的 条 件 分 支 将 一 个warp中 所 有 线 程id是 偶 数 的 线 程 组 成coalesced_group协 作 组,组 内 各 线 程thread_rank接 口 返 回 结 果 如 下 图 所 示。
图 1 coalesced_group组 内 各 线 程rank
SIMT编 程 场 景:
C++using namespace cooperative_groups; __global__ void simt_kernel(...) { ... if (threadIdx.x % 2 == 0) { coalesced_group active = coalesced_threads(); unsigned long long rank = active.thread_rank(); } ... }SIMD与SIMT混 合 编 程 场 景:
C++using namespace cooperative_groups; __simt_vf__ inline void simt_kernel(...) { ... if (threadIdx.x % 2 == 0) { coalesced_group active = coalesced_threads(); unsigned long long rank = active.thread_rank(); } ... }