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