Skip to content
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

Use ofast-flag rather than fast-math for mkFit #124

Merged
merged 3 commits into from
May 4, 2023
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
2 changes: 1 addition & 1 deletion RecoTracker/MkFitCore/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<use name="rootsmatrix"/>
<use name="json"/>
<use name="tbb"/>
<use name="ofast-flag"/>
<flags CXXFLAGS="-fopenmp-simd"/>
<flags CXXFLAGS="-ffast-math"/>
<flags ADD_SUBDIR="1"/>
<export>
<lib name="RecoTrackerMkFitCore"/>
Expand Down
8 changes: 6 additions & 2 deletions RecoTracker/MkFitCore/standalone/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ else
endif

ifeq ($(CXX), g++)
CXXFLAGS += -std=c++1z -ftree-vectorize -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -Wstrict-overflow -Werror=array-bounds -Werror=format-contains-nul -Werror=type-limits -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 -Xassembler --compress-debug-sections -felide-constructors -fmessage-length=0 -Wall -Wno-non-template-friend -Wno-long-long -Wreturn-type -Wunused -Wparentheses -Wno-deprecated -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-dtor -Wstrict-aliasing -Werror=narrowing -Werror=unused-but-set-variable -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Werror=return-local-addr -Wnon-virtual-dtor -Werror=switch -fdiagnostics-show-option -Wno-unused-local-typedefs -Wno-attributes -Wno-psabi
CXXFLAGS += -fdiagnostics-color=auto -fdiagnostics-show-option -pthread -pipe -fopenmp-simd
# For gcc, compile with flags approximating "scram build echo_CXXFLAGS" in a CMSSW env
CXXFLAGS += -pthread -pipe -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -std=c++17 -ftree-vectorize -Werror=array-bounds -Werror=format-contains-nul -Werror=type-limits -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 -Xassembler --compress-debug-sections -fuse-ld=bfd -msse3 -felide-constructors -fmessage-length=0 -Wall -Wno-non-template-friend -Wno-long-long -Wreturn-type -Wextra -Wpessimizing-move -Wclass-memaccess -Wno-cast-function-type -Wno-unused-but-set-parameter -Wno-ignored-qualifiers -Wno-deprecated-copy -Wno-unused-parameter -Wunused -Wparentheses -Wno-deprecated -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=unused-label -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-dtor -Werror=strict-aliasing -Werror=narrowing -Werror=unused-but-set-variable -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Werror=return-local-addr -Wnon-virtual-dtor -Werror=switch -fdiagnostics-show-option -Wno-unused-local-typedefs -Wno-attributes -Wno-psabi
CXXFLAGS += -fdiagnostics-color=auto -fdiagnostics-show-option -fopenmp-simd
# Add flags to enable auto-vectorization of sin/cos with libmvec (glibc >= 2.22)
# Disable reciprocal math for Intel/AMD consistency, see cms-sw/cmsdist#8280
CXXFLAGS += -Ofast -fno-reciprocal-math -mrecip=none
Copy link

Choose a reason for hiding this comment

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

is -fno-math-errno still needed?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not 100% sure. IIUC, @srlantz tested the additional flags on top of the existing ones, that's why I did not removed it. However, can be removed if unnecessary.

Copy link

Choose a reason for hiding this comment

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

also , -ftree-vectorize is a part of -O2, apparently (which is in turn a part of -O3, and that is in -Ofast)

or is the point that redundant flags are OK?

Copy link
Author

Choose a reason for hiding this comment

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

I let @srlantz comment about it: to me, we can clean the unnecessary flags; however, I thought I would be as close as possible to what I understood was tested as a start.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general, not setting errno is a requirement for vectorizing transcendentals, so it’s probably worth specifying even if it’s subsumed by other optimization flags

Copy link
Collaborator

Choose a reason for hiding this comment

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

The Makefile.config gcc flags were copied from CMSSW at some point in the distant past, it would be completely reasonable to update to whatever the defaults are today. (I think there was one flag I had to omit back in the day, but that must have been resolved getting mkFit into CMSSW.)

Copy link
Author

Choose a reason for hiding this comment

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

I pushed cb2e7d6, which updates to the most recent gcc flags, with the exception of -O2, since we already invoke -O3. Does this look OK?
I checked, and standalone mkFit compiles.

Copy link

Choose a reason for hiding this comment

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

Looks good to me. I agree with @dan131riley that we should take the opportunity to update these flags. Thanks @mmasciov !

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! Then, if OK with everyone, I will open a PR to cms-sw/cmssw

Copy link
Author

Choose a reason for hiding this comment

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

Done: cms-sw#41374

endif

# Try to find a new enough TBB
Expand Down