-
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
[µTVM] Use standalone_crt build tree for all µTVM builds #7333
Conversation
Hi @areusch, This is great! |
@manupa-arm yeah correct--it revises all functions in |
* Make build/standalone_crt available to CI unit tests. * We could do this with stash but it's complex because we would need to use wildcards. Instead, rebuild standalone_crt source tree before testing.
* Make build/standalone_crt available to CI unit tests. * We could do this with stash but it's complex because we would need to use wildcards. Instead, rebuild standalone_crt source tree before testing.
* Make build/standalone_crt available to CI unit tests. * We could do this with stash but it's complex because we would need to use wildcards. Instead, rebuild standalone_crt source tree before testing.
@tqchen @manupa-arm @u99127 @gromero @tom-gall looks like this is ready for review |
@areusch Hi Andrew. The change looks good (I'll differ the review of |
@gromero thanks for the review. unfortunately if you force-push (I.e. rebase) it loses the context around the previous comments, and I like that less :/. for line length, we're at 100 char, and pylint's enforcing that, so i'm keeping to that 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.
Broadly looks fine. few clarifications and concerns.
@@ -55,15 +57,62 @@ def path(self): | |||
CRT_RUNTIME_LIB_NAMES = ["utvm_rpc_server", "utvm_rpc_common", "common"] | |||
|
|||
|
|||
TVM_ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) | |||
STANDALONE_CRT_DIR = None |
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.
Im not too sure whether we need this ?
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.
do you mean that it's fine to just do the search every 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.
oh you want to cache/memoize the function ... if thats the case, you might want to consider options to do that such using the memoize decorator, functools caches or maybe we can move variable inside of the function as it is not used by anyother ?
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, though functools.cache
is new in 3.9 and lru_cache
seems a bit complex. i think this way might almost be easier to debug. is there a different stdlib thing i'm missing?
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.
Hmm there is one other option you might want to consider -- you make it attr of the function -- thats python's way of having static variables. Anyway, Im not very fussed about 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.
ok--I may opt to leave this as it's passing CI and there's a bunch of other pressing work.
The path to the standalone_crt | ||
""" | ||
global STANDALONE_CRT_DIR | ||
if STANDALONE_CRT_DIR is None: |
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.
Again on the same question as above, however this kind of makes me think do we need something like an environment variable ? Maybe PassContext is a better option for that ? What do you think ?
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 think that ultimately these are going to become data dependencies of the tlcpack wheel and we don't have a standard facility to figure out where the data deps go. I think we should make such a thing in both Python and CMake and then it would reduce this function to: if not isdir(f'{data_dir}/standalone_crt'): raise CrtNotFoundError()
.
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.
Ack
f"{TVM_ROOT_DIR}/include", | ||
f"{TVM_ROOT_DIR}/3rdparty/dlpack/include", | ||
f"{TVM_ROOT_DIR}/3rdparty/libcrc/include", | ||
f"{TVM_ROOT_DIR}/3rdparty/dmlc-core/include", |
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.
[Clarification] do we not need them anymore or do they go inside build/crt/include ?
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.
they go in build/standalone_crt/include according to cmake/modules/StandaloneCrt.cmake.
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.
Alright!
_CRT_GENERATED_LIB_OPTIONS["cflags"].append("-Wno-unused-variable") | ||
_CRT_GENERATED_LIB_OPTIONS["ccflags"].append("-Wno-unused-variable") | ||
lib_opts = _build_default_compiler_options(standalone_crt_dir) | ||
lib_opts["cflags"] = ["-Wno-error=incompatible-pointer-types"] |
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.
[Clarification] why is this needed suddenly ?
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 think it's on line 110 at main--I don't think it's a change 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.
Oh sorry I missed that!
@areusch yeah.. I forgot about the "constraint" on push -f. Maybe the only thing we could do is to try to avoid merging in the middle of the incremental pushes (pushes due to the review process)? On the other hand that amounts to not doing a rebase on the top of the most fresh code in |
@gromero easiest way to patch given merges might be something like:
I think the rest is just limitations of this code-review system. I generally try to push -f until there's a comment on the thread |
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.
@manupa-arm thanks for the review!
@@ -55,15 +57,62 @@ def path(self): | |||
CRT_RUNTIME_LIB_NAMES = ["utvm_rpc_server", "utvm_rpc_common", "common"] | |||
|
|||
|
|||
TVM_ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) | |||
STANDALONE_CRT_DIR = None |
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.
do you mean that it's fine to just do the search every time?
The path to the standalone_crt | ||
""" | ||
global STANDALONE_CRT_DIR | ||
if STANDALONE_CRT_DIR is None: |
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 think that ultimately these are going to become data dependencies of the tlcpack wheel and we don't have a standard facility to figure out where the data deps go. I think we should make such a thing in both Python and CMake and then it would reduce this function to: if not isdir(f'{data_dir}/standalone_crt'): raise CrtNotFoundError()
.
f"{TVM_ROOT_DIR}/include", | ||
f"{TVM_ROOT_DIR}/3rdparty/dlpack/include", | ||
f"{TVM_ROOT_DIR}/3rdparty/libcrc/include", | ||
f"{TVM_ROOT_DIR}/3rdparty/dmlc-core/include", |
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.
they go in build/standalone_crt/include according to cmake/modules/StandaloneCrt.cmake.
_CRT_GENERATED_LIB_OPTIONS["cflags"].append("-Wno-unused-variable") | ||
_CRT_GENERATED_LIB_OPTIONS["ccflags"].append("-Wno-unused-variable") | ||
lib_opts = _build_default_compiler_options(standalone_crt_dir) | ||
lib_opts["cflags"] = ["-Wno-error=incompatible-pointer-types"] |
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 think it's on line 110 at main--I don't think it's a change here?
@areusch I see. I imagine that's the flow the committer will follow when squashing for the final commit to get merged into Now, I've just made a quick test and I see that the review comments (even the comments related to a line of code) haven't disappeared after a
The forced push and the new incremental change (plus the changes merged / pushed into Feel free to ping for a few tests if you want :)
Yeah, that's what I do too. |
@gromero yes, I think that's roughly what GH does when someone hits merge. the review comments do stick around, but the context is usually obliterated, which is usually pretty crucial to understanding what they meant. maybe see if the old sha is still available after a few hours--GH may do a cleanup task internally |
Got it 👍
@areusch Amazing, indeed, after some time, when clicking on "View Changes" related to a commit that was rebased (and git pushed -f) I get:
The best part is "Sometimes commits can disappear... ". OK, I give up :P |
@gromero @manupa-arm can you explicit ack if you're ok with this change? https://tvm.apache.org/docs/contribute/code_review.html#approve-and-request-changes-explicitly |
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.
LGTM
@tmoreau89 @tqchen to merge |
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.
LGTM
Thank you @areusch @gromero @manupa-arm - the PR has been merged |
* Build microTVM using standalone_crt in build tree. * black format * pylint * try stashing entire standalone_crt in hopes it will not upset jenkins * Put standalone_crt in correct Jenkinsfile stash bundle * include build prefix * switch to python script for expanding globs * revert attempt to use globs in pack_libs, switch to building standalone_crt * properly revert pack_lib changes * fix typo * retrigger CI * revert pyproject.toml * update Jenkinsfile approach to use task_ci_setup.sh
* Build microTVM using standalone_crt in build tree. * black format * pylint * try stashing entire standalone_crt in hopes it will not upset jenkins * Put standalone_crt in correct Jenkinsfile stash bundle * include build prefix * switch to python script for expanding globs * revert attempt to use globs in pack_libs, switch to building standalone_crt * properly revert pack_lib changes * fix typo * retrigger CI * revert pyproject.toml * update Jenkinsfile approach to use task_ci_setup.sh
Right now due to historical reasons we sometimes build the CRT from build/standalone_crt and other times from src/runtime/crt. This PR consolidates building to always be from
build/standalone_crt
and updates several path computations to use that. Ultimately we'll need this if we expect microTVM to be useful when TVM has beenpip install
ed rather than just built from source.This is also helpful for autotuning, as we expect the autotvm runner to use
standalone_crt
to build the project. This PR also changes the default compiler options to reference the standalone_crt directory.Finally, to properly separate the host main() and crt_config.h from the remaining reusable CRT libs, places these in a new directory
standalone_crt/template
along with the template crt_config.h.