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 "rts_1ton_cnt_notify.h"
12 : #include "exception_util.h"
13 : #include "task.h"
14 :
15 : namespace Hccl {
16 :
17 16 : Rts1ToNCntNotify::Rts1ToNCntNotify() : deviceId(HrtGetDevice()), devPhyId(HrtGetDevicePhyIdByIndex(HrtGetDevice())),
18 16 : handle(HrtCntNotifyCreate(deviceId)), id(HrtGetCntNotifyId(handle))
19 : {
20 16 : }
21 :
22 16 : Rts1ToNCntNotify::~Rts1ToNCntNotify()
23 : {
24 16 : DECTOR_TRY_CATCH("Rts1ToNCntNotify", HrtCntNotifyDestroy(handle));
25 16 : }
26 :
27 0 : std::unique_ptr<BaseTask> Rts1ToNCntNotify::WaitBits(u32 bitValue)
28 : {
29 0 : return std::make_unique<TaskWaitBits>(this, bitValue);
30 : }
31 :
32 0 : std::unique_ptr<BaseTask> Rts1ToNCntNotify::PostValue(u32 value)
33 : {
34 0 : return std::make_unique<TaskPostValue>(this, value);
35 : }
36 :
37 12 : void Rts1ToNCntNotify::WaitBits(u32 bitValue, u32 timeout, const Stream &stream) const
38 : {
39 12 : HrtCntNotifyWaitWithTimeOut(handle, stream.GetPtr(), HrtCntNotifyWaitMode::BITMAP, bitValue, timeout);
40 12 : }
41 :
42 7 : void Rts1ToNCntNotify::PostValue(u32 value, const aclrtStream &rtStream) const
43 : {
44 7 : HrtCntNotifyRecord(handle, rtStream, HrtCntNotifyRecordMode::STORE, value);
45 7 : }
46 :
47 4 : void Rts1ToNCntNotify::PostValue(u32 value, const Stream &stream) const
48 : {
49 4 : PostValue(value, stream.GetPtr());
50 4 : }
51 :
52 1 : std::string Rts1ToNCntNotify::Describe() const
53 : {
54 1 : return StringFormat("Rts1ToNCntNotify[handle=%p, id=%d]", handle, id);
55 : }
56 :
57 5 : std::vector<char> Rts1ToNCntNotify::GetUniqueId() const
58 : {
59 5 : BinaryStream binaryStream;
60 5 : binaryStream << id;
61 5 : binaryStream << devPhyId;
62 5 : std::vector<char> result;
63 5 : binaryStream.Dump(result);
64 5 : return result;
65 5 : }
66 :
67 : } // namespace Hccl
|