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 "host_device_sync_notify_manager.h"
12 : namespace Hccl {
13 211 : HostDeviceSyncNotifyManager::HostDeviceSyncNotifyManager()
14 : {
15 211 : notifys[0] = std::make_unique<RtsNotify>(false);
16 211 : notifys[1] = std::make_unique<RtsNotify>(false);
17 211 : }
18 :
19 2 : RtsNotify *HostDeviceSyncNotifyManager::GetDeviceWaitNotify()
20 : {
21 2 : return notifys[0].get();
22 : }
23 :
24 2 : RtsNotify *HostDeviceSyncNotifyManager::GetHostWaitNotify()
25 : {
26 2 : return notifys[1].get();
27 : }
28 :
29 2 : void HostDeviceSyncNotifyManager::GetMc2AiCpuNotifys(u8 aicpuNotifyNum, void** aicpuNotify)
30 : {
31 2 : if (mc2AicpuNotifys_.size() < aicpuNotifyNum) {
32 11 : for (u16 i = mc2AicpuNotifys_.size(); i < aicpuNotifyNum; i++) {
33 10 : shared_ptr<RtsNotify> rtsNotify = make_shared<RtsNotify>(true);
34 10 : mc2AicpuNotifys_.push_back(rtsNotify);
35 10 : }
36 : }
37 20 : for (u16 i = 0; i < aicpuNotifyNum; i++) {
38 18 : *(aicpuNotify + i) = reinterpret_cast<void *>(mc2AicpuNotifys_[i].get()->GetHandleAddr());
39 : }
40 2 : }
41 :
42 1 : std::vector<char> HostDeviceSyncNotifyManager::GetPackedData()
43 : {
44 1 : std::vector<char> result;
45 1 : BinaryStream binaryStream;
46 1 : binaryStream << notifys[0]->GetUniqueId();
47 1 : binaryStream << notifys[1]->GetUniqueId();
48 1 : binaryStream.Dump(result);
49 :
50 1 : return result;
51 1 : }
52 : } // namespace Hccl
|