Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-17 22:59:08

0001 ################################################################
0002 # Build notes
0003 ################################################################
0004 
0005 # Requires a recent gcc, e.g.:
0006 #   . /opt/rh/devtoolset-2/enable
0007 # This is also needed for icc as it uses gcc headers.
0008 
0009 # To build mkFit -- Matriplex Kalman Fit:
0010 # - cd mkFit; make (or make -C mkFit).
0011 
0012 
0013 ################################################################
0014 # Configuration section
0015 ################################################################
0016 
0017 # -1. What to build - default is AVX
0018 # Define to build for AVX_512
0019 #AVX_512 := 1
0020 # Define to build for AVX2
0021 #AVX2    := 1
0022 # Define to build for SSE3
0023 #SSE3 := 1
0024 
0025 # 0. Use gcc-5 from MacPorts on OSX
0026 # OSXGCC5    := 1
0027 # Use clang from MacPorts on OSX
0028 # OSXMPCLANG   := 1
0029 
0030 # 1. Use ROOT or not
0031 # Comment out to disable root ("1" is not relevant)
0032 #WITH_ROOT := 1
0033 # Comment out to also enable RootEve visualization through Shell
0034 #WITH_REVE := 1
0035 
0036 # 2. Use gcc (clang by default on mac) or icc
0037 # Comment out to force using standard c++.
0038 ifdef INTEL_LICENSE_FILE
0039   # Define ICC to make it easier to switch to icpc
0040   ICC := icc
0041   CXX := ${ICC}
0042 else ifdef OSXGCC5
0043   CXX := c++-mp-5
0044   TBB_PREFIX := /opt/local
0045 else ifdef OSXMPCLANG
0046   CXX := ${OSXMPCLANG} -Wall -Wno-unknown-pragmas -Wno-missing-braces
0047   TBB_PREFIX := /opt/local
0048 endif
0049 
0050 # 3. Optimization
0051 # -O3 implies vectorization and simd (but not AVX)
0052 # But use -Ofast rather than -O3 so gcc can auto-vectorize sin/cos with libmvec (glibc >= 2.22)
0053 OPT := -g -Ofast
0054 
0055 # 4. Vectorization settings
0056 # SRL 2024-10-15: Updated to use -march flags available in GCC 11+, Clang 12+
0057 ifdef AVX_512
0058 VEC_GCC  := -march=x86-64-v4
0059 #VEC_GCC  := -march=native # -fopt-info-vec -mavx512f -mavx512cd
0060 VEC_ICC  := -xHost -qopt-zmm-usage=high # -xcore-avx512
0061 else ifdef AVX2
0062 VEC_GCC  := -march=x86-64-v3
0063 #VEC_GCC  := -mavx2 -mfma
0064 VEC_ICC  := -mavx2 -mfma
0065 else ifdef SSE3
0066 VEC_GCC  := -march=x86-64-v2
0067 #VEC_GCC  := -msse3
0068 # SRL 2024-10-05: v2 is latest CMSSW default, includes SSE4, SSSE3, not AVX
0069 VEC_ICC  := -msse3
0070 else
0071 # SRL 2024-10-05: Default to AVX - Intel Sandy Bridge, Ivy Bridge (2011-2015)
0072 VEC_GCC  := -mavx # -fopt-info-vec-all
0073 VEC_ICC  := -mavx
0074 endif
0075 
0076 # 5. Matriplex intrinsics, vtune
0077 # Comment-out to enable intrinsics (supported for AVX512, AVX2 and AVX)
0078 USE_INTRINSICS := -DMPLEX_USE_INTRINSICS
0079 # To enforce given vector size (does not work with intrinsics!)
0080 # When setting MPT_SIZE to 1, -Werror=array-bounds might need to be removed from CXXFLAGS below (gcc-13?).
0081 #USE_INTRINSICS := -DMPT_SIZE=1
0082 USE_VTUNE_NOTIFY := 1
0083 
0084 # 6. Intel Threading Building Blocks.  With icc uses system
0085 # TBB, otherwise requires a local installation, and paths will
0086 # have to be adjusted.
0087 WITH_TBB := 1
0088 
0089 # 7. Use inward fit in Conformal fit
0090 #INWARD_FIT := -DINWARDFIT
0091 
0092 ################################################################
0093 # Derived settings
0094 ################################################################
0095 
0096 CPPFLAGS := ${USE_INTRINSICS} -DMKFIT_STANDALONE
0097 CXXFLAGS := -fPIC ${OPT} ${OSX_CXXFLAGS}
0098 
0099 LDFLAGS_HOST := 
0100 
0101 CPPFLAGS += ${INWARD_FIT}
0102 
0103 # Downgrade tbb::parallel_for to plainer loops
0104 # CPPFLAGS += -DTBB_DISABLE
0105 
0106 # Dump hit selection window tuples
0107 # CPPFLAGS += -DDUMPHITWINDOW
0108 # The new dumpers
0109 ifdef WITH_ROOT
0110   # CPPFLAGS += -DRNT_DUMP_MkF_SelHitIdcs
0111 endif
0112 
0113 ifdef USE_VTUNE_NOTIFY
0114   ifdef VTUNE_AMPLIFIER_XE_2017_DIR
0115     CPPFLAGS     += -I$(VTUNE_AMPLIFIER_XE_2017_DIR)/include -DUSE_VTUNE_PAUSE
0116     LDFLAGS_HOST += -L$(VTUNE_AMPLIFIER_XE_2017_DIR)/lib64 -littnotify
0117   endif
0118 endif
0119 
0120 ifeq (${CXX}, ${ICC})
0121   VEC_HOST := ${VEC_ICC}
0122   CXXFLAGS += -qopt-report=5 -qopenmp-simd -qopt-report-phase=all
0123 else
0124   VEC_HOST := ${VEC_GCC}
0125 endif
0126 
0127 ifeq ($(CXX), g++)
0128   # For gcc, compile with flags approximating "scram build echo_CXXFLAGS" in a CMSSW env
0129   # SRL 2024-10-05: Update to latest CMSSW flags, some get set elsewere...
0130   # -march=x86-64-v2 is enabled above, if so configured (i.e., SSE3=1, not avx)
0131   # -Ofast is specified above in section 3, it includes -O3
0132   # -std=c++20 below (ROOT 6.30.09 needs it too, formerly it was c++1z below)
0133   # MT 2023-12-11: Had to remove -Werror=missing-braces ... triggered by RNTuple/REntry
0134   CXXFLAGS += -pthread -pipe -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -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 -Wno-error=array-bounds -Warray-bounds -fuse-ld=bfd -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-unused-parameter -Wunused -Wparentheses -Werror=return-type -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
0135 endif
0136 
0137 # SRL 2024-10-05: Enable the flags below for gcc plus Clang-like compilers
0138 # (including icpx); the flags above either affect warnings (-W), or have
0139 # effects that don't matter or are invalid for Clang.
0140 # Note, -Ofast already includes -mno-math-errno and -ftree-vectorize (via -O3).
0141 ifneq ($(CXX),icc)
0142   CXXFLAGS += -fdiagnostics-color=auto -fdiagnostics-show-option -fopenmp-simd
0143   # Disable reciprocal math for Intel/AMD consistency, see cms-sw/cmsdist#8280
0144   CXXFLAGS += -fno-reciprocal-math -mrecip=none
0145 endif
0146 
0147 # Try to find a new enough TBB
0148 ifneq ($(CXX),icc)
0149   ifndef TBB_PREFIX
0150     ifdef CMSSW_BASE
0151       CPPFLAGS += -I$(shell cd $$CMSSW_BASE && scram tool tag tbb INCLUDE)
0152       LDFLAGS_HOST += -L$(shell cd $$CMSSW_BASE && scram tool tag tbb LIBDIR)
0153     else ifdef TBB_GCC
0154       TBB_PREFIX = $(TBB_GCC)
0155     endif
0156   endif
0157 endif
0158 
0159 ifdef WITH_TBB
0160   # icc finds tbb in its own installation, but allow overriding in case it doesn't
0161   ifdef TBB_PREFIX
0162     CPPFLAGS += -I${TBB_PREFIX}/include
0163     LDFLAGS  += -L${TBB_PREFIX}/lib -Wl,-rpath,${TBB_PREFIX}/lib 
0164   endif
0165   CPPFLAGS += -DTBB
0166   LDFLAGS  += -ltbb
0167 endif
0168 
0169 CPPFLAGS_NO_ROOT := ${CPPFLAGS}
0170 LDFLAGS_NO_ROOT  := ${LDFLAGS}
0171 
0172 ifdef WITH_ROOT
0173   CPPFLAGS += -DWITH_ROOT
0174   ifdef WITH_REVE
0175         CPPFLAGS += -DWITH_REVE
0176   endif
0177   CPPFLAGS += -I$(shell root-config --incdir)
0178   LDFLAGS  += $(shell root-config --libs)
0179 endif
0180 
0181 ifdef DEBUG
0182   CPPFLAGS += -DDEBUG
0183 endif
0184 
0185 # Set C++ standard version at the very end, as other flags (i.e. ROOT) can override our choice for which version of c++
0186 CXXFLAGS += -std=c++20
0187 
0188 ################################################################
0189 # Dependency generation
0190 ################################################################
0191 
0192 DEPEND_TGTS = -MQ '$(patsubst %.d,%.o,$@)'
0193 
0194 # With icc use gcc for dependency generation. Check if this is still true with icc-16.
0195 # MT-2016-08-30: icc 16.0.3 seems ok. Leaving this here until we update phiphi.
0196 
0197 ifeq (${CXX}, ${ICC})
0198   MAKEDEPEND = gcc    -MM -MG ${DEPEND_TGTS} ${CPPFLAGS}
0199 else
0200   MAKEDEPEND = ${CXX} -MM -MG ${DEPEND_TGTS} ${CPPFLAGS}
0201 endif
0202 
0203 CPPFLAGS += ${CPPUSERFLAGS}
0204 CXXFLAGS += ${CXXUSERFLAGS}
0205 LDFLAGS  += ${LDUSERFLAGS}