Skip to content

Support for arch native on mac #3153

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
Show file tree
Hide file tree
Changes from 2 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
12 changes: 8 additions & 4 deletions src/Compiler/CompilerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,10 @@ std::string getTargetArchOption(bool forLLVMToolchain) {
int64_t zArchNum = getZArchNum(march, mcpu);
if (zArchNum != -1)
return "--march=systemz";
// On mac, llc --version seem to want aarch64 or arm64.
if (march == "apple-m1" || march == "apple-m2" || march == "apple-m3" ||
march == "apple-m4")
return "--march=arm64";
}
return (march != "") ? "--march=" + march : "";
}
Expand Down Expand Up @@ -1413,11 +1417,11 @@ void initCompilerConfig() {
setLLVMOption(getLLVMOption() + " --enable-unsafe-fp-math");
}

if (march == "z17")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zXX or archYY are equally recognized, so no need to convert the one into the other

march = "arch15";

if (march == "native")
if (march == "native") {
march = std::string(llvm::sys::getHostCPUName());
if (VerboseOutput)
llvm::outs() << "Native machine set as \"" << march << "\"\n";
}
}

} // namespace onnx_mlir
6 changes: 4 additions & 2 deletions src/Dialect/Mlir/VectorMachineSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ namespace onnx_mlir {
else
// Default seems to be SSE
globalVectorMachineSupport = new SSE42x86VectorMachineSupport();
// Arm uses arch
} else if (arch.compare("aarch64") == 0 || arch.compare("arm64") == 0) {
// Arm uses arch, and arch=native returns apple-mXXX.
} else if (arch.compare("aarch64") == 0 || arch.compare("arm64") == 0 ||
arch.compare("apple-m1") == 0 || arch.compare("apple-m2") == 0 ||
arch.compare("apple-m3") == 0 || arch.compare("apple-m4") == 0) {
// Arm arch
globalVectorMachineSupport = new NeonVectorMachineSupport();
} else {
Expand Down
Loading