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