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 576 : std::size_t operator()(const Hccl::InstructionType& type) const noexcept { return static_cast<std::size_t>(type); }
27 : };
28 : } // namespace std
29 : namespace Hccl {
30 :
31 : class CommunicatorImpl;
32 :
33 : class Interpreter {
34 : public:
35 : using InsRule = std::function<void(const Instruction&, CommunicatorImpl&, const Stream&, const OpTaskConfig&)>;
36 :
37 : explicit Interpreter(CommunicatorImpl& communicator);
38 :
39 : void Submit(const InsQueue& insQueue);
40 :
41 : private:
42 : CommunicatorImpl& comm;
43 : std::unordered_map<InstructionType, InsRule> insRuleMap;
44 : OpTaskConfig taskConfig{};
45 :
46 : void SubmitSlaveQueueAlternatively(list<InsQueue::Iterator>& slaveQueueIters, std::set<u32>& slaveStreamIndexSet);
47 : void SubmitMasterQueueAlternatively(InsQueue::Iterator& masterQueueIter);
48 : };
49 : } // namespace Hccl
50 :
51 : #endif // !HCCLV2_INTERPRETER_H
|