This repository has been archived by the owner on Nov 25, 2022. It is now read-only.
forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hexagon] Add power manager (apache#13162)
This PR adds a new class, HexagonPowerManager, which interfaces with the HAP_power API to request maximum performance. * Add Hexagon Power Manager * Remove HexagonPowerManager::LogPowerConfig * Delete HexagonPowerManager in ReleaseResources * Hexagon power manager must be destroyed after the thread manager
- Loading branch information
Showing
6 changed files
with
184 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#include "hexagon_power_manager.h" | ||
|
||
#include <AEEStdDef.h> | ||
#include <AEEStdErr.h> | ||
|
||
#include "HAP_power.h" | ||
#include "hexagon_common.h" | ||
|
||
namespace tvm { | ||
namespace runtime { | ||
namespace hexagon { | ||
|
||
HexagonPowerManager::HexagonPowerManager() { | ||
hap_pwr_ctx_ = HAP_utils_create_context(); | ||
PowerOnHVX(); | ||
PowerOnHTP(); | ||
SetAppType(); | ||
SetDCVS(); | ||
} | ||
|
||
HexagonPowerManager::~HexagonPowerManager() { | ||
PowerOffHTP(); | ||
PowerOffHVX(); | ||
HAP_utils_destroy_context(hap_pwr_ctx_); | ||
} | ||
|
||
void HexagonPowerManager::PowerOnHVX() { | ||
HAP_power_request_t pwr_req; | ||
|
||
pwr_req.type = HAP_power_set_HVX; | ||
pwr_req.hvx.power_up = true; | ||
HEXAGON_SAFE_CALL(HAP_power_set(hap_pwr_ctx_, &pwr_req)); | ||
} | ||
|
||
void HexagonPowerManager::PowerOffHVX() { | ||
HAP_power_request_t pwr_req; | ||
|
||
pwr_req.type = HAP_power_set_HVX; | ||
pwr_req.hvx.power_up = false; | ||
HEXAGON_SAFE_CALL(HAP_power_set(hap_pwr_ctx_, &pwr_req)); | ||
} | ||
|
||
void HexagonPowerManager::PowerOnHTP() { | ||
HAP_power_request_t pwr_req; | ||
|
||
pwr_req.type = HAP_power_set_HMX; | ||
pwr_req.hmx.power_up = true; | ||
HEXAGON_SAFE_CALL(HAP_power_set(hap_pwr_ctx_, &pwr_req)); | ||
} | ||
|
||
void HexagonPowerManager::PowerOffHTP() { | ||
HAP_power_request_t pwr_req; | ||
|
||
pwr_req.type = HAP_power_set_HMX; | ||
pwr_req.hmx.power_up = false; | ||
HEXAGON_SAFE_CALL(HAP_power_set(hap_pwr_ctx_, &pwr_req)); | ||
} | ||
|
||
void HexagonPowerManager::SetAppType() { | ||
HAP_power_request_t pwr_req; | ||
|
||
pwr_req.type = HAP_power_set_apptype; | ||
pwr_req.apptype = HAP_POWER_COMPUTE_CLIENT_CLASS; | ||
HEXAGON_SAFE_CALL(HAP_power_set(hap_pwr_ctx_, &pwr_req)); | ||
} | ||
|
||
void HexagonPowerManager::SetDCVS() { | ||
HAP_power_request_t pwr_req; | ||
|
||
memset(&pwr_req, 0, sizeof(HAP_power_request_t)); | ||
pwr_req.type = HAP_power_set_DCVS_v3; | ||
pwr_req.dcvs_v3.set_dcvs_enable = TRUE; | ||
pwr_req.dcvs_v3.dcvs_enable = FALSE; | ||
pwr_req.dcvs_v3.set_core_params = TRUE; | ||
pwr_req.dcvs_v3.core_params.min_corner = HAP_DCVS_VCORNER_TURBO_PLUS; | ||
pwr_req.dcvs_v3.core_params.max_corner = HAP_DCVS_VCORNER_TURBO_PLUS; | ||
pwr_req.dcvs_v3.core_params.target_corner = HAP_DCVS_VCORNER_TURBO_PLUS; | ||
pwr_req.dcvs_v3.set_bus_params = TRUE; | ||
pwr_req.dcvs_v3.bus_params.min_corner = HAP_DCVS_VCORNER_TURBO_PLUS; | ||
pwr_req.dcvs_v3.bus_params.max_corner = HAP_DCVS_VCORNER_TURBO_PLUS; | ||
pwr_req.dcvs_v3.bus_params.target_corner = HAP_DCVS_VCORNER_TURBO_PLUS; | ||
pwr_req.dcvs_v3.set_sleep_disable = TRUE; | ||
pwr_req.dcvs_v3.sleep_disable = TRUE; | ||
HEXAGON_SAFE_CALL(HAP_power_set(hap_pwr_ctx_, &pwr_req)); | ||
} | ||
|
||
} // namespace hexagon | ||
} // namespace runtime | ||
} // namespace tvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef TVM_RUNTIME_HEXAGON_HEXAGON_POWER_MANAGER_H_ | ||
#define TVM_RUNTIME_HEXAGON_HEXAGON_POWER_MANAGER_H_ | ||
|
||
namespace tvm { | ||
namespace runtime { | ||
namespace hexagon { | ||
|
||
class HexagonPowerManager { | ||
public: | ||
//! \brief Constructor. | ||
HexagonPowerManager(); | ||
|
||
//! \brief Destructor. | ||
~HexagonPowerManager(); | ||
|
||
//! \brief Prevent copy construction of HexagonPowerManager. | ||
HexagonPowerManager(const HexagonPowerManager&) = delete; | ||
|
||
//! \brief Prevent copy assignment with HexagonPowerManager. | ||
HexagonPowerManager& operator=(const HexagonPowerManager&) = delete; | ||
|
||
//! \brief Prevent move construction. | ||
HexagonPowerManager(HexagonPowerManager&&) = delete; | ||
|
||
//! \brief Prevent move assignment. | ||
HexagonPowerManager& operator=(HexagonPowerManager&&) = delete; | ||
|
||
private: | ||
//! \brief Power context | ||
void* hap_pwr_ctx_; | ||
|
||
void PowerOnHVX(); | ||
void PowerOffHVX(); | ||
void PowerOnHTP(); | ||
void PowerOffHTP(); | ||
void SetAppType(); | ||
void SetDCVS(); | ||
}; | ||
|
||
} // namespace hexagon | ||
} // namespace runtime | ||
} // namespace tvm | ||
|
||
#endif // TVM_RUNTIME_HEXAGON_HEXAGON_POWER_MANAGER_H_ |