You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "lhutton1 (via GitHub)" <gi...@apache.org> on 2024/02/02 17:25:39 UTC
[PR] [Target] Automatically detect system triple when not specified by the user [tvm]
lhutton1 opened a new pull request, #16513:
URL: https://github.com/apache/tvm/pull/16513
Currently, when a default compile target such as llvm is specified, it implies llvm -keys=cpu which tends to imply x86 related components being used during compilation e.g. the schedules registered in TOPI. This can be confusing for a user when compiling on other architectures, especially when other tools such as llc infer the default target based on the host.
When the target kind is llvm, this commit uses the "target.llvm_get_system_triple" functionality to automatically detect mtriple when one has not been provided in the target string. The target will be updated to one that uses the mtriple of the host: llvm -> llvm -mtriple=<system-triple>. When compiling on Arm(R)-based targets, this has the added benefit of automatically introducing -keys=arm_cpu to the target improving the schedule selection.
Lots of tests are currently using targets such as llvm or similar which has resulted in a lack of coverage of other targets such as arm_cpu. As part of this commit, failing test cases which have simple / obvious issues have been fixed. Others that likely need more thought have been skipped. In doing so, it reduces the number of modifications and simplifies the review for this change.
Note: This PR is marked as draft while checking and fixing other failures in CI. Tests marked as skipped containing "<Issue link>" in the reason will have issues added and the related reason will be updated when CI is green.
This commit is a follow up of the changes made in: #14981
Co-authored-by: Jack Frankland <ja...@arm.com>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "cbalint13 (via GitHub)" <gi...@apache.org>.
cbalint13 commented on code in PR #16513:
URL: https://github.com/apache/tvm/pull/16513#discussion_r1483200887
##########
src/target/parsers/cpu.cc:
##########
@@ -28,7 +28,24 @@ namespace target {
namespace parsers {
namespace cpu {
+Optional<String> DetectSystemTriple() {
+ auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
+ if (pf->defined()) {
+ return (*pf)();
+ }
+ return {};
+}
+
TargetJSON ParseTarget(TargetJSON target) {
+ String kind = Downcast<String>(target.Get("kind"));
+ Optional<String> mtriple = Downcast<Optional<String>>(target.Get("mtriple"));
+ Optional<String> mcpu = Downcast<Optional<String>>(target.Get("mcpu"));
+
+ // Try to fill in the blanks by detecting target information from the system
+ if (kind == "llvm" && !mtriple.defined() && !mcpu.defined()) {
+ target.Set("mtriple", DetectSystemTriple().value_or(""));
+ }
Review Comment:
Uh oh, yes.
Well this is it, the best is to put this at the creation of host/target (runs once), globally for all CPU targets.
I will try take a little time to add it there in a separate PR, for now this can be removed from here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "cbalint13 (via GitHub)" <gi...@apache.org>.
cbalint13 commented on code in PR #16513:
URL: https://github.com/apache/tvm/pull/16513#discussion_r1479502313
##########
src/target/parsers/cpu.cc:
##########
@@ -28,7 +28,24 @@ namespace target {
namespace parsers {
namespace cpu {
+Optional<String> DetectSystemTriple() {
+ auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
+ if (pf->defined()) {
+ return (*pf)();
+ }
+ return {};
+}
+
TargetJSON ParseTarget(TargetJSON target) {
+ String kind = Downcast<String>(target.Get("kind"));
+ Optional<String> mtriple = Downcast<Optional<String>>(target.Get("mtriple"));
+ Optional<String> mcpu = Downcast<Optional<String>>(target.Get("mcpu"));
+
+ // Try to fill in the blanks by detecting target information from the system
+ if (kind == "llvm" && !mtriple.defined() && !mcpu.defined()) {
+ target.Set("mtriple", DetectSystemTriple().value_or(""));
+ }
Review Comment:
One small nit, in this case would be nice to leave a message for the user about facts:
* explicit mtriple and/or explict mcpu wasnt provided
* backend here detected an X mtriple and/or and Y mcpu
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "lhutton1 (via GitHub)" <gi...@apache.org>.
lhutton1 commented on PR #16513:
URL: https://github.com/apache/tvm/pull/16513#issuecomment-1929091896
cc @ekalda @neildhickey @cbalint13 @kparzysz-quic would be good to hear your thoughts before I proceed with creating the issues for the failing tests (due to test coverage in CI increasing).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "ekalda (via GitHub)" <gi...@apache.org>.
ekalda commented on PR #16513:
URL: https://github.com/apache/tvm/pull/16513#issuecomment-1997008071
Thanks @lhutton1 @FranklandJack @cbalint13!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "lhutton1 (via GitHub)" <gi...@apache.org>.
lhutton1 commented on code in PR #16513:
URL: https://github.com/apache/tvm/pull/16513#discussion_r1479663190
##########
src/target/parsers/cpu.cc:
##########
@@ -28,7 +28,24 @@ namespace target {
namespace parsers {
namespace cpu {
+Optional<String> DetectSystemTriple() {
+ auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
+ if (pf->defined()) {
+ return (*pf)();
+ }
+ return {};
+}
+
TargetJSON ParseTarget(TargetJSON target) {
+ String kind = Downcast<String>(target.Get("kind"));
+ Optional<String> mtriple = Downcast<Optional<String>>(target.Get("mtriple"));
+ Optional<String> mcpu = Downcast<Optional<String>>(target.Get("mcpu"));
+
+ // Try to fill in the blanks by detecting target information from the system
+ if (kind == "llvm" && !mtriple.defined() && !mcpu.defined()) {
+ target.Set("mtriple", DetectSystemTriple().value_or(""));
+ }
Review Comment:
Just added, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "lhutton1 (via GitHub)" <gi...@apache.org>.
lhutton1 commented on code in PR #16513:
URL: https://github.com/apache/tvm/pull/16513#discussion_r1483164278
##########
src/target/parsers/cpu.cc:
##########
@@ -28,7 +28,24 @@ namespace target {
namespace parsers {
namespace cpu {
+Optional<String> DetectSystemTriple() {
+ auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
+ if (pf->defined()) {
+ return (*pf)();
+ }
+ return {};
+}
+
TargetJSON ParseTarget(TargetJSON target) {
+ String kind = Downcast<String>(target.Get("kind"));
+ Optional<String> mtriple = Downcast<Optional<String>>(target.Get("mtriple"));
+ Optional<String> mcpu = Downcast<Optional<String>>(target.Get("mcpu"));
+
+ // Try to fill in the blanks by detecting target information from the system
+ if (kind == "llvm" && !mtriple.defined() && !mcpu.defined()) {
+ target.Set("mtriple", DetectSystemTriple().value_or(""));
+ }
Review Comment:
After looking through the CI logs, I'm wondering if emitting a warning message is not the best idea here - there are way too many warnings. Perhaps it can be implemented in some driver of tvm instead, e.g. TVMC, and emitted once?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "ekalda (via GitHub)" <gi...@apache.org>.
ekalda commented on PR #16513:
URL: https://github.com/apache/tvm/pull/16513#issuecomment-1994744783
@tvm-bot rerun
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Target] Automatically detect system triple when not specified by the user [tvm]
Posted by "ekalda (via GitHub)" <gi...@apache.org>.
ekalda merged PR #16513:
URL: https://github.com/apache/tvm/pull/16513
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org