Skip to content

Add --enable-unsafe-fp-math flag when -O3 and NNPA is used #2963

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 2 commits into from
Oct 2, 2024
Merged
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
7 changes: 7 additions & 0 deletions src/Compiler/CompilerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,13 @@ void initCompilerConfig() {
addCompilerConfig(CCM_SHARED_LIB_DEPS, extraLibs);
addCompilerConfig(CCM_SHARED_LIB_PATH_DEPS, extraLibPaths);
}

// Enable aggressive optimization for NNPA with -O3
if (OptimizationLevel == OptLevel::O3 &&
getTargetAccel().find("NNPA") != std::string::npos &&
getLLVMOption().find("enable-unsafe-fp-math") == std::string::npos) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, the idea is that you just check if that opt is already there. If it's there, either its true and there is no need to add it again, or false and then we don't add it also. Clever.

setLLVMOption(getLLVMOption() + " --enable-unsafe-fp-math");
}
}

} // namespace onnx_mlir
Loading