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 "profiling_manager_device.h"
12 : #include "profiling_command_handle.h"
13 : namespace hccl {
14 0 : int32_t DeviceCommandHandle(uint32_t profType, void *data, uint32_t len) {
15 0 : HCCL_INFO("[%s] start", __func__);
16 : (void)len;
17 0 : if (data == nullptr) {
18 0 : HCCL_ERROR("[%s] CommandHandle's data is NULL.", __func__);
19 0 : return PROF_FAILED;
20 : }
21 0 : MsprofCommandHandle *command = reinterpret_cast<MsprofCommandHandle *>(data);
22 0 : auto type = command->type;
23 0 : HCCL_INFO("[%s] type = [%u]. CommandHandle_switch = [%llu]", __func__, type, command->profSwitch);
24 : // 目前只会有两种状态 开启或者关闭
25 0 : if (type == PROF_COMMANDHANDLE_TYPE_START) {
26 0 : if ((ADPROF_TASK_TIME_L0 & command->profSwitch) != 0) {
27 0 : dfx::ProfilingManager::SetProL0On(true);
28 : }
29 0 : if ((ADPROF_TASK_TIME_L1 & command->profSwitch) != 0) {
30 0 : dfx::ProfilingManager::SetProL1On(true);
31 : }
32 0 : } else if (type == PROF_COMMANDHANDLE_TYPE_STOP) {
33 0 : dfx::ProfilingManager::SetProL0On(false);
34 0 : dfx::ProfilingManager::SetProL1On(false);
35 : }
36 0 : return PROF_SUCCESS;
37 : }
38 : }
|