janetsc commented on code in PR #13162: URL: https://github.com/apache/tvm/pull/13162#discussion_r1001872179
########## src/runtime/hexagon/hexagon_power_manager.cc: ########## @@ -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() { Review Comment: Can different HVX instances be powered on and off separately? ########## src/runtime/hexagon/hexagon_htp.cc: ########## @@ -35,39 +35,9 @@ namespace tvm { namespace runtime { namespace hexagon { -HexagonHtp::HexagonHtp() { - PowerOn(); - Acquire(); -} - -HexagonHtp::~HexagonHtp() { - Release(); - PowerOff(); -} - -void HexagonHtp::PowerOn() { - HAP_power_request_t pwr_req; - int nErr; - - hap_pwr_ctx_ = HAP_utils_create_context(); - pwr_req.type = HAP_power_set_HMX; - pwr_req.hmx.power_up = true; - if ((nErr = HAP_power_set(hap_pwr_ctx_, &pwr_req))) { - LOG(FATAL) << "InternalError: HAP_power_set failed\n"; - } -} - -void HexagonHtp::PowerOff() { - HAP_power_request_t pwr_req; - int nErr; +HexagonHtp::HexagonHtp() { Acquire(); } Review Comment: I'm working on this area, too. It is similar, but Acquire/Release are public methods now. And I'll be splitting out Acquire/Release to be called separately from thread_main and thread_exit. What you have here is good - it will be a merge for me, though! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
