Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hexagon] Create tests to showcase vtcm loading capabilities on Hexagon. #12667

Merged
merged 7 commits into from
Sep 13, 2022
2 changes: 1 addition & 1 deletion python/tvm/contrib/hexagon/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
remote_kw: dict,
session_name: str = "hexagon-rpc",
remote_stack_size_bytes: int = 256 * 1024, # Min size for main thread in QuRT/sim
rpc_receive_buffer_size_bytes: int = 5 * 1024 * 1024, # Size for passing hexagon tests
rpc_receive_buffer_size_bytes: int = 256 * 1024 * 1024, # Size for passing hexagon tests
):
self._launcher = launcher
self._session_name: str = session_name
Expand Down
9 changes: 5 additions & 4 deletions src/runtime/hexagon/hexagon_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct VTCMAllocation : public Allocation {

// allocate nbytes of vtcm on a single page
HEXAGON_SAFE_CALL(HAP_compute_res_attr_set_vtcm_param(&res_info, /*vtcm_size = */ nbytes,
/*b_single_page = */ 1));
/*b_single_page = */ 0));

// TODO(HWE): Investigate why a non-zero timeout results in
// hanging, both in the simulator and on hardware.
Expand All @@ -71,13 +71,14 @@ struct VTCMAllocation : public Allocation {
if (context_id_) {
data_ = HAP_compute_res_attr_get_vtcm_ptr(&res_info);
if (!data_) {
LOG(ERROR) << "ERROR: Allocated VTCM ptr is null.";
LOG(ERROR) << "ERROR: HAP_compute_res_acquire returned nullptr when allocating VTCM.";
HEXAGON_SAFE_CALL(HAP_compute_res_release(context_id_));
return;
}
} else {
LOG(ERROR) << "ERROR: Unable to acquire requeisted resource.";
return;
LOG(FATAL) << "FATAL: HAP_compute_res_acquire failed to acquire requested VTCM resource.";
throw std::runtime_error(
"HAP_compute_res_acquire failed to acquire requested VTCM resource.");
}
}
~VTCMAllocation() {
Expand Down
11 changes: 11 additions & 0 deletions src/runtime/hexagon/hexagon_device_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ void HexagonDeviceAPI::CopyDataFromTo(const void* from, size_t from_offset, void
memcpy(static_cast<char*>(to) + to_offset, static_cast<const char*>(from) + from_offset, size);
}

TVM_REGISTER_GLOBAL("device_api.hexagon.mem_copy_DLTensor")
.set_body([](TVMArgs args, TVMRetValue* rv) {
DLTensor* dst = args[0];
DLTensor* src = args[1];
int size = args[2];

hexagon_user_dma_1d_sync(dst->data, src->data, size);

*rv = static_cast<int32_t>(0);
});

TVM_REGISTER_GLOBAL("device_api.hexagon.mem_copy").set_body([](TVMArgs args, TVMRetValue* rv) {
void* dst = args[0];
void* src = args[1];
Expand Down
Loading