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 __AICPU_ALGORITHM_H__
12 : #define __AICPU_ALGORITHM_H__
13 :
14 : #include <memory>
15 :
16 : #include "aicpu_dispatcher.h"
17 : #include "task_orchestrator.h"
18 :
19 : constexpr uint32_t RING_NUM = 2U;
20 :
21 : class AicpuAlgorithm {
22 : public:
23 101 : explicit AicpuAlgorithm(AicpuComContext* ctx)
24 101 : {
25 101 : ctx_ = ctx;
26 101 : rankId_ = ctx_ != nullptr ? ctx_->rankId : 0U;
27 101 : rankNum_ = ctx_ != nullptr ? ctx_->rankNum : 0U;
28 101 : unitSize_ = ctx_ != nullptr ? ctx_->unitSize : 0U;
29 101 : turn_ = ctx_ != nullptr ? ctx_->curTurnCnt : 0U;
30 101 : }
31 100 : virtual ~AicpuAlgorithm() = default;
32 :
33 : virtual HcclResult RunAlgorithm(
34 : HcclReduceOp opType, void* sendBuffer, void* recvBuffer, u64 dataCount, HcclDataType dataType,
35 : u64 strideLen = 0, AivAicpuOpParam* nextTask = nullptr)
36 : = 0;
37 :
38 : protected:
39 : AicpuComContext* ctx_{nullptr};
40 : uint32_t rankId_{0U};
41 : uint32_t rankNum_{0U};
42 : uint32_t unitSize_{0U};
43 : uint32_t turn_{0U};
44 : };
45 :
46 : #endif
|