Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:25

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 # -DDUMP_HIT_PRESEL
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   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
0121   CXXFLAGS += -fdiagnostics-color=auto -fdiagnostics-show-option -fopenmp-simd
0122   # Disable reciprocal math for Intel/AMD consistency, see cms-sw/cmsdist#8280
0123   CXXFLAGS += -fno-reciprocal-math -mrecip=none
0124 endif
0125 
0126 # Try to find a new enough TBB
0127 ifneq ($(CXX),icc)
0128   ifndef TBB_PREFIX
0129     ifdef CMSSW_BASE
0130       CPPFLAGS += -I$(shell cd $$CMSSW_BASE && scram tool tag tbb INCLUDE)
0131       LDFLAGS_HOST += -L$(shell cd $$CMSSW_BASE && scram tool tag tbb LIBDIR)
0132     else ifdef TBB_GCC
0133       TBB_PREFIX = $(TBB_GCC)
0134     endif
0135   endif
0136 endif
0137 
0138 ifdef WITH_TBB
0139   # icc finds tbb in its own installation, but allow overriding in case it doesn't
0140   ifdef TBB_PREFIX
0141     CPPFLAGS += -I${TBB_PREFIX}/include
0142     LDFLAGS  += -L${TBB_PREFIX}/lib -Wl,-rpath,${TBB_PREFIX}/lib 
0143   endif
0144   CPPFLAGS += -DTBB
0145   LDFLAGS  += -ltbb
0146 endif
0147 
0148 CPPFLAGS_NO_ROOT := ${CPPFLAGS} -DNO_ROOT
0149 LDFLAGS_NO_ROOT  := ${LDFLAGS}
0150 
0151 ifdef WITH_ROOT
0152   CPPFLAGS += $(shell root-config --cflags)
0153   LDFLAGS  += $(shell root-config --libs)
0154 else
0155   CPPFLAGS += -DNO_ROOT
0156 endif
0157 
0158 ifdef DEBUG
0159   CPPFLAGS += -DDEBUG
0160 endif
0161 
0162 # Set C++ standard version at the very end, as other flags (i.e. ROOT) can override our choice for which version of c++
0163 CXXFLAGS += -std=c++1z
0164 
0165 ################################################################
0166 # Dependency generation
0167 ################################################################
0168 
0169 DEPEND_TGTS = -MQ '$(patsubst %.d,%.o,$@)'
0170 
0171 # With icc use gcc for dependency generation. Check if this is still true with icc-16.
0172 # MT-2016-08-30: icc 16.0.3 seems ok. Leaving this here until we update phiphi.
0173 
0174 ifeq (${CXX}, ${ICC})
0175   MAKEDEPEND = gcc    -MM -MG ${DEPEND_TGTS} ${CPPFLAGS}
0176 else
0177   MAKEDEPEND = ${CXX} -MM -MG ${DEPEND_TGTS} ${CPPFLAGS}
0178 endif
0179 
0180 CPPFLAGS += ${CPPUSERFLAGS}
0181 CXXFLAGS += ${CXXUSERFLAGS}
0182 LDFLAGS  += ${LDUSERFLAGS}