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