Skip to content
版 本

sync

产 品 支 持 情 况

  • Ascend 950PR/Ascend 950DT:支 持
  • Atlas A3 训 练 系 列 产 品/Atlas A3 推 理 系 列 产 品:不 支 持
  • Atlas A2 训 练 系 列 产 品/Atlas A2 推 理 系 列 产 品:不 支 持
  • Atlas 200I/500 A2 推 理 产 品:不 支 持
  • Atlas 推 理 系 列 产 品AI Core:不 支 持
  • Atlas 推 理 系 列 产 品Vector Core:不 支 持
  • Atlas 训 练 系 列 产 品:不 支 持

功 能 说 明

同 步 线 程 块 内 所 有 线 程,所 有 线 程 都 执 行 到 该 同 步 点 位 置 才 能 继 续 执 行。

函 数 原 型

C++
static void sync()

参 数 说 明

返 回 值 说 明

约 束 说 明

必 须 保 证 线 程 块 内 所 有 线 程 都 能 执 行 到 同 一 个sync()调 用,否 则 会 导 致 卡 死。

调 用 示 例

  • SIMT编 程 场 景:

    C++
    using namespace cooperative_groups;
    __global__ void simt_kernel(...)
    {
        ...
        thread_block g = this_thread_block();
        g.sync(); // 同 步 线 程 块 内 所 有 线 程
        ...
    }
    
  • SIMD与SIMT混 合 编 程 场 景:

    C++
    using namespace cooperative_groups;
    __simt_vf__ inline void simt_kernel(...)
    {
        ...
        thread_block g = this_thread_block();
        g.sync(); // 同 步 线 程 块 内 所 有 线 程
        ...
    }
    

免 责 声 明:本 站 内 容 由 asc-devkit 仓 master 分 支 自 动 编 译 生 成,属 于 持 续 开 发 版 本,可 能 存 在 缺 陷,仅 供 预 览 与 参 考。如 需 稳 定 及 商 用 资 料,请 查 阅 官 方 昇 腾 社 区