nverke commented on code in PR #13181:
URL: https://github.com/apache/tvm/pull/13181#discussion_r1005064379
##########
src/runtime/hexagon/hexagon_hvx.cc:
##########
@@ -31,25 +31,28 @@ namespace tvm {
namespace runtime {
namespace hexagon {
-HexagonHvx::HexagonHvx() {
- // Reserve HVX.
- int res = qurt_hvx_reserve(QURT_HVX_RESERVE_ALL_AVAILABLE);
- CHECK((res != QURT_HVX_RESERVE_NOT_SUPPORTED) && (res !=
QURT_HVX_RESERVE_NOT_SUCCESSFUL))
- << "error reserving HVX: " << res;
+HexagonHvx::HexagonHvx() { Acquire(); }
- // Lock HVX.
+HexagonHvx::~HexagonHvx() { Release(); }
+
+void HexagonHvx::Acquire() {
+ reserved_count_ = qurt_hvx_reserve(QURT_HVX_RESERVE_ALL);
+ CHECK(reserved_count_ == QURT_HVX_RESERVE_ALL) << "error reserving HVX: " <<
reserved_count_;
+}
+
+void HexagonHvx::Release() {
+ int rel = qurt_hvx_cancel_reserve();
+ CHECK(rel == 0) << "error releasing HVX: " << rel;
+}
+
+void HexagonHvx::Lock() {
int lck = qurt_hvx_lock(QURT_HVX_MODE_128B);
CHECK(lck == 0) << "error locking HVX: " << lck;
}
-HexagonHvx::~HexagonHvx() {
Review Comment:
This destructor unlocks and then releases HVX, but the new one just
releases. Do we not need to unlock upon destruction?
--
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]