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 "dispatcher_virtural.h"
12 : #include "hccl_tbe_task.h"
13 :
14 : namespace hccl {
15 521 : DispatcherVirtural::DispatcherVirtural(const s32 deviceLogicId)
16 521 : : DispatcherPub(deviceLogicId)
17 521 : {}
18 :
19 1042 : DispatcherVirtural::~DispatcherVirtural() {}
20 :
21 521 : HcclResult DispatcherVirtural::Init()
22 : {
23 : #ifndef HCCD
24 521 : if (deviceLogicId_ == HOST_DEVICE_ID) {
25 0 : return HCCL_SUCCESS;
26 : }
27 :
28 521 : aclrtContext ctx = nullptr;
29 521 : CHK_RET(hrtCtxGetCurrent(&ctx));
30 521 : if (ctx == nullptr) {
31 0 : CHK_RET(hrtSetDevice(deviceLogicId_));
32 0 : setDeviceFlag_ = true;
33 : }
34 :
35 521 : CHK_RET(HcclTbeTaskInit(deviceLogicId_));
36 : #else
37 : HCCL_ERROR("does not support this interface.");
38 : return HCCL_E_PARA;
39 : #endif
40 521 : return HCCL_SUCCESS;
41 : }
42 :
43 0 : HcclResult DispatcherVirtural::SignalRecord(HcclRtNotify signal, Stream &stream, u32 userRank, u64 offset, s32 stage,
44 : bool inchip, u64 signalAddr, u32 notifyId)
45 : {
46 : TaskLogicInfo info(0, TaskLogicType::DISPATCHER_TYPE, TaskLogicFuncType::DISPATCHER_SIGNALRECORD_TYPE,
47 0 : signal, userRank, offset, stage);
48 0 : stream.PushTaskLogicInfo(info);
49 :
50 0 : return HCCL_SUCCESS;
51 0 : }
52 :
53 0 : HcclResult DispatcherVirtural::SignalWait(HcclRtNotify signal, Stream &stream, u32 userRank, u32 remoteUserRank,
54 : s32 stage, bool inchip, u32 notifyId, u32 timeOut)
55 : {
56 : TaskLogicInfo info(0, TaskLogicType::DISPATCHER_TYPE, TaskLogicFuncType::DISPATCHER_SIGNALWAIT_TYPE, signal,
57 0 : userRank, remoteUserRank, stage);
58 0 : stream.PushTaskLogicInfo(info);
59 0 : return HCCL_SUCCESS;
60 0 : }
61 :
62 0 : HcclResult DispatcherVirtural::MemcpyAsync(hccl::DeviceMem &dst, const hccl::DeviceMem &src, hccl::Stream &stream,
63 : u32 remoteUserRank, hccl::LinkType inLinkType)
64 : {
65 0 : if (dst.size() < src.size()) {
66 0 : HCCL_ERROR(
67 : "The size of dst is smaller than that of src. dst addr[%p], dst size[%llu], src addr[%p], src size[%llu]",
68 : dst.ptr(), dst.size(), src.ptr(), src.size());
69 0 : return HCCL_E_PTR;
70 : }
71 :
72 : TaskLogicInfo info(0, TaskLogicType::DISPATCHER_TYPE, TaskLogicFuncType::DISPATCHER_MEMCPYASYNC_TYPE, dst.ptr(),
73 0 : dst.size(), src.ptr(), src.size(), HcclRtMemcpyKind::HCCL_RT_MEMCPY_KIND_DEVICE_TO_DEVICE);
74 :
75 0 : stream.PushTaskLogicInfo(info);
76 0 : return HCCL_SUCCESS;
77 0 : }
78 : } // namespace hccl
|