---
title: Mesh
description: "Mesh是FullMesh互联拓扑内的基础算法，是NPU之间的全连接，任意两个NPU之间可以直接进行数据收发。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/hcclug/hcclug_000116.html
sourcePath: /source/zh/canncommercial/900/API/hcclug/hcclug_000116.html
indexId: d8413f044a0cf6374c16af6583fb00bb5430fd6b18fa84b73389c548e3917c4459
---
# Mesh

#### 算法描述

Mesh是FullMesh互联拓扑内的基础算法，是NPU之间的全连接，任意两个NPU之间可以直接进行数据收发。


Mesh算法实现AllReduce算子的流程如下图所示，每个NPU并发的使用多路HCCS链路从对端读取或者写入数据，使双工互联链路的双向带宽同时得到利用。


Mesh算法的时间复杂度是O(1)。


#### 耗时计算


**表1 Mesh算法中各操作计算耗时**

| 操作 | 耗时 |
| --- | --- |
| Scatter |  |
| Gather |  |
| Broadcast | 实现为Scatter+ AllGather，耗时为 |
| Reduce | 实现为ReduceScatter+ Gather，耗时为 |
| ReduceScatter |  |
| AllGather |  |
| AllReduce | 实现为ReduceScatter + AllGather，耗时为 |
