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 <hccl_params_pub.h>
12 : #include "exception_util.h"
13 : #include "not_support_exception.h"
14 : #include "string_util.h"
15 : namespace Hccl {
16 3 : std::string CollOpParams::Describe() const
17 : {
18 3 : if (descOpMap.find(opType) != descOpMap.end()) {
19 3 : return descOpMap.at(opType).operator()(*this);
20 : } else {
21 0 : std::string msg = StringFormat("Does not support this operator=%s, please check.", opType.Describe().c_str());
22 0 : MACRO_THROW(NotSupportException, msg);
23 0 : }
24 : }
25 :
26 1 : std::string CollOpParams::DescReduceScatter(const CollOpParams &opParams)
27 : {
28 : return StringFormat("CollOpParams[opType=%s, dataType=%s, reduceOp=%s, recvCount=%llu, sendBuf=%p, recvBuf=%p]",
29 3 : opType.Describe().c_str(), opParams.dataType.Describe().c_str(),
30 4 : opParams.reduceOp.Describe().c_str(), opParams.count, opParams.sendBuf, opParams.recvBuf);
31 : }
32 :
33 1 : std::string CollOpParams::DescReduce(const CollOpParams &opParams)
34 : {
35 : return StringFormat("CollOpParams[opType=%s, dataType=%s, reduceOp=%s, recvCount=%llu, root=%u, sendBuf=%p, recvBuf=%p]",
36 3 : opType.Describe().c_str(), opParams.dataType.Describe().c_str(),
37 4 : opParams.reduceOp.Describe().c_str(), opParams.count, opParams.root, opParams.sendBuf, opParams.recvBuf);
38 : }
39 :
40 2 : std::string CollOpParams::DescAllreduce(const CollOpParams &opParams)
41 : {
42 : return StringFormat("CollOpParams[opType=%s, dataType=%s, reduceOp=%s, count=%llu, sendBuf=%p, recvBuf=%p]",
43 6 : opType.Describe().c_str(), opParams.dataType.Describe().c_str(),
44 8 : opParams.reduceOp.Describe().c_str(), opParams.count, opParams.sendBuf, opParams.recvBuf);
45 : }
46 :
47 1 : std::string CollOpParams::DescAllgather(const CollOpParams &opParams)
48 : {
49 : return StringFormat("CollOpParams[opType=%s, dataType=%s, sendCount=%llu, sendBuf=%p, recvBuf=%p]",
50 2 : opType.Describe().c_str(), opParams.dataType.Describe().c_str(), opParams.count,
51 3 : opParams.sendBuf, opParams.recvBuf);
52 : }
53 :
54 1 : std::string CollOpParams::DescScatter(const CollOpParams &opParams)
55 : {
56 : return StringFormat("CollOpParams[opType=%s, dataType=%s, sendCount=%llu, sendBuf=%p, recvBuf=%p, root=%u]",
57 2 : opType.Describe().c_str(), opParams.dataType.Describe().c_str(), opParams.count,
58 3 : opParams.sendBuf, opParams.recvBuf, opParams.root);
59 : }
60 :
61 1 : std::string CollOpParams::DescAlltoall(const CollOpParams &opParams)
62 : {
63 : return StringFormat("CollOpParams[opType=%s, sendCount=%llu, recvCount=%llu, sendType=%s, recvType=%s]",
64 2 : opType.Describe().c_str(), opParams.all2AllDataDes.sendCount, opParams.all2AllDataDes.recvCount,
65 3 : opParams.all2AllDataDes.sendType.Describe().c_str(), opParams.all2AllDataDes.recvType.Describe().c_str());
66 : }
67 :
68 1 : std::string CollOpParams::DescAlltoallV(const CollOpParams &opParams)
69 : {
70 : return StringFormat("CollOpParams[opType=%s, sendType=%s, recvType=%s]",
71 3 : opType.Describe().c_str(), opParams.all2AllVDataDes.sendType.Describe().c_str(),
72 4 : opParams.all2AllVDataDes.recvType.Describe().c_str());
73 : }
74 :
75 1 : std::string CollOpParams::DescAlltoallVC(const CollOpParams &opParams)
76 : {
77 : return StringFormat("CollOpParams[opType=%s, sendType=%s, recvType=%s]",
78 3 : opType.Describe().c_str(), opParams.all2AllVCDataDes.sendType.Describe().c_str(),
79 4 : opParams.all2AllVCDataDes.recvType.Describe().c_str());
80 : }
81 :
82 1 : std::string CollOpParams::DescSend(const CollOpParams &opParams)
83 : {
84 2 : return StringFormat("CollOpParams[opType=%s, dataType=%s, sendBuf=%p]", opType.Describe().c_str(),
85 3 : opParams.dataType.Describe().c_str(), opParams.sendBuf);
86 : }
87 :
88 1 : std::string CollOpParams::DescRecv(const CollOpParams &opParams)
89 : {
90 2 : return StringFormat("CollOpParams[opType=%s, dataType=%s, recvBuf=%p]", opType.Describe().c_str(),
91 3 : opParams.dataType.Describe().c_str(), opParams.recvBuf);
92 : }
93 :
94 2 : std::string CollOpParams::DescBroadcast(const CollOpParams &opParams)
95 : {
96 : return StringFormat("CollOpParams[opType=%s, dataType=%s, reduceOp=%s, recvCount=%llu, sendBuf=%p, recvBuf=%p]",
97 6 : opType.Describe().c_str(), opParams.dataType.Describe().c_str(),
98 8 : opParams.reduceOp.Describe().c_str(), opParams.count, opParams.sendBuf, opParams.recvBuf);
99 : }
100 :
101 1 : std::string CollOpParams::DescBatchSendRecv(const CollOpParams &opParams)
102 : {
103 : return StringFormat("CollOpParams[opType=%s, itemNum=%u",
104 1 : opType.Describe().c_str(), opParams.batchSendRecvDataDes.itemNum);
105 : }
106 :
107 1 : std::string CollOpParams::DescAllGatherV(const CollOpParams &opParams)
108 : {
109 2 : return StringFormat("CollOpParams[opType=%s, dataType=%s]", opType.Describe().c_str(),
110 3 : opParams.vDataDes.dataType.Describe().c_str());
111 : }
112 :
113 0 : std::string CollOpParams::DescReduceScatterV(const CollOpParams &opParams)
114 : {
115 0 : return StringFormat("CollOpParams[opType=%s, dataType=%s]", opType.Describe().c_str(),
116 0 : opParams.vDataDes.dataType.Describe().c_str());
117 : }
118 : }
|