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_INTERPRETER_H
12 : #define HCCLV2_INTERPRETER_H
13 :
14 : #include <functional>
15 : #include <unordered_map>
16 : #include <memory>
17 : #include <vector>
18 : #include <map>
19 : #include "ins_queue.h"
20 : #include "task.h"
21 : #include "op_task_config.h"
22 : #include "notify_timeout_cfg.h"
23 : namespace std {
24 : template <>
25 : struct hash<Hccl::InstructionType> {
26 861 : std::size_t operator () (const Hccl::InstructionType &type) const noexcept
27 : {
28 861 : return static_cast<std::size_t>(type);
29 : }
30 : };
31 : }
32 : namespace Hccl {
33 :
34 : class CommunicatorImpl;
35 :
36 : class Interpreter {
37 : public:
38 : using InsRule = std::function<void(const Instruction &, CommunicatorImpl &, const Stream &, const OpTaskConfig &)>;
39 :
40 : explicit Interpreter(CommunicatorImpl &communicator);
41 :
42 : void Submit(const InsQueue &insQueue);
43 :
44 : private:
45 : CommunicatorImpl &comm;
46 : std::unordered_map<InstructionType, InsRule> insRuleMap;
47 : OpTaskConfig taskConfig{};
48 :
49 : void SubmitSlaveQueueAlternatively(list<InsQueue::Iterator> &slaveQueueIters, std::set<u32> &slaveStreamIndexSet);
50 : void SubmitMasterQueueAlternatively(InsQueue::Iterator &masterQueueIter);
51 : };
52 : } // namespace Hccl
53 :
54 : #endif // !HCCLV2_INTERPRETER_H
|