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 ZERO_COPY_ACL_GRAPH_H
12 : #define ZERO_COPY_ACL_GRAPH_H
13 : #include <atomic>
14 : #include <memory>
15 : #include <hccl/hccl_types.h>
16 : #include <set>
17 : #include "hccl_communicator_attrs.h"
18 : #include "hccl/base.h"
19 : #include "hccl_impl_pub.h"
20 : #include "zero_copy/zero_copy_memory_agent.h"
21 : #include "coll_alg_operator.h"
22 : #include "hccl_alg.h"
23 : namespace hccl {
24 : class ZeroCopyAclGraph {
25 : public:
26 : ZeroCopyAclGraph();
27 810 : ~ZeroCopyAclGraph() = default;
28 : bool
29 : SetAclGraphZeroCopyMode(DevType deviceType, HcclCMDType opType, OpParam& opParam, HcclAlg* impl, u64 bufferSize);
30 : std::string GetTagPrefix();
31 : void SetRetryEnable(bool retryEnable);
32 :
33 : private:
34 : bool IsAlgoSupportAclGraphZeroCopyMode(HcclCMDType opType, OpParam& opParam, HcclAlg* impl, u64 bufferSize);
35 : bool IsScratchMemorySupportAclGraphZeroCopyMode(const OpParam& opParam, u64 bufferSize, u64 scratchMemSize);
36 : bool SetGraphMode(HcclCMDType opType, OpParam& opParam, HcclAlg* impl, u64 bufferSize);
37 : bool AlgoCheck(OpParam& opParam, std::unique_ptr<CollAlgOperator>& algo, u64 bufferSize);
38 : bool IsAclGraphZeroCopyAlgAvailable(HcclCMDType opType, OpParam& opParam);
39 :
40 : private:
41 : std::atomic<u32> tagResourceIndex_;
42 : std::set<HcclCMDType> algoSet_;
43 : bool retryEnable_;
44 : };
45 : } // namespace hccl
46 : #endif // end of ZERO_COPY_ACL_GRAPH_H
|