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 <algorithm>
12 : #include <mutex>
13 : #include <sstream>
14 : #include <string>
15 : #include "log.h"
16 : #include "env_config.h"
17 :
18 : using namespace hccl;
19 43 : HcclResult SetHcclAlgoConfig(const std::string& hcclAlgo)
20 : {
21 43 : std::string algoConfig = hcclAlgo;
22 43 : algoConfig.erase(std::remove(algoConfig.begin(), algoConfig.end(), ' '), algoConfig.end());
23 43 : if (algoConfig.empty()) {
24 1 : HCCL_RUN_INFO("hccl algo config is empty, HCCL use built-in algo selection.");
25 1 : return HCCL_SUCCESS;
26 : }
27 42 : std::vector<std::string> algoPerOptype;
28 42 : CHK_RET(SplitHcclOpType(algoConfig, algoPerOptype));
29 42 : bool anyCommonConfig = false;
30 42 : bool anySpecificConfig = false;
31 42 : CHK_RET(CheckAlgoConfigValid(algoPerOptype, anyCommonConfig, anySpecificConfig));
32 42 : if (anyCommonConfig) {
33 42 : CHK_RET(SetCommonAlgType(algoPerOptype));
34 : } else {
35 0 : g_envConfig.specificAlgoMode = anySpecificConfig;
36 0 : CHK_RET(SetSpecificAlgType(algoPerOptype));
37 : }
38 42 : return HCCL_SUCCESS;
39 43 : }
|