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 : ~AicpuStreamManager();
23 :
24 : void AllocStreams(u32 num);
25 :
26 : void Clear();
27 :
28 : u32 SizeOfStreams() const { return streams.size(); }
29 :
30 : void AllocFreeStream();
31 :
32 : void AclGraphCaptureFreeStream(const Stream* mainStream) const;
33 :
34 5 : Stream* GetFreeStream() const { return freeStream.get(); }
35 :
36 : std::vector<char> GetPackedData();
37 :
38 1 : std::vector<Stream*>& GetStreams() { return stream_pointers; }
39 :
40 : private:
41 : HcclResult CaptureFreeStream(const Stream* mainStream, const Stream* slaveStream) const;
42 : std::vector<std::unique_ptr<Stream>> streams;
43 : std::unique_ptr<Stream> freeStream{nullptr};
44 : std::vector<Stream*> stream_pointers;
45 : };
46 :
47 : } // namespace Hccl
48 : #endif
|