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] Support fetching and building Hexagon runtime with external runtime sources #13138

Merged
merged 6 commits into from
Oct 20, 2022
Merged

[Hexagon] Support fetching and building Hexagon runtime with external runtime sources #13138

merged 6 commits into from
Oct 20, 2022

Conversation

csullivan
Copy link
Contributor

@csullivan csullivan commented Oct 19, 2022

It can be desirable to incorporate external source libraries for Hexagon which are maintained outside of upstream TVM. This PR enables the cmake tvm option USE_HEXAGON_EXTERNAL_LIBS which can point to an external git repo containing runtime sources in src/runtime/hexagon for compilation along with the Hexagon TVM runtime.

When a git repo url is used, a SHA is required to be specified as well. Any source controlled use of TVM for benchmarking should commit the SHA used for reproducibility in the respective benchmarking repository -- and explicitly not in TVM.

cc @kparzysz-quic @mehrdadh @adstraw @janetsc @supersat @nverke

@tvm-bot
Copy link
Collaborator

tvm-bot commented Oct 19, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@csullivan csullivan changed the title Support fetching and building Hexagon runtime with external runtime sources [Hexagon] Support fetching and building Hexagon runtime with external runtime sources Oct 19, 2022
@github-actions github-actions bot requested a review from mehrdadh October 19, 2022 19:07

# Include hexagon external library runtime sources
if(DEFINED USE_HEXAGON_EXTERNAL_LIBS)
if (EXISTS ${USE_HEXAGON_EXTERNAL_LIBS})
Copy link
Collaborator

@janetsc janetsc Oct 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here. If we get here, USE_HEXAGON_EXTERNAL_LIBS exists, yes? When would line 188 be false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should clear this up with a comment, thank you. EXISTS here is checking to see if USE_HEXAGON_EXTERNAL_LIBS is a path that is resolvable on the system. If it is a local path then it will use the path to the local install of external libs. EXISTS will return false when it's not a path, e.g. if it is a git url or malformed.

Copy link
Collaborator

@janetsc janetsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with a question and a comment

list(APPEND RUNTIME_HEXAGON_SRCS "${HEXAGON_EXTERNAL_RUNTIME_SRCS}")
set_source_files_properties(
"${HEXAGON_EXTERNAL_RUNTIME_SRCS}"
PROPERTIES COMPILE_FLAGS "-mhvx -mhmx"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these properties specific to the external private repro be define there, and this pulls them in from a known sub-location within an external repo? (So that each private repo could customize flags inside itself.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering the same also yesterday.

One option, that I personally prefer not to rely on, is to not allow external sources and require the external libs to fully manage their own build to object files which are linked in.

Another option that comes to mind would be to do a cmake include on a required hexagon_external.cmake in the external lib. I haven't explored the feasibility of this option but it could work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the good feedback, 18fe01c takes your suggestion of optionally including an external library defined cmake config file which defines these compiler flags. The risk we run is keeping these synchronized across repos, but as long as the footprint stays microscopic (ie just a single shared variable name) it should be manageable.

by defining HEXAGON_EXTERNAL_LIBS_COMPILE_FLAGS in a top level
HexagonExternalCompileFlags.cmake config file which is
conditionally included if it exists.
@mehrdadh mehrdadh self-assigned this Oct 20, 2022
Copy link
Member

@mehrdadh mehrdadh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mehrdadh mehrdadh merged commit 1dbd1fa into apache:main Oct 20, 2022
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 10, 2022
… runtime sources (apache#13138)

* Support fetching and building Hexagon runtime with external runtime sources.

* Ensure compiler flags are set to cover potential uses of Hexagon hardware features used by external libs.

* Add libinfo entries for USE_HEXAGON_EXTERNAL_LIBS.

* Better document options for external libs.

* Allow external hexagon libs to specify their own compile flags
by defining HEXAGON_EXTERNAL_LIBS_COMPILE_FLAGS in a top level
HexagonExternalCompileFlags.cmake config file which is
conditionally included if it exists.

* Check for USE_HEXAGON_EXTERNAL_LIBS triviality.
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
… runtime sources (apache#13138)

* Support fetching and building Hexagon runtime with external runtime sources.

* Ensure compiler flags are set to cover potential uses of Hexagon hardware features used by external libs.

* Add libinfo entries for USE_HEXAGON_EXTERNAL_LIBS.

* Better document options for external libs.

* Allow external hexagon libs to specify their own compile flags
by defining HEXAGON_EXTERNAL_LIBS_COMPILE_FLAGS in a top level
HexagonExternalCompileFlags.cmake config file which is
conditionally included if it exists.

* Check for USE_HEXAGON_EXTERNAL_LIBS triviality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants