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 "one_sided_component_lite.h"
12 : #include <iostream>
13 : #include <string>
14 : #include <map>
15 : #include "log.h"
16 :
17 : namespace Hccl {
18 2 : HcclResult OneSidedComponentLite::Orchestrate(const HcclAicpuOpLite& op, InsQuePtr queue)
19 : {
20 6 : HCCL_INFO("[%s] Orchestrate Mode: Instruction.", __func__);
21 2 : bool isOneSidedComm = (op.algOperator.opType == OpType::BATCHPUT) || (op.algOperator.opType == OpType::BATCHGET);
22 :
23 2 : if (!isOneSidedComm) {
24 3 : HCCL_ERROR("[%s] OneSidedComm not support opType[%s].", __func__, op.algOperator.opType.Describe().c_str());
25 1 : return HCCL_E_PARA;
26 : }
27 :
28 1 : vector<RmaBufSliceLite> usrInSlice;
29 1 : vector<RmtRmaBufSliceLite> usrOutSlice;
30 :
31 1 : for (uint32_t i = 0; i < op.batchPutGetDescNum; i++) {
32 0 : HcclAicpuLocBufLite* localBuf = static_cast<HcclAicpuLocBufLite*>(op.batchPutGetLocalAddr) + i;
33 0 : usrInSlice.push_back(RmaBufSliceLite(localBuf->addr, localBuf->size, localBuf->tokenValue, localBuf->tokenId));
34 :
35 0 : HcclAicpuLocBufLite* rmtBuf = static_cast<HcclAicpuLocBufLite*>(op.batchPutGetRemoteAddr) + i;
36 0 : usrOutSlice.push_back(
37 0 : RmtRmaBufSliceLite(rmtBuf->addr, rmtBuf->size, 0, rmtBuf->tokenId, rmtBuf->tokenValue, UINT32_MAX));
38 : }
39 :
40 1 : RankId rmtRankId = op.sendRecvRemoteRank;
41 1 : vector<LinkData> link = linkMgr_->GetLinks(0, rmtRankId);
42 3 : HCCL_INFO("[%s] Orchestrate Mode: Instruction %d.", __func__, rmtRankId);
43 1 : if (op.algOperator.opType == OpType::BATCHGET) {
44 : std::unique_ptr<Instruction> ins
45 1 : = std::make_unique<InsBatchOneSidedRead>(rmtRankId, link[0], usrInSlice, usrOutSlice);
46 1 : queue->Append(std::move(ins));
47 1 : } else {
48 : std::unique_ptr<Instruction> ins
49 0 : = std::make_unique<InsBatchOneSidedWrite>(rmtRankId, link[0], usrInSlice, usrOutSlice);
50 0 : queue->Append(std::move(ins));
51 0 : }
52 :
53 3 : HCCL_INFO("[%s] finish orchestrate opType[%s].", __func__, op.algOperator.opType.Describe().c_str());
54 1 : return HcclResult::HCCL_SUCCESS;
55 1 : }
56 : } // namespace Hccl
|