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