asc_gather
产 品 支 持 情 况
| 产 品 | 是 否 支 持 |
|---|---|
| √ | |
| √ |
功 能 说 明
将src按 照src_offset给 定 的 偏 移 按 元 素 收 集 到dst中。
函 数 原 型
前n个 数 据 计 算
C++__aicore__ inline void asc_gather(__ubuf__ int16_t* dst, __ubuf__ int16_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather(__ubuf__ uint16_t* dst, __ubuf__ uint16_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather(__ubuf__ half* dst, __ubuf__ half* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather(__ubuf__ bfloat16_t* dst, __ubuf__ bfloat16_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather(__ubuf__ int32_t* dst, __ubuf__ int32_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather(__ubuf__ uint32_t* dst, __ubuf__ uint32_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather(__ubuf__ float* dst, __ubuf__ float* src, __ubuf__ uint32_t* src_offset, uint32_t count)高 维 切 分 计 算
C++__aicore__ inline void asc_gather(__ubuf__ int16_t* dst, __ubuf__ int16_t* src, __ubuf__ uint32_t* src_offset, uint16_t dst_repeat_stride, uint8_t repeat) __aicore__ inline void asc_gather(__ubuf__ uint16_t* dst, __ubuf__ uint16_t* src, __ubuf__ uint32_t* src_offset, uint16_t dst_repeat_stride, uint8_t repeat) __aicore__ inline void asc_gather(__ubuf__ half* dst, __ubuf__ half* src, __ubuf__ uint32_t* src_offset, uint16_t dst_repeat_stride, uint8_t repeat) __aicore__ inline void asc_gather(__ubuf__ bfloat16_t* dst, __ubuf__ bfloat16_t* src, __ubuf__ uint32_t* src_offset, uint16_t dst_repeat_stride, uint8_t repeat) __aicore__ inline void asc_gather(__ubuf__ int32_t* dst, __ubuf__ int32_t* src, __ubuf__ uint32_t* src_offset, uint16_t dst_repeat_stride, uint8_t repeat) __aicore__ inline void asc_gather(__ubuf__ uint32_t* dst, __ubuf__ uint32_t* src, __ubuf__ uint32_t* src_offset, uint16_t dst_repeat_stride, uint8_t repeat) __aicore__ inline void asc_gather(__ubuf__ float* dst, __ubuf__ float* src, __ubuf__ uint32_t* src_offset, uint16_t dst_repeat_stride, uint8_t repeat)同 步 计 算
C++__aicore__ inline void asc_gather_sync(__ubuf__ int16_t* dst, __ubuf__ int16_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather_sync(__ubuf__ uint16_t* dst, __ubuf__ uint16_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather_sync(__ubuf__ half* dst, __ubuf__ half* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather_sync(__ubuf__ bfloat16_t* dst, __ubuf__ bfloat16_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather_sync(__ubuf__ int32_t* dst, __ubuf__ int32_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather_sync(__ubuf__ uint32_t* dst, __ubuf__ uint32_t* src, __ubuf__ uint32_t* src_offset, uint32_t count) __aicore__ inline void asc_gather_sync(__ubuf__ float* dst, __ubuf__ float* src, __ubuf__ uint32_t* src_offset, uint32_t count)
参 数 说 明
| 参 数 名 | 输 入/输 出 | 描 述 |
|---|---|---|
| dst | 输 出 | 目 的 操 作 数(矢 量)的 起 始 地 址。 |
| src | 输 入 | 源 操 作 数(矢 量)的 起 始 地 址。 |
| src_offset | 输 入 | 源 操 作 数 的 每 个 元 素 对 应 的 地 址 偏 移,该 偏 移 量 相 对 于 源 操 作 数 的 起 始 基 地 址 而 言,单 位 为Bytes。 |
| count | 输 入 | 参 与 计 算 的 元 素 个 数。 |
| dst_repeat_stride | 输 入 | 目 的 操 作 数 相 邻 迭 代 间 相 同DataBlock的 地 址 步 长。 |
| repeat | 输 入 | 迭 代 次 数。 |
返 回 值 说 明
无
流 水 类 型
PIPE_V
约 束 说 明
- src_offset里 的 偏 移 量 取 值 应 保 证src元 素 类 型 位 宽 对 齐。
- src加 上src_offset偏 移 后 的 地 址 不 能 超 出Unified Buffer (UB)大 小 数 据 的 范 围。
- dst、src的 起 始 地 址 需 要32字 节 对 齐。
- 操 作 数 地 址 重 叠 约 束 请 参 考通 用 地 址 重 叠 约 束。
调 用 示 例
C++
constexpr uint64_t total_length = 128; // total_length指 参 与 计 算 的 数 据 长 度
__ubuf__ half src[total_length];
__ubuf__ uint32_t src_offset[total_length];
__ubuf__ half dst[total_length];
asc_gather(dst, src, src_offset, total_length);
// src [1, 2, 3, ..., 126, 127, 128],128个half类 型 数 据
// src_offset [254, 252, 250, ..., 4, 2, 0],对 应src中 每 个 元 素 的 偏 移 量,基 于src的 起 始 基 地 址,单 位 为Bytes
// dst [128, 127, 126, ..., 3, 2, 1]