Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-22 23:30:01

0001 #
0002 # stuff to make
0003 #
0004 
0005 CCSOURCES=$(wildcard ../../src/*.cc)
0006 ALPAKACCSOURCES=$(wildcard ../../src/alpaka/*.dev.cc)
0007 CCOBJECTS_CPU=$(patsubst ../../src/alpaka/%.dev.cc, %_cpu.o, $(ALPAKACCSOURCES)) $(patsubst ../../src/%.cc, %_cpu.o, $(CCSOURCES))
0008 CCOBJECTS_CUDA=$(patsubst ../../src/alpaka/%.dev.cc, %_cuda.o, $(ALPAKACCSOURCES)) $(patsubst ../../src/%.cc, %_cuda.o, $(CCSOURCES))
0009 CCOBJECTS_ROCM=$(patsubst ../../src/alpaka/%.dev.cc, %_rocm.o, $(ALPAKACCSOURCES)) $(patsubst ../../src/%.cc, %_rocm.o, $(CCSOURCES))
0010 
0011 LSTSOURCES=../../src/alpaka/LST.cc
0012 LSTOBJECTS_CPU=$(patsubst ../../src/alpaka/%.cc, %_cpu.o, $(LSTSOURCES))
0013 LSTOBJECTS_CUDA=$(patsubst ../../src/alpaka/%.cc, %_cuda.o, $(LSTSOURCES))
0014 LSTOBJECTS_ROCM=$(patsubst ../../src/alpaka/%.cc, %_rocm.o, $(LSTSOURCES))
0015 
0016 # Default to CPU and CUDA backends
0017 ifeq ($(BACKEND),)
0018   LIB_CPU=liblst_cpu.so
0019   LIB_CUDA=liblst_cuda.so
0020 endif
0021 
0022 ifneq ($(findstring cpu,$(BACKEND)),)
0023   LIB_CPU=liblst_cpu.so
0024 endif
0025 ifneq ($(findstring cuda,$(BACKEND)),)
0026   LIB_CUDA=liblst_cuda.so
0027 endif
0028 ifneq ($(findstring rocm,$(BACKEND)),)
0029   LIB_ROCM=liblst_rocm.so
0030 endif
0031 ifneq ($(findstring all,$(BACKEND)),)
0032   LIB_CPU=liblst_cpu.so
0033   LIB_CUDA=liblst_cuda.so
0034   LIB_ROCM=liblst_rocm.so
0035 endif
0036 
0037 LIBS=$(LIB_CPU) $(LIB_CUDA) $(LIB_ROCM)
0038 
0039 #
0040 # flags to keep track of
0041 #
0042 
0043 # Different architectures to optimize for
0044 GENCODE_CUDA := -gencode arch=compute_70,code=[sm_70,compute_70] -gencode arch=compute_89,code=[sm_89,compute_89]
0045 
0046 CXX                  = g++
0047 CXXFLAGS_CPU         = -march=native -mtune=native -Ofast -fno-reciprocal-math -fopenmp-simd -g -Wall -Woverloaded-virtual -fPIC -fopenmp -I..
0048 CXXFLAGS_CUDA        = -O3 -g --compiler-options -Wall --compiler-options -Woverloaded-virtual --compiler-options -fPIC --compiler-options -fopenmp -dc -lineinfo --ptxas-options=-v --cudart shared $(GENCODE_CUDA) --use_fast_math --default-stream per-thread -I..
0049 CXXFLAGS_ROCM        = -O3 -g -Wall -Woverloaded-virtual -fPIC -I${ROCM_ROOT}/include -I..
0050 CMSSWINCLUDE        := -I${TRACKLOOPERDIR}/../../../ -I${CMSSW_BASE}/src -I${FMT_ROOT}/include
0051 ifdef CMSSW_RELEASE_BASE 
0052 CMSSWINCLUDE        := ${CMSSWINCLUDE} -I${CMSSW_RELEASE_BASE}/src
0053 endif
0054 ALPAKAINCLUDE        = -I${ALPAKA_ROOT}/include -I/${BOOST_ROOT}/include -std=c++20 ${CMSSWINCLUDE} 
0055 ALPAKASERIAL         = -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED -DALPAKA_DISABLE_VENDOR_RNG -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
0056 ALPAKACUDA           = -DALPAKA_ACC_GPU_CUDA_ENABLED -DALPAKA_ACC_GPU_CUDA_ONLY -DALPAKA_DISABLE_VENDOR_RNG -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 --expt-relaxed-constexpr
0057 ALPAKAROCM           = -DALPAKA_ACC_GPU_HIP_ENABLED -DALPAKA_ACC_GPU_HIP_ONLY -DALPAKA_DISABLE_VENDOR_RNG -DALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128 -DGNU_GCC -D_GNU_SOURCE --target=x86_64-redhat-linux-gnu --gcc-toolchain=$(patsubst %/bin/gcc,%,$(shell command -v gcc))
0058 ROOTINCLUDE          = -I$(ROOT_ROOT)/include
0059 ROOTCFLAGS           = -pthread -m64 $(ROOTINCLUDE) 
0060 PTCUTFLAG            =
0061 LSTWARNINGSFLAG      =
0062 CMSSW_WERRORS_CPU    = -Werror=pointer-arith -Werror=overlength-strings -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=unused-label \
0063                        -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-dtor -Werror=strict-aliasing -Werror=narrowing \
0064                        -Werror=unused-but-set-variable -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Werror=return-local-addr -Wnon-virtual-dtor -Werror=switch \
0065                        -Werror=main -Werror=overflow -Werror=format-contains-nul -Werror=type-limits -Wreturn-type -Wextra -Wpessimizing-move -Wclass-memaccess -Wunused \
0066                        -Wparentheses -Wno-vla -Wno-non-template-friend -Wno-long-long -Wno-cast-function-type -Wno-unused-but-set-parameter -Wno-ignored-qualifiers \
0067                        -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-attributes
0068 CMSSW_WERRORS_CUDA   = $(patsubst %,-Xcompiler %,$(CMSSW_WERRORS_CPU))
0069 CMSSW_WERRORS_ROCM   = $(CMSSW_WERRORS_CPU)
0070 T5CUTFLAGS           = $(T5DNNFLAG) $(T5RZCHI2FLAG)
0071 
0072 LD_CPU               = g++
0073 SOFLAGS_CPU          = -g -shared -fPIC
0074 ALPAKABACKEND_CPU    = $(ALPAKASERIAL)
0075 COMPILE_CMD_CPU      = $(LD_CPU) -c
0076 
0077 LD_CUDA              = nvcc
0078 SOFLAGS_CUDA         = -g -shared --compiler-options -fPIC --cudart shared $(GENCODE_CUDA)
0079 ALPAKABACKEND_CUDA   = $(ALPAKACUDA)
0080 COMPILE_CMD_CUDA     = $(LD_CUDA) -x cu
0081 
0082 LD_ROCM              = hipcc
0083 SOFLAGS_ROCM         = -g -shared -fPIC
0084 ALPAKABACKEND_ROCM   = $(ALPAKAROCM)
0085 COMPILE_CMD_ROCM     = $(LD_ROCM) -c
0086 
0087 CUTVALUEFLAG =
0088 CUTVALUEFLAG_FLAGS = -DCUT_VALUE_DEBUG
0089 
0090 %_cpu.o: ../../src/alpaka/%.dev.cc
0091         $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@
0092 
0093 %_cuda.o: ../../src/alpaka/%.dev.cc
0094         $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@
0095 
0096 %_rocm.o: ../../src/alpaka/%.dev.cc
0097         $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@
0098 
0099 %_cpu.o: ../../src/alpaka/%.cc
0100         $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@
0101 
0102 %_cuda.o: ../../src/alpaka/%.cc
0103         $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@
0104 
0105 %_rocm.o: ../../src/alpaka/%.cc
0106         $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@
0107 
0108 %_cpu.o: ../../src/%.cc
0109         $(COMPILE_CMD_CPU) $(CXXFLAGS_CPU) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CPU) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CPU) $< -o $@
0110 
0111 %_cuda.o: ../../src/%.cc
0112         $(COMPILE_CMD_CUDA) $(CXXFLAGS_CUDA) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_CUDA) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_CUDA) $< -o $@
0113 
0114 %_rocm.o: ../../src/%.cc
0115         $(COMPILE_CMD_ROCM) $(CXXFLAGS_ROCM) $(ROOTINCLUDE) $(CUTVALUEFLAG) $(LSTWARNINGSFLAG) $(CMSSW_WERRORS_ROCM) $(T5CUTFLAGS) $(ALPAKAINCLUDE) $(ALPAKABACKEND_ROCM) $< -o $@
0116 
0117 $(LIB_CPU): $(CCOBJECTS_CPU) $(LSTOBJECTS_CPU)
0118         $(LD_CPU) $(SOFLAGS_CPU) $^ -o $@
0119 
0120 $(LIB_CUDA): $(CCOBJECTS_CUDA) $(LSTOBJECTS_CUDA)
0121         $(LD_CUDA) $(SOFLAGS_CUDA) $^ -o $@
0122 
0123 $(LIB_ROCM): $(CCOBJECTS_ROCM) $(LSTOBJECTS_ROCM)
0124         $(LD_ROCM) $(SOFLAGS_ROCM) $^ -o $@
0125 
0126 explicit: $(LIBS)
0127 
0128 explicit_cutvalue: CUTVALUEFLAG = $(CUTVALUEFLAG_FLAGS)
0129 explicit_cutvalue: $(LIBS)
0130 
0131 clean:
0132         rm -f *.opp
0133         rm -f *.o
0134         rm -f *.d
0135         rm -f *.so
0136 
0137 .PHONY: clean explicit explicit_cutvalue format check check-fix
0138 
0139 format:
0140         clang-format --style=file:../.clang-format -i *.cc *.h
0141 
0142 # Collect all the include paths from the compiler.
0143 # The .../gcc/x86_64-redhat-linux-gnu/*/include path is excluded since .../gcc/x86_64-redhat-linux-gnu/*/include-fixed should be used instead.
0144 TIDYINCLUDEFLAGS := $(shell g++ -E -x c++ - -v < /dev/null 2>&1 | awk '/#include <...>/,/^End of search/{if (/^ / && !/x86_64-redhat-linux-gnu\/[0-9.]+\/include$$/) print "-I"$$1}' | tr '\n' ' ')
0145 TIDYFLAGS := --language=c++ $(CXXFLAGS_CPU) $(ALPAKAINCLUDE) $(ALPAKASERIAL) $(ROOTCFLAGS) $(DUPLICATED) $(TIDYINCLUDEFLAGS)
0146 
0147 check:
0148         clang-tidy --config-file=../.clang-tidy *.cc *.h -- $(TIDYFLAGS)
0149 
0150 check-fix:
0151         clang-tidy --config-file=../.clang-tidy --format-style=file:../.clang-format --fix --fix-errors --fix-notes *.cc *.h -- $(TIDYFLAGS)