Skip to content

Commit 07e645b

Browse files
authored
Support --march=native (#3134)
* changes Signed-off-by: Chen Tong <[email protected]> * format Signed-off-by: Chen Tong <[email protected]> * linkage Signed-off-by: Chen Tong <[email protected]> * lib Signed-off-by: Chen Tong <[email protected]> --------- Signed-off-by: Chen Tong <[email protected]>
1 parent cd1b96d commit 07e645b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Compiler/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ add_onnx_mlir_library(OMCompilerOptions
5656
LINK_LIBS PUBLIC
5757
MLIRIR
5858
OMAccelerator
59+
LLVMTargetParser
5960
)
6061

6162

src/Compiler/CompilerOptions.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#include "llvm/Support/Debug.h"
16+
#include "llvm/TargetParser/Host.h"
1617

1718
#include "ExternalUtil.hpp"
1819
#include "onnx-mlir/Compiler/OMCompilerRuntimeTypes.h"
@@ -174,7 +175,8 @@ static llvm::cl::opt<float, true> nnpaEpsilonOpt("nnpa-epsilon",
174175
llvm::cl::cat(OnnxMlirCommonOptions), llvm::cl::init(1e-5));
175176

176177
static llvm::cl::opt<std::string, true> marchOpt("march",
177-
llvm::cl::desc("Target architecture to generate code for."),
178+
llvm::cl::desc("Target architecture to generate code for.\n"
179+
"--march=native will use the host's archituecture"),
178180
llvm::cl::value_desc("Target a specific architecture type"),
179181
llvm::cl::location(march), llvm::cl::cat(OnnxMlirCommonOptions),
180182
llvm::cl::ValueRequired);
@@ -1413,6 +1415,9 @@ void initCompilerConfig() {
14131415

14141416
if (march == "z17")
14151417
march = "arch15";
1418+
1419+
if (march == "native")
1420+
march = std::string(llvm::sys::getHostCPUName());
14161421
}
14171422

14181423
} // namespace onnx_mlir

0 commit comments

Comments
 (0)