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