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_channel_config.h"
12 : #include "log.h"
13 : #include "exception_handler.h"
14 :
15 0 : HcclResult HcclChannelConfigCreate(HcclChannelConfig* config)
16 : {
17 0 : CHK_PTR_NULL(config);
18 0 : NEW_NOTHROW(*config, hccl::HcclChannelConfigData(), return HCCL_E_PTR);
19 0 : return HCCL_SUCCESS;
20 : }
21 :
22 0 : HcclResult HcclChannelConfigDestroy(HcclChannelConfig config)
23 : {
24 0 : if (config == nullptr) {
25 0 : return HCCL_SUCCESS;
26 : }
27 0 : auto* cfg = static_cast<hccl::HcclChannelConfigData*>(config);
28 0 : delete cfg;
29 0 : return HCCL_SUCCESS;
30 : }
31 :
32 0 : HcclResult HcclChannelConfigSetInt(HcclChannelConfig config, HcclChannelConfigType type, uint32_t value)
33 : {
34 0 : CHK_PTR_NULL(config);
35 0 : auto* cfg = static_cast<hccl::HcclChannelConfigData*>(config);
36 0 : switch (type) {
37 0 : case HCCL_CHANNEL_CONFIG_TYPE_IS_SHARED_QUEUE:
38 0 : cfg->isSharedQueue = (value != 0);
39 0 : HCCL_INFO("[%s] set IS_SHARED_QUEUE=%d.", __func__, static_cast<int>(cfg->isSharedQueue));
40 0 : break;
41 0 : default:
42 0 : HCCL_ERROR("[%s] invalid int config type[%d].", __func__, static_cast<int>(type));
43 0 : return HCCL_E_PARA;
44 : }
45 0 : return HCCL_SUCCESS;
46 : }
47 :
48 0 : HcclResult HcclChannelConfigSetStr(HcclChannelConfig config, HcclChannelConfigType type, const char* value)
49 : {
50 0 : CHK_PTR_NULL(config);
51 0 : CHK_PTR_NULL(value);
52 0 : auto* cfg = static_cast<hccl::HcclChannelConfigData*>(config);
53 0 : switch (type) {
54 0 : case HCCL_CHANNEL_CONFIG_TYPE_SHARED_QUEUE_TAG:
55 0 : cfg->sharedQueueTag = std::string(value);
56 0 : HCCL_INFO("[%s] set SHARED_QUEUE_TAG=%s.", __func__, cfg->sharedQueueTag.c_str());
57 0 : break;
58 0 : default:
59 0 : HCCL_ERROR("[%s] invalid str config type[%d].", __func__, static_cast<int>(type));
60 0 : return HCCL_E_PARA;
61 : }
62 0 : return HCCL_SUCCESS;
63 : }
|