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