Skip to content

Commit 7a621c3

Browse files
chentong319tungld
authored andcommitted
Support --march=native (onnx#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 6faf742 commit 7a621c3

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"
@@ -173,7 +174,8 @@ static llvm::cl::opt<float, true> nnpaEpsilonOpt("nnpa-epsilon",
173174
llvm::cl::cat(OnnxMlirCommonOptions), llvm::cl::init(1e-5));
174175

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

14051407
if (march == "z17")
14061408
march = "arch15";
1409+
1410+
if (march == "native")
1411+
march = std::string(llvm::sys::getHostCPUName());
14071412
}
14081413

14091414
} // namespace onnx_mlir

0 commit comments

Comments
 (0)