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 236 : HcclResult InitWorkflowMode(HcclWorkflowMode mode)
25 : {
26 236 : CHK_RET(SetWorkflowMode(mode));
27 236 : return HCCL_SUCCESS;
28 : }
29 :
30 1184 : HcclResult SetWorkflowMode(HcclWorkflowMode mode)
31 : {
32 1184 : g_workflowMode = mode;
33 1184 : return HCCL_SUCCESS;
34 : }
35 :
36 61390 : HcclWorkflowMode GetWorkflowMode() { return g_workflowMode; }
37 :
38 0 : void SetLaunchKernelMode(bool state) { g_isLaunchKernel = state; }
39 :
40 13 : bool IsLaunchKernelMode(void) { return g_isLaunchKernel; }
41 :
42 0 : void SetTaskNumCalMode(bool state) { g_isTaskNumCal = state; }
43 :
44 1164 : bool IsTaskNumCalMode(void) { return g_isTaskNumCal; }
|