-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[RUNTIME] Initial implementation of Hexagon runtime support #5252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, awesome to see a major new runtime being added to TVM. I left a couple comments.
src/runtime/hexagon/README.md
Outdated
|
||
The TVM runtime that contains Hexagon runtime is the one executing on host. In either case, there will need to be a separate TVM runtime (i.e. the `libtvm_runtime.so` library) compiled for execution on Hexagon. | ||
|
||
The prerequisite is to have Hexagon SDK installed, preferably version 3.5.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a link to installing the Hexagon SDK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, is there a way to install it "automatically" to this back-end can be tested in the CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll add the link. I'm not sure about automatic install, because there is a license that needs to be accepted during installation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it might be hard to create an automatic installed version, we can look into at least do the compilation tests, to make sure that the runtime compiles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SDK link is https://developer.qualcomm.com/software/hexagon-dsp-sdk. I'll update the PR once the build completes (I want to see if it passes)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, and addressing the comments, the changes LGTM.
TVM_LOGD_HT("Done VTCM free from HexagonTarget::FreeVtcm"); | ||
} | ||
|
||
void HexagonTarget::CopyDeviceToDevice(void* dst, const void* src, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comment said: #3163 (comment) We should implement it. I tested on real device and find it is one must for device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
const DspRpcAPI* dsp_api = DspRpcAPI::Global(); | ||
const StubAPI* stub_api = StubAPI::Global(); | ||
|
||
stub_api->rpcmem_init_ptr()(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I maybe forget a little bit, because I do it last year. However, I remember rpcmem_init_ptr
will have problem when we set use_unsigned_pd
be false. In your code logic of this pr, you will always set use_unsigned_pd
be true. Could you double check it? I set it be false, because I find when we set it be true
, we can not do parallel on DSP. But I don't have device now and can not verify it sadly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can set it to false, would you prefer that? I don't think there is a way to make it a parameter that the user can provide at run time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I prefer setting it to be false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Could you provide the |
The IDL file and the implementation of the Hexagon-side target code will be upstreamed in an upcoming PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kparzysz-quic , the changes LGTM
src/runtime/hexagon/README.md
Outdated
USE_HEXAGON_SDK=/path/to/sdk | ||
``` | ||
|
||
Set the C/C++ compiler to `clang`, and pass `-DCMAKE_CXX_FLAGS='-stdlib=libc++'` to the cmake command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it a must? I use g++ and libstdc++ ever and no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we started, I was seeing some problems with libstdc++, but I don't remember what they were anymore. Since it worked for you, I removed this line.
CHECKED_CALL(ConfigureAppCommandLine, sim_dev_args_.size(), sim_dev_args_); | ||
|
||
LOG(INFO) << "HexagonSimulator: ConfigureHVXLength: 128"; | ||
CHECKED_CALL(ConfigureHVXLength, 128); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am concerning here. When we create Hexagon target and use HVX 64, but we write hard code of 128 here. We can not find the problem easily. I didn't think of good solution before too. If we don't have a better way, could we add comment in def hexagon(cpu_ver='v66', sim_args=None, hvx=128):
to prompt users if you change the hvx length, we should change the simulator here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually only setting the default HVX length. If --hvx_length
was specified in sim_args, it would be processed in
Configure` below, resetting the HVX length to the new value.
I changed the processing of sim_args
to always add --hvx_length
that matches hvx
(it already printed a warning if both were given and didn't match). Now, configuring the default HVX length here is not needed, so I removed it.
|
||
std::shared_ptr<Device> Device::Global() { | ||
// Declare device constructors. | ||
#ifdef __ANDROID__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to support more Hexagon target in the future, we maybe have problem. For example, hexagon could run embed system of Ubuntu, which is official support of Hexagon SDK too. Then we can not use __ANDROID__
to distinguish target or simulator. One proposal is in our Hexagon.cmake, when we build for simulator, we define one macro like -D__HEXAGON_SIM__=1
to indicate we are running on simulator or like -D__HEXAGON_DEVICE__=1
to indicate we are running on real devices. This is one nit-pick comment, however, I wish we could consider it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably do that, but I'd prefer to do it in another commit.
|
||
When configuring TVM (cmake), set the following variables: | ||
``` | ||
USE_LLVM=llvm-config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need us to add one line of LLVM version requirement? If I remember correctly, older LLVM version (like 6.0 or before) has many bugs on Hexagon DSP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I'm not aware of any specific issues with older LLVMs for Hexagon, so I didn't know which version is the minimum. I used 7.0.0 as the minimum, based on your comment, but recommended using as recent version as possible.
LGTM except one last comment. @kparzysz-quic Could you fix the CI? |
I don't think that the CI failure has anything to do with this PR, there are other PRs that failed in the same way. I rebased it op top of the current master, maybe that will help... |
Example of two other PRs that fail in the same place: |
This is only the TVM runtime. The FastRPC libraries, simulator driver, etc. will be provided in subsequent commits.
Apparently things work with libstdc++.
@FrozenGene If you're happy with the code, could you approve? Your review is still showing as "requested changes". |
@kparzysz-quic Thanks for the great work. Looking forward other parts of Hexagon like IDL / codegen part and so on. Thanks @tmoreau89 for the code review! |
) * [RUNTIME] Initial implementation of Hexagon runtime support This is only the TVM runtime. The FastRPC libraries, simulator driver, etc. will be provided in subsequent commits. * Fix pylint complaints * Fix some more pylint complaints * Add link to the Hexagon SDK website * Extract VTCM marker into a common variable * Implement device->device memory copy * Disable unsigned PDs by default * Ensure that --hvx_length is present in sim_args if HVX is enabled * Remove the line about clang from README.md Apparently things work with libstdc++. * Mention to set USE_RPC=OFF when building libtvm_runtime.so for Hexagon * Remember to use codegen_hvx in validate_hvx_length * Add a line about minimum version of LLVM
) * [RUNTIME] Initial implementation of Hexagon runtime support This is only the TVM runtime. The FastRPC libraries, simulator driver, etc. will be provided in subsequent commits. * Fix pylint complaints * Fix some more pylint complaints * Add link to the Hexagon SDK website * Extract VTCM marker into a common variable * Implement device->device memory copy * Disable unsigned PDs by default * Ensure that --hvx_length is present in sim_args if HVX is enabled * Remove the line about clang from README.md Apparently things work with libstdc++. * Mention to set USE_RPC=OFF when building libtvm_runtime.so for Hexagon * Remember to use codegen_hvx in validate_hvx_length * Add a line about minimum version of LLVM
) * [RUNTIME] Initial implementation of Hexagon runtime support This is only the TVM runtime. The FastRPC libraries, simulator driver, etc. will be provided in subsequent commits. * Fix pylint complaints * Fix some more pylint complaints * Add link to the Hexagon SDK website * Extract VTCM marker into a common variable * Implement device->device memory copy * Disable unsigned PDs by default * Ensure that --hvx_length is present in sim_args if HVX is enabled * Remove the line about clang from README.md Apparently things work with libstdc++. * Mention to set USE_RPC=OFF when building libtvm_runtime.so for Hexagon * Remember to use codegen_hvx in validate_hvx_length * Add a line about minimum version of LLVM
…m_data:master to master * commit 'cd0d52daa6942bdafa9363ff6cfa3d25fcd5b8d6': (824 commits) [Intrinsic] Add log1p, ldexp, atan2, hypot, nextafter, copysign (apache#5312) [Rust][CI] Restore Rust CI (apache#5137) Remove PrimExpr from String (apache#5311) [Requantize] Cleanup and Optimize Lowering (apache#5286) [IR][TRANSFORM] Enable CopyOnWrite for passes. (apache#5309) [PYTORCH]Abs, Arange, Softplus ops (apache#5295) [LLVM] Fix generation of LLVM intrinsics (apache#5282) [BYOC] Add example of Composite + Annotate for DNNL fused op (apache#5272) [Frontend][TensorFlow]Improve TensorFlow Static Shape Tensor Array (apache#5243) [RUNTIME] Introduce RValue reference(move) support to TypedPackedFunc (apache#5271) [RELAY][FRONTEND][CAFFE2] add Mul and ConvTranspose operator (apache#5302) [BYOC] Refine AnnotateTarget and MergeCompilerRegion Passes (apache#5277) [CI] Fix the hexagon string (apache#5304) [Arith] linear system and equation solver (apache#5171) [PYTORCH]Repeat, Reciprocal & Reshape Op support (apache#5280) [FRONTEND][TENSORFLOW] Fix gather_nd indices (apache#5279) Update device_annotation.cc (apache#5291) [REFACTOR][IR] Move to runtime::String (apache#5276) [NDArray] Set shape_ in NDArray::FromDLPack (apache#5301) [RUNTIME] Initial implementation of Hexagon runtime support (apache#5252) ...
This is only the TVM runtime. The FastRPC libraries, simulator driver, etc. will be provided in subsequent commits.