Skip to content

Commit

Permalink
Fix apache#6954 uTVM, fix when building the runtime for native hardwa…
Browse files Browse the repository at this point in the history
…re (apache#6957)

* Fix apache#6954 which when building the runtime for native hardware fails
with -march= is missing.

This fix:
1) adds support for march
2) picks a senable setting for f746 discovery

There is an interesting downside to this fix involving scheduling that likely needs discussion.
In the microcontroller world we really should be setting ex: -march=armv7e-m depending on what
cortex-m is being used.

-mcpu isn't as important when it comes to a command line compiler.

Signed-off-by: Tom Gall <[email protected]>

* Fix apache#6954 which when building the runtime for native hardware fails
with -march= is missing.

This fix:
1) adds support for march
2) picks a senible setting for f746 discovery

There is an interesting downside to this fix involving scheduling that likely needs discussion.
In the microcontroller world we really should be setting ex: -march=armv7e-m depending on what
cortex-m is being used.

-mcpu isn't as important when it comes to a command line compiler.

Signed-off-by: Tom Gall <[email protected]>
  • Loading branch information
tom-gall authored Nov 24, 2020
1 parent 28b1577 commit 0c92772
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion python/tvm/micro/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ def _defaults_from_target(self, target):
opts = []
# TODO use march for arm(https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html)?
if target.attrs.get("mcpu"):
opts.append(f'-march={target.attrs["mcpu"]}')
opts.append(f'-mcpu={target.attrs["mcpu"]}')
if target.attrs.get("mfpu"):
opts.append(f'-mfpu={target.attrs["mfpu"]}')
if target.attrs.get("march"):
opts.append(f'-march={target.attrs["march"]}')

return opts

Expand Down
2 changes: 1 addition & 1 deletion python/tvm/target/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def micro(model="unknown", options=None):
"""
trans_table = {
"host": ["-mcpu=native"],
"stm32f746xx": ["-mcpu=cortex-m7"],
"stm32f746xx": ["-mcpu=cortex-m7", "-march=armv7e-m"],
}
opts = _merge_opts(
trans_table[model] + ["-runtime=c", "--system-lib", f"-model={model}"], options
Expand Down
1 change: 1 addition & 0 deletions src/target/target_kind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ TVM_REGISTER_TARGET_KIND("c", kDLCPU)
.add_attr_option<Bool>("system-lib")
.add_attr_option<String>("runtime")
.add_attr_option<String>("mcpu")
.add_attr_option<String>("march")
.set_default_keys({"cpu"});

TVM_REGISTER_TARGET_KIND("cuda", kDLGPU)
Expand Down

0 comments on commit 0c92772

Please sign in to comment.