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 : #ifndef HCCLV2_AICPU_STREAM_MANAGER_H
11 : #define HCCLV2_AICPU_STREAM_MANAGER_H
12 :
13 : #include <vector>
14 : #include <memory>
15 : #include "stream.h"
16 :
17 : namespace Hccl {
18 :
19 : class AicpuStreamManager {
20 : public:
21 491 : explicit AicpuStreamManager()
22 491 : {
23 491 : }
24 : ~AicpuStreamManager();
25 :
26 : void AllocStreams(u32 num);
27 :
28 : void Clear();
29 :
30 : u32 SizeOfStreams() const
31 : {
32 : return streams.size();
33 : }
34 :
35 : void AllocFreeStream();
36 :
37 : void AclGraphCaptureFreeStream(const Stream *mainStream) const;
38 :
39 5 : Stream *GetFreeStream() const
40 : {
41 5 : return freeStream.get();
42 : }
43 :
44 : std::vector<char> GetPackedData();
45 :
46 1 : std::vector<Stream*>& GetStreams()
47 : {
48 1 : return stream_pointers;
49 : }
50 :
51 : private:
52 : HcclResult CaptureFreeStream(const Stream *mainStream, const Stream *slaveStream) const;
53 : std::vector<std::unique_ptr<Stream>> streams;
54 : std::unique_ptr<Stream> freeStream{nullptr};
55 : std::vector<Stream*> stream_pointers;
56 : };
57 :
58 : } // namespace Hccl
59 : #endif
|