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(HcclReduceOp opType, void *sendBuffer, void *recvBuffer, u64 dataCount,
34 : HcclDataType dataType, u64 strideLen = 0, AivAicpuOpParam *nextTask = nullptr) = 0;
35 :
36 : protected:
37 : AicpuComContext *ctx_ { nullptr };
38 : uint32_t rankId_ { 0U };
39 : uint32_t rankNum_ { 0U };
40 : uint32_t unitSize_ { 0U };
41 : uint32_t turn_ { 0U };
42 : };
43 :
44 : #endif
|