Skip to content

Support --march=native #3134

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

Merged
merged 6 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ add_onnx_mlir_library(OMCompilerOptions
LINK_LIBS PUBLIC
MLIRIR
OMAccelerator
LLVMTargetParser
)


Expand Down
7 changes: 6 additions & 1 deletion src/Compiler/CompilerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/Support/Debug.h"
#include "llvm/TargetParser/Host.h"

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

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

if (march == "z17")
march = "arch15";

if (march == "native")
march = std::string(llvm::sys::getHostCPUName());
}

} // namespace onnx_mlir
Loading