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 : #include "prim_queue.h"
12 :
13 : namespace Hccl {
14 :
15 7 : void PrimQueue::Append(unique_ptr<Primitive> prim)
16 : {
17 7 : auto primPtr = prim.get();
18 7 : if (primPtr->GetType() == PrimType::POST_TO) {
19 1 : PrimPostTo& postTo = static_cast<PrimPostTo&>(*primPtr);
20 1 : postTo.SetParent(shared_from_this());
21 6 : } else if (primPtr->GetType() == PrimType::WAIT_FROM) {
22 1 : PrimWaitFrom& waitFrom = static_cast<PrimWaitFrom&>(*primPtr);
23 1 : waitFrom.SetParent(shared_from_this());
24 5 : } else if (primPtr->GetType() == PrimType::WAIT_GROUP) {
25 1 : PrimWaitGroup& waitFrom = static_cast<PrimWaitGroup&>(*primPtr);
26 1 : waitFrom.SetParent(shared_from_this());
27 : }
28 7 : HierarchicalQueue::Append(std::move(prim));
29 7 : }
30 0 : void PrintPrimQueue(const PrimQueue& queue)
31 : {
32 0 : HCCL_INFO("Master queue: ");
33 0 : for (auto it = queue.Iter(); it.HasNext(); ++it) {
34 0 : HCCL_INFO(" %s", it->Describe().c_str());
35 0 : }
36 0 : for (auto slaveIt = queue.IterSlaves(); slaveIt.HasNext(); ++slaveIt) {
37 0 : HCCL_INFO("Slave queue %u: ", slaveIt->GetId());
38 0 : for (auto it = slaveIt->Iter(); it.HasNext(); ++it) {
39 0 : HCCL_INFO(" %s", it->Describe().c_str());
40 0 : }
41 0 : }
42 0 : }
43 : } // namespace Hccl
|