Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-25 02:14:14

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 
0034 # 2. Use gcc (clang by default on mac) or icc
0035 # Comment out to force using standard c++.
0036 ifdef INTEL_LICENSE_FILE
0037   # Define ICC to make it easier to switch to icpc
0038   ICC := icc
0039   CXX := ${ICC}
0040 else ifdef OSXGCC5
0041   CXX := c++-mp-5
0042   TBB_PREFIX := /opt/local
0043 else ifdef OSXMPCLANG
0044   CXX := ${OSXMPCLANG} -Wall -Wno-unknown-pragmas -Wno-missing-braces
0045   TBB_PREFIX := /opt/local
0046 endif
0047 
0048 # 3. Optimization
0049 # -O3 implies vectorization and simd (but not AVX)
0050 # But use -Ofast rather than -O3 so gcc can auto-vectorize sin/cos with libmvec (glibc >= 2.22)
0051 OPT := -g -Ofast
0052 
0053 # 4. Vectorization settings
0054 ifdef AVX_512
0055 VEC_GCC  := -march=native # -fopt-info-vec -mavx512f -mavx512cd
0056 VEC_ICC  := -xHost -qopt-zmm-usage=high # -xcore-avx512
0057 else ifdef AVX2
0058 VEC_GCC  := -mavx2 -mfma
0059 VEC_ICC  := -mavx2 -mfma
0060 else ifdef SSE3
0061 VEC_GCC  := -msse3
0062 VEC_ICC  := -msse3
0063 else
0064 VEC_GCC  := -mavx # -fopt-info-vec-all
0065 VEC_ICC  := -mavx
0066 endif
0067 
0068 # 5. Matriplex intrinsics, vtune
0069 # Comment-out to enable intrinsics (supported for AVX512, AVX2 and AVX)
0070 USE_INTRINSICS := -DMPLEX_USE_INTRINSICS
0071 # To enforce given vector size (does not work with intrinsics!)
0072 #USE_INTRINSICS := -DMPT_SIZE=1
0073 USE_VTUNE_NOTIFY := 1
0074 
0075 # 6. Intel Threading Building Blocks.  With icc uses system
0076 # TBB, otherwise requires a local installation, and paths will
0077 # have to be adjusted.
0078 WITH_TBB := 1
0079 
0080 # 7. Use inward fit in Conformal fit
0081 #INWARD_FIT := -DINWARDFIT
0082 
0083 ################################################################
0084 # Derived settings
0085 ################################################################
0086 
0087 CPPFLAGS := ${USE_INTRINSICS} -DMKFIT_STANDALONE
0088 CXXFLAGS := -fPIC ${OPT} ${OSX_CXXFLAGS}
0089 
0090 LDFLAGS_HOST := 
0091 
0092 CPPFLAGS += ${INWARD_FIT}
0093 
0094 # Dump hit selection window tuples
0095 # CPPFLAGS += -DDUMPHITWINDOW
0096 # The new dumpers
0097 ifdef WITH_ROOT
0098   # CPPFLAGS += -DRNT_DUMP_MkF_SelHitIdcs
0099 endif
0100 
0101 ifdef USE_VTUNE_NOTIFY
0102   ifdef VTUNE_AMPLIFIER_XE_2017_DIR
0103     CPPFLAGS     += -I$(VTUNE_AMPLIFIER_XE_2017_DIR)/include -DUSE_VTUNE_PAUSE
0104     LDFLAGS_HOST += -L$(VTUNE_AMPLIFIER_XE_2017_DIR)/lib64 -littnotify
0105   endif
0106 endif
0107 
0108 ifeq (${CXX}, ${ICC})
0109   VEC_HOST := ${VEC_ICC}
0110   CXXFLAGS += -qopt-report=5 -qopenmp-simd -qopt-report-phase=all
0111 else
0112   VEC_HOST := ${VEC_GCC}
0113 endif
0114 
0115 ifeq ($(CXX), g++)
0116   # For gcc, compile with flags approximating "scram build echo_CXXFLAGS" in a CMSSW env
0117   # -msse3 is enabled above, if so configured (i.e., not avx)
0118   # -Ofast is specified above in section 3.
0119   # -std is set to c++1z below (was c++17 here)
0120   # MT 2023-12-11: Had to remove -Werror=missing-braces ... triggered by RNTuple/REntry
0121   # 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 -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-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
0122   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 -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-deprecated-copy -Wno-unused-parameter -Wunused -Wparentheses -Wno-deprecated -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
0123   CXXFLAGS += -fdiagnostics-color=auto -fdiagnostics-show-option -fopenmp-simd
0124   # Disable reciprocal math for Intel/AMD consistency, see cms-sw/cmsdist#8280
0125   CXXFLAGS += -fno-reciprocal-math -mrecip=none
0126 endif
0127 
0128 # Try to find a new enough TBB
0129 ifneq ($(CXX),icc)
0130   ifndef TBB_PREFIX
0131     ifdef CMSSW_BASE
0132       CPPFLAGS += -I$(shell cd $$CMSSW_BASE && scram tool tag tbb INCLUDE)
0133       LDFLAGS_HOST += -L$(shell cd $$CMSSW_BASE && scram tool tag tbb LIBDIR)
0134     else ifdef TBB_GCC
0135       TBB_PREFIX = $(TBB_GCC)
0136     endif
0137   endif
0138 endif
0139 
0140 ifdef WITH_TBB
0141   # icc finds tbb in its own installation, but allow overriding in case it doesn't
0142   ifdef TBB_PREFIX
0143     CPPFLAGS += -I${TBB_PREFIX}/include
0144     LDFLAGS  += -L${TBB_PREFIX}/lib -Wl,-rpath,${TBB_PREFIX}/lib 
0145   endif
0146   CPPFLAGS += -DTBB
0147   LDFLAGS  += -ltbb
0148 endif
0149 
0150 CPPFLAGS_NO_ROOT := ${CPPFLAGS} -DNO_ROOT
0151 LDFLAGS_NO_ROOT  := ${LDFLAGS}
0152 
0153 ifdef WITH_ROOT
0154   CPPFLAGS += $(shell root-config --cflags)
0155   LDFLAGS  += $(shell root-config --libs)
0156 else
0157   CPPFLAGS += -DNO_ROOT
0158 endif
0159 
0160 ifdef DEBUG
0161   CPPFLAGS += -DDEBUG
0162 endif
0163 
0164 # Set C++ standard version at the very end, as other flags (i.e. ROOT) can override our choice for which version of c++
0165 CXXFLAGS += -std=c++1z
0166 
0167 ################################################################
0168 # Dependency generation
0169 ################################################################
0170 
0171 DEPEND_TGTS = -MQ '$(patsubst %.d,%.o,$@)'
0172 
0173 # With icc use gcc for dependency generation. Check if this is still true with icc-16.
0174 # MT-2016-08-30: icc 16.0.3 seems ok. Leaving this here until we update phiphi.
0175 
0176 ifeq (${CXX}, ${ICC})
0177   MAKEDEPEND = gcc    -MM -MG ${DEPEND_TGTS} ${CPPFLAGS}
0178 else
0179   MAKEDEPEND = ${CXX} -MM -MG ${DEPEND_TGTS} ${CPPFLAGS}
0180 endif
0181 
0182 CPPFLAGS += ${CPPUSERFLAGS}
0183 CXXFLAGS += ${CXXUSERFLAGS}
0184 LDFLAGS  += ${LDUSERFLAGS}