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 "channel_config.h"
12 : #include "log.h"
13 : #include "exception_handler.h"
14 :
15 : namespace hcomm {
16 :
17 0 : HcommResult ChannelConfigCreate(HcommChannelConfig* config)
18 : {
19 0 : CHK_PTR_NULL(config);
20 0 : NEW_NOTHROW(*config, HcommChannelConfigData(), return HCCL_E_PTR);
21 0 : return HCCL_SUCCESS;
22 : }
23 :
24 0 : HcommResult ChannelConfigDestroy(HcommChannelConfig config)
25 : {
26 0 : if (config == nullptr) {
27 0 : return HCCL_SUCCESS;
28 : }
29 0 : auto* cfg = static_cast<HcommChannelConfigData*>(config);
30 0 : delete cfg;
31 0 : return HCCL_SUCCESS;
32 : }
33 :
34 0 : HcommResult ChannelConfigSetInt(HcommChannelConfig config, HcommChannelConfigType type, uint32_t value)
35 : {
36 0 : CHK_PTR_NULL(config);
37 0 : auto* cfg = static_cast<HcommChannelConfigData*>(config);
38 0 : switch (type) {
39 0 : case HCOMM_CHANNEL_CONFIG_TYPE_IS_SHARED_QUEUE:
40 0 : cfg->isSharedQueue = (value != 0);
41 0 : HCCL_INFO("[%s] set IS_SHARED_QUEUE=%d.", __func__, static_cast<int>(cfg->isSharedQueue));
42 0 : break;
43 0 : default:
44 0 : HCCL_ERROR("[%s] invalid int config type[%d].", __func__, static_cast<int>(type));
45 0 : return HCCL_E_PARA;
46 : }
47 0 : return HCCL_SUCCESS;
48 : }
49 :
50 : } // namespace hcomm
|