Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef ALLTOALL_V_INFO_PUB_H
12 : #define ALLTOALL_V_INFO_PUB_H
13 :
14 : #include <list>
15 : #include "hccl_types.h"
16 : #include "mem_device_pub.h"
17 :
18 : namespace hccl {
19 :
20 : struct RemoteMem {
21 : DeviceMem remoteScratchPingMem;
22 : DeviceMem remoteScratchPongMem;
23 : };
24 :
25 : struct SendDataBlock {
26 : u64 sendLen;
27 : u64 userInOffset;
28 : u64 scratchOffset;
29 : };
30 :
31 : struct ReadDataBlock {
32 : u64 recvLen;
33 : u64 remoteOffset;
34 : u64 recvOffset;
35 : };
36 :
37 : struct RecvDataBlock {
38 : u64 recvOffset;
39 : u64 recvLen;
40 : u64 scratchOffset;
41 : };
42 :
43 : struct AlltoallSendRecvInfo {
44 : std::vector<SendDataBlock> sendInfo;
45 : std::vector<ReadDataBlock> readInfo;
46 : };
47 :
48 : // alltoallv_mesh_read_only_pub.h
49 : struct DataTrace {
50 : u32 dataIndex;
51 : u64 dataOffset;
52 : };
53 :
54 : // alltoallv_for_310p_pub.h
55 : const uint32_t COMPUTE_CONST = 2; // 计算Rank类型用到的常量
56 : const uint32_t STEP_NUM = 5;
57 : const uint32_t THIRD_STEP = 3;
58 : const uint32_t MAX_RANK_GAP = 3;
59 : const uint32_t DUO_RANK_NUM = 4;
60 : const uint32_t ALIGN_CONST = 128;
61 :
62 : // alltoallv_direct_fullmesh_pub.h
63 : const uint32_t ALLTOALLV_DIRECT_FULLMESH_SDMA_CONCURRENT_SIZE = 8; // SDMA链路上的并发数量
64 : const uint32_t ALLTOALLV_DIRECT_FULLMESH_RDMA_CONCURRENT_SIZE = 1; // RDMA链路上的并发数量
65 : const uint32_t RANK_SET_COMPUTE_CONST = 2; // 计算对端Rank用到的常量
66 : const uint32_t ALLTOALLV_DIRECT_FULLMESH_BIG_SIZE = 1 * 1024 * 1024; // 大数据量走并发拷贝的标准
67 :
68 : struct AlltoAllVBufferInfo {
69 : DeviceMem mem;
70 : u64* counts = nullptr;
71 : u64* displs = nullptr;
72 : HcclDataType dataType = HCCL_DATA_TYPE_RESERVED;
73 :
74 0 : AlltoAllVBufferInfo& operator=(const AlltoAllVBufferInfo& that) noexcept
75 : {
76 0 : if (&that != this) {
77 0 : mem = that.mem;
78 0 : counts = that.counts;
79 0 : displs = that.displs;
80 0 : dataType = that.dataType;
81 : }
82 0 : return *this;
83 : }
84 :
85 : AlltoAllVBufferInfo& operator=(const AlltoAllVBufferInfo&& that) noexcept
86 : {
87 : if (&that != this) {
88 : mem = that.mem;
89 : counts = that.counts;
90 : displs = that.displs;
91 : dataType = that.dataType;
92 : }
93 : return *this;
94 : }
95 : };
96 :
97 : struct OneSendRecvAddrInfo {
98 : u64 localOffset;
99 : u64 localLength;
100 : u64 remoteOffset;
101 : u64 remoteLength;
102 : };
103 :
104 : using StageAlltoAllVAddrInfo = std::map<u32, std::list<OneSendRecvAddrInfo>>; // key: remote rank in local communicator
105 :
106 : class A2aPipelineMemory {
107 : public:
108 : DeviceMem userInput;
109 : DeviceMem userOutput;
110 : DeviceMem scratchMem; // 图模式使用
111 : DeviceMem cclInBuffer; // 单算子模式使用
112 : DeviceMem cclOutBuffer; // 单算子模式使用
113 : };
114 :
115 : } // namespace hccl
116 : #endif
|