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 : #include "coll_all_gather_single_rank_executor.h"
12 :
13 : namespace hccl {
14 0 : CollAllGatherSingleRankExecutor::CollAllGatherSingleRankExecutor(const HcclDispatcher dispatcher,
15 0 : std::unique_ptr<TopoMatcher> &topoMatcher)
16 0 : : CollAllGatherExecutor(dispatcher, topoMatcher)
17 : {
18 0 : }
19 :
20 0 : HcclResult CollAllGatherSingleRankExecutor::KernelRun(const OpParam ¶m, ExecMem &execMem)
21 : {
22 0 : HCCL_CONFIG_INFO(HCCL_ALG, "[CollAllGatherSingleRankExecutor][KernelRun]AllGather single rank");
23 0 : u32 unitSize = SIZE_TABLE[param.DataDes.dataType];
24 0 : auto originalAlgTypeLevel1 = static_cast<u32>(algType_.algoLevel1);
25 0 : bool hugeData = (execMem.count * unitSize) > SDMA_SEND_MAX_SIZE;
26 0 : if (execMem.inputPtr == execMem.outputPtr) {
27 : // 通过CopyPattern字段区分不同的子图
28 0 : auto opMeta = HcclOpMetaInfo::GetOneForAllGather(originalAlgTypeLevel1, hugeData, false, CopyPattern::ZCOPY);
29 0 : CHK_RET(InitTask(dispatcher_, const_cast<Stream&>(param.stream), opMeta.isEnableCache, opMeta.GetCacheKey()));
30 : } else {
31 0 : auto opMeta = HcclOpMetaInfo::GetOneForAllGather(originalAlgTypeLevel1, hugeData, false, CopyPattern::BCOPY);
32 0 : CHK_RET(InitTask(dispatcher_, const_cast<Stream&>(param.stream), opMeta.isEnableCache, opMeta.GetCacheKey()));
33 : // ranksize = 1; input、output地址不同,input->output
34 0 : DeviceMem srcMem(execMem.inputPtr, execMem.count * unitSize);
35 0 : DeviceMem dstMem(execMem.outputPtr, execMem.count * unitSize);
36 0 : CHK_RET(HcclD2DMemcpyAsync(dispatcher_, dstMem, srcMem, const_cast<Stream&>(param.stream)));
37 0 : }
38 0 : CHK_RET(LaunchTaskExtend(dispatcher_, const_cast<Stream&>(param.stream), algResResp_->slaveStreams));
39 :
40 0 : return HCCL_SUCCESS;
41 : }
42 :
43 : REGISTER_EXEC("AllGatherSingleExecutor", AllGatherSingleRank, CollAllGatherSingleRankExecutor);
44 :
45 : } // namespace hccl
|