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 <mutex>
12 : #include <array>
13 : #include "adapter_rts.h"
14 : #include "workflow_pub.h"
15 :
16 : static std::mutex g_workFlowModeMutex;
17 :
18 : // workflowMode 调整成线程变量,避免全局变量被并行修改
19 : static thread_local HcclWorkflowMode g_workflowMode = HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;
20 :
21 : static bool g_isLaunchKernel = false; // 是否为对接GE接口场景
22 : static bool g_isTaskNumCal = false; // 是否为tasknum精确评估
23 :
24 235 : HcclResult InitWorkflowMode(HcclWorkflowMode mode)
25 : {
26 235 : CHK_RET(SetWorkflowMode(mode));
27 235 : return HCCL_SUCCESS;
28 : }
29 :
30 1183 : HcclResult SetWorkflowMode(HcclWorkflowMode mode)
31 : {
32 1183 : g_workflowMode = mode;
33 1183 : return HCCL_SUCCESS;
34 : }
35 :
36 61052 : HcclWorkflowMode GetWorkflowMode()
37 : {
38 61052 : return g_workflowMode;
39 : }
40 :
41 0 : void SetLaunchKernelMode(bool state)
42 : {
43 0 : g_isLaunchKernel = state;
44 0 : }
45 :
46 13 : bool IsLaunchKernelMode(void)
47 : {
48 13 : return g_isLaunchKernel;
49 : }
50 :
51 0 : void SetTaskNumCalMode(bool state)
52 : {
53 0 : g_isTaskNumCal = state;
54 0 : }
55 :
56 1160 : bool IsTaskNumCalMode(void)
57 : {
58 1160 : return g_isTaskNumCal;
59 : }
|