ex7
This commit is contained in:
parent
89326dd329
commit
2467b9ae03
44 changed files with 22631 additions and 0 deletions
154
ex7/code/task2/GCC_default.mk
Normal file
154
ex7/code/task2/GCC_default.mk
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
# Basic Defintions for using GNU-compiler suite sequentially
|
||||
# requires setting of COMPILER=GCC_
|
||||
|
||||
#startmake as follows to avoid warnings caused by OpenMPI code
|
||||
# make 2>&1 | grep -v openmpi
|
||||
|
||||
|
||||
MPI_ROOT=/usr/bin/
|
||||
|
||||
CC = ${MPI_ROOT}mpicc
|
||||
CXX = ${MPI_ROOT}mpicxx
|
||||
F77 = ${MPI_ROOT}mpif77
|
||||
LINKER = ${CXX}
|
||||
|
||||
# If you 'mpirun ...' reports some error "... not enough slots .." then use the option '--oversubscribe'
|
||||
MPIRUN = ${MPI_ROOT}mpirun --oversubscribe -display-map
|
||||
#MPIRUN = ${MPI_ROOT}mpiexec
|
||||
|
||||
# 2023, Oct 23: ""WARNING: There is at least non-excluded one OpenFabrics device found,"
|
||||
# solution according to https://github.com/open-mpi/ompi/issues/11063
|
||||
MPIRUN += -mca btl ^openib
|
||||
|
||||
# KFU:sauron
|
||||
CXXFLAGS += -I/software/boost/1_72_0/include
|
||||
|
||||
WARNINGS = -Wall -pedantic -Woverloaded-virtual -Wfloat-equal -Wshadow \
|
||||
-Wredundant-decls -Wunreachable-code -Winline -fmax-errors=1
|
||||
|
||||
# WARNINGS += -Weffc++ -Wextra
|
||||
# -Wno-pragmas
|
||||
CXXFLAGS += -std=c++17 -ffast-math -O3 -march=native ${WARNINGS}
|
||||
# -ftree-vectorizer-verbose=5 -DNDEBUG
|
||||
# -ftree-vectorizer-verbose=2
|
||||
# CFLAGS = -ffast-math -O3 -DNDEBUG -msse3 -fopenmp -fdump-tree-vect-details
|
||||
# CFLAGS = -ffast-math -O3 -funroll-loops -DNDEBUG -msse3 -fopenmp -ftree-vectorizer-verbose=2
|
||||
|
||||
# info on vectorization
|
||||
#VECTORIZE = -ftree-vectorize -fdump-tree-vect-blocks=foo.dump
|
||||
#-fdump-tree-pre=stderr
|
||||
VECTORIZE = -ftree-vectorize -fopt-info -ftree-vectorizer-verbose=5
|
||||
#CXXFLAGS += ${VECTORIZE}
|
||||
|
||||
# -funroll-all-loops -msse3
|
||||
#GCC -march=knl -march=broadwell -march=haswell
|
||||
|
||||
# for debugging purpose (save code)
|
||||
# -fsanitize=leak # only one out the trhee can be used
|
||||
# -fsanitize=address
|
||||
# -fsanitize=thread
|
||||
SANITARY = -fsanitize=address -fsanitize=undefined -fsanitize=null -fsanitize=return \
|
||||
-fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow \
|
||||
-fsanitize=bool -fsanitize=enum -fsanitize=vptr
|
||||
#CXXFLAGS += ${SANITARY}
|
||||
#LINKFLAGS +=${SANITARY}
|
||||
|
||||
# OpenMP
|
||||
CXXFLAGS += -fopenmp
|
||||
LINKFLAGS += -fopenmp
|
||||
|
||||
default: ${PROGRAM}
|
||||
|
||||
${PROGRAM}: ${OBJECTS}
|
||||
$(LINKER) $^ ${LINKFLAGS} -o $@
|
||||
@echo
|
||||
@echo "Start with : $(MPIRUN) -np num_proc $(MPIFLAGS) $(PROGRAM)"
|
||||
@echo
|
||||
|
||||
clean:
|
||||
@rm -f ${PROGRAM} ${OBJECTS} gmon.out
|
||||
|
||||
clean_all:: clean
|
||||
@rm -f *_ *~ *.bak *.log *.out *.tar *.orig
|
||||
@rm -rf html latex
|
||||
|
||||
run: ${PROGRAM}
|
||||
${MPIRUN} -np 4 ./$^
|
||||
|
||||
# tar the current directory
|
||||
MY_DIR = `basename ${PWD}`
|
||||
tar: clean_all
|
||||
@echo "Tar the directory: " ${MY_DIR}
|
||||
@cd .. ;\
|
||||
tar cf ${MY_DIR}.tar ${MY_DIR} *default.mk ;\
|
||||
cd ${MY_DIR}
|
||||
# tar cf `basename ${PWD}`.tar *
|
||||
|
||||
zip: clean
|
||||
@echo "Zip the directory: " ${MY_DIR}
|
||||
@cd .. ;\
|
||||
zip -r ${MY_DIR}.zip ${MY_DIR} *default.mk ;\
|
||||
cd ${MY_DIR}
|
||||
|
||||
doc:
|
||||
doxygen Doxyfile
|
||||
|
||||
#########################################################################
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) -o $@ $<
|
||||
# 2>&1 | grep -v openmpi
|
||||
|
||||
# special: get rid of compiler warnings genereate by openmpi-files
|
||||
#.cpp.o:
|
||||
# @$(CXX) -c $(CXXFLAGS) $< 2>/tmp/t.txt || grep -sv openmpi /tmp/t.txt
|
||||
# |grep -sv openmpi
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
.f.o:
|
||||
$(F77) -c $(FFLAGS) -o $@ $<
|
||||
|
||||
##################################################################################################
|
||||
# some tools
|
||||
# Cache behaviour (CXXFLAGS += -g tracks down to source lines; no -pg in linkflags)
|
||||
cache: ${PROGRAM}
|
||||
valgrind --tool=callgrind --simulate-cache=yes ./$^
|
||||
# kcachegrind callgrind.out.<pid> &
|
||||
kcachegrind `ls -1tr callgrind.out.* |tail -1`
|
||||
|
||||
# Check for wrong memory accesses, memory leaks, ...
|
||||
# use smaller data sets
|
||||
# no "-pg" in compile/link options
|
||||
mem: ${PROGRAM}
|
||||
valgrind -v --leak-check=yes --tool=memcheck --undef-value-errors=yes --track-origins=yes --log-file=$^.addr.out --show-reachable=yes mpirun -np 4 ./$^
|
||||
# Graphical interface
|
||||
# valkyrie
|
||||
|
||||
# Simple run time profiling of your code
|
||||
# CXXFLAGS += -g -pg
|
||||
# LINKFLAGS += -pg
|
||||
prof: ${PROGRAM}
|
||||
perf record ./$^
|
||||
perf report
|
||||
# gprof -b ./$^ > gp.out
|
||||
# kprof -f gp.out -p gprof &
|
||||
|
||||
#Trace your heap:
|
||||
#> heaptrack ./main.GCC_
|
||||
#> heaptrack_gui heaptrack.main.GCC_.<pid>.gz
|
||||
heap: ${PROGRAM}
|
||||
heaptrack ./$^ 11
|
||||
heaptrack_gui `ls -1tr heaptrack.$^.* |tail -1` &
|
||||
|
||||
codecheck: $(SOURCES)
|
||||
cppcheck --enable=all --inconclusive --std=c++17 --suppress=missingIncludeSystem $^
|
||||
|
||||
|
||||
########################################################################
|
||||
# get the detailed status of all optimization flags
|
||||
info:
|
||||
echo "detailed status of all optimization flags"
|
||||
$(CXX) --version
|
||||
$(CXX) -Q $(CXXFLAGS) --help=optimizers
|
||||
107
ex7/code/task2/ICC_NATIVE_default.mk
Normal file
107
ex7/code/task2/ICC_NATIVE_default.mk
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
# Basic Defintions for using INTEL-MPI with its compilers
|
||||
# requires setting of COMPILER=ICC_NATIVE_
|
||||
|
||||
# MPI_ROOT should be defined by shell
|
||||
# path to icpc is contained in $PATH
|
||||
MPI_BIN = $(shell dirname `which icpc` | sed 's/bin\/intel64/mpi\/intel64\/bin/g')/
|
||||
MPI_LIB = $(shell echo ${MPI_BIN} | sed 's/bin/lib/g')
|
||||
|
||||
# Intel-MPI wrappers used gcc as default !!
|
||||
CC = ${MPI_BIN}mpicc -cc=icc
|
||||
CXX = ${MPI_BIN}mpicxx -cxx=icpc
|
||||
F77 = ${MPI_BIN}mpif77 -f77=ifort
|
||||
LINKER = ${CXX}
|
||||
|
||||
MPIRUN = ${MPI_BIN}mpirun
|
||||
|
||||
WARNINGS = -Wall -Wextra -pedantic -Woverloaded-virtual -Wfloat-equal -Wshadow
|
||||
# -Weffc++ -Wunreachable-code -Winline
|
||||
CXXFLAGS += -O3 -fargument-noalias -DNDEBUG -std=c++17 ${WARNINGS} ${MPI_COMPILE_FLAGS}
|
||||
CFLAGS += -O3 -fargument-noalias -DNDEBUG -Wall -Wextra -pedantic -Wfloat-equal \
|
||||
-Wshadow ${MPI_COMPILE_FLAGS}
|
||||
# -vec-report=3 -mkl
|
||||
# -guide -parallel
|
||||
# -guide-opts=string -guide-par[=n] -guide-vec[=n]
|
||||
# -auto-p32 -simd
|
||||
|
||||
# use MKL by INTEL
|
||||
LINKFLAGS += -mkl ${MPI_LINK_FLAGS}
|
||||
|
||||
default: ${PROGRAM}
|
||||
|
||||
${PROGRAM}: ${OBJECTS}
|
||||
$(LINKER) $^ ${LINKFLAGS} -o $@
|
||||
@echo
|
||||
@echo "Start with : $(MPIRUN) -np num_proc $(MPIFLAGS) $(PROGRAM)"
|
||||
@echo
|
||||
|
||||
clean:
|
||||
rm -f ${PROGRAM} ${OBJECTS}
|
||||
|
||||
clean_all:: clean
|
||||
@rm -f *_ *~ *.bak *.log *.out *.tar
|
||||
|
||||
run: ${PROGRAM}
|
||||
(export LD_LIBRARY_PATH=${MPI_LIB}:${LD_LIBRARY_PATH} ;${MPIRUN} -np 4 ./$^ ${PROG_ARGS})
|
||||
|
||||
# tar the current directory
|
||||
MY_DIR = `basename ${PWD}`
|
||||
tar: clean_all
|
||||
@echo "Tar the directory: " ${MY_DIR}
|
||||
@cd .. ;\
|
||||
tar cf ${MY_DIR}.tar ${MY_DIR} *default.mk ;\
|
||||
cd ${MY_DIR}
|
||||
# tar cf `basename ${PWD}`.tar *
|
||||
|
||||
doc:
|
||||
doxygen Doxyfile
|
||||
|
||||
#########################################################################
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) -o $@ $<
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
.f.o:
|
||||
$(F77) -c $(FFLAGS) -o $@ $<
|
||||
|
||||
##################################################################################################
|
||||
# # some tools
|
||||
# # Cache behaviour (CXXFLAGS += -g tracks down to source lines)
|
||||
# cache: ${PROGRAM}
|
||||
# valgrind --tool=callgrind --simulate-cache=yes ./$^
|
||||
# # kcachegrind callgrind.out.<pid> &
|
||||
#
|
||||
# # Check for wrong memory accesses, memory leaks, ...
|
||||
# # use smaller data sets
|
||||
# mem: ${PROGRAM}
|
||||
# valgrind -v --leak-check=yes --tool=memcheck --undef-value-errors=yes --track-origins=yes --log-file=$^.addr.out --show-reachable=yes ./$^
|
||||
#
|
||||
# # Simple run time profiling of your code
|
||||
# # CXXFLAGS += -g -pg
|
||||
# # LINKFLAGS += -pg
|
||||
# prof: ${PROGRAM}
|
||||
# ./$^
|
||||
# gprof -b ./$^ > gp.out
|
||||
# # kprof -f gp.out -p gprof &
|
||||
#
|
||||
|
||||
|
||||
mem: inspector
|
||||
prof: amplifier
|
||||
cache: amplifier
|
||||
|
||||
gap_par_report:
|
||||
${CXX} -c -guide -parallel $(SOURCES) 2> gap.txt
|
||||
|
||||
# GUI for performance report
|
||||
amplifier: ${PROGRAM}
|
||||
${BINDIR}../vtune_amplifier_xe_2013/bin64/amplxe-gui &
|
||||
|
||||
# GUI for Memory and Thread analyzer (race condition)
|
||||
inspector: ${PROGRAM}
|
||||
# http://askubuntu.com/questions/41629/after-upgrade-gdb-wont-attach-to-process
|
||||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
||||
${BINDIR}../inspector_xe_2013/bin64/inspxe-gui &
|
||||
112
ex7/code/task2/ICC_default.mk
Normal file
112
ex7/code/task2/ICC_default.mk
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
# Basic Defintions for using INTEL compilers with OpenMPI headers and libraries
|
||||
# requires setting of COMPILER=ICC_
|
||||
|
||||
# MPI_ROOT should be defined by shell
|
||||
MPI_ROOT=/usr
|
||||
|
||||
CC = icc
|
||||
CXX = icpc
|
||||
F77 = ifort
|
||||
LINKER = ${CXX}
|
||||
|
||||
MPIRUN = ${MPI_ROOT}/bin/mpirun
|
||||
|
||||
# no differences when C or C++ is used !! (always used options from mpicxx)
|
||||
MPI_COMPILE_FLAGS = `${MPI_ROOT}/bin/mpicxx -showme:compile`
|
||||
MPI_LINK_FLAGS = `${MPI_ROOT}/bin/mpicxx -showme:link`
|
||||
# MPI_LINK_FLAGS = -pthread -L/usr/lib/openmpi/lib -lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl
|
||||
|
||||
|
||||
WARNINGS = -Wall -Wextra -pedantic -Woverloaded-virtual -Wfloat-equal -Wshadow
|
||||
# -Weffc++ -Wunreachable-code -Winline
|
||||
CXXFLAGS += -O3 -std=c++17 -fargument-noalias -DNDEBUG ${WARNINGS} ${MPI_COMPILE_FLAGS}
|
||||
CFLAGS += -O3 -fargument-noalias -DNDEBUG -Wall -Wextra -pedantic -Wfloat-equal \
|
||||
-Wshadow ${MPI_COMPILE_FLAGS}
|
||||
# -vec-report=3 -mkl
|
||||
# -guide -parallel
|
||||
# -guide-opts=string -guide-par[=n] -guide-vec[=n]
|
||||
# -auto-p32 -simd
|
||||
|
||||
# use MKL by INTEL
|
||||
LINKFLAGS += -mkl
|
||||
# use MPI by Compiler
|
||||
LINKFLAGS += ${MPI_LINK_FLAGS}
|
||||
|
||||
default: ${PROGRAM}
|
||||
|
||||
${PROGRAM}: ${OBJECTS}
|
||||
$(LINKER) $^ ${LINKFLAGS} -o $@
|
||||
@echo
|
||||
@echo "Start with : $(MPIRUN) -np num_proc $(MPIFLAGS) $(PROGRAM)"
|
||||
@echo
|
||||
|
||||
clean:
|
||||
rm -f ${PROGRAM} ${OBJECTS}
|
||||
|
||||
clean_all:: clean
|
||||
@rm -f *_ *~ *.bak *.log *.out *.tar
|
||||
|
||||
run: ${PROGRAM}
|
||||
${MPIRUN} -np 4 ./$^
|
||||
|
||||
# tar the current directory
|
||||
MY_DIR = `basename ${PWD}`
|
||||
tar: clean_all
|
||||
@echo "Tar the directory: " ${MY_DIR}
|
||||
@cd .. ;\
|
||||
tar cf ${MY_DIR}.tar ${MY_DIR} *default.mk ;\
|
||||
cd ${MY_DIR}
|
||||
# tar cf `basename ${PWD}`.tar *
|
||||
|
||||
doc:
|
||||
doxygen Doxyfile
|
||||
|
||||
#########################################################################
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) -o $@ $<
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
.f.o:
|
||||
$(F77) -c $(FFLAGS) -o $@ $<
|
||||
|
||||
##################################################################################################
|
||||
# # some tools
|
||||
# # Cache behaviour (CXXFLAGS += -g tracks down to source lines)
|
||||
# cache: ${PROGRAM}
|
||||
# valgrind --tool=callgrind --simulate-cache=yes ./$^
|
||||
# # kcachegrind callgrind.out.<pid> &
|
||||
#
|
||||
# # Check for wrong memory accesses, memory leaks, ...
|
||||
# # use smaller data sets
|
||||
# mem: ${PROGRAM}
|
||||
# valgrind -v --leak-check=yes --tool=memcheck --undef-value-errors=yes --track-origins=yes --log-file=$^.addr.out --show-reachable=yes ./$^
|
||||
#
|
||||
# # Simple run time profiling of your code
|
||||
# # CXXFLAGS += -g -pg
|
||||
# # LINKFLAGS += -pg
|
||||
# prof: ${PROGRAM}
|
||||
# ./$^
|
||||
# gprof -b ./$^ > gp.out
|
||||
# # kprof -f gp.out -p gprof &
|
||||
#
|
||||
|
||||
|
||||
mem: inspector
|
||||
prof: amplifier
|
||||
cache: amplifier
|
||||
|
||||
gap_par_report:
|
||||
${CXX} -c -guide -parallel $(SOURCES) 2> gap.txt
|
||||
|
||||
# GUI for performance report
|
||||
amplifier: ${PROGRAM}
|
||||
${BINDIR}../vtune_amplifier_xe_2013/bin64/amplxe-gui &
|
||||
|
||||
# GUI for Memory and Thread analyzer (race condition)
|
||||
inspector: ${PROGRAM}
|
||||
# http://askubuntu.com/questions/41629/after-upgrade-gdb-wont-attach-to-process
|
||||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
||||
${BINDIR}../inspector_xe_2013/bin64/inspxe-gui &
|
||||
128
ex7/code/task2/OPENMPI_CLANG_default.mk
Normal file
128
ex7/code/task2/OPENMPI_CLANG_default.mk
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
# Basic Defintions for using OpenMPI with CLANG compilers
|
||||
# requires setting of COMPILER=OPENMPI_CLANG_
|
||||
|
||||
# Pass CLANG Compilers to the OpenMPI wrappers
|
||||
# see: https://www.open-mpi.org/faq/?category=mpi-apps#override-wrappers-after-v1.0
|
||||
EXPORT = export OMPI_CXX=clang++; export OMPI_CC=clang; export OMPI_mpifort=flang
|
||||
|
||||
CC = mpicc
|
||||
CXX = mpicxx
|
||||
F77 = mpifort
|
||||
LINKER = ${CXX}
|
||||
|
||||
MPIRUN = ${MPI_BIN}mpirun
|
||||
|
||||
#http://clang.llvm.org/docs/UsersManual.html#options-to-control-error-and-warning-messages
|
||||
SILENCE_MPI = -Wno-weak-vtables -Wno-old-style-cast -Wno-cast-align -Wno-deprecated
|
||||
SILENCE_MPI+= -Wno-sign-conversion -Wno-reserved-id-macro -Wno-c++98-compat-pedantic
|
||||
SILENCE_MPI+= -Wno-zero-as-null-pointer-constant -Wno-source-uses-openmp
|
||||
WARNINGS = -Weverything -Wno-c++98-compat -Wno-weak-vtables -ferror-limit=3 ${SILENCE_MPI}
|
||||
#-fsyntax-only -Wdocumentation -Wconversion -Wshadow -Wfloat-conversion -pedantic
|
||||
CXXFLAGS += -Ofast -std=c++17 ${WARNINGS}
|
||||
#CXXFLAGS += -Ofast -std=c++17
|
||||
# -ftrapv
|
||||
#
|
||||
CFLAGS += -Ofast -Weverything -ferror-limit=3 ${MPI_COMPILE_FLAGS}
|
||||
|
||||
# OpenMP
|
||||
#CXXFLAGS += -fopenmp
|
||||
#LINKFLAGS += -fopenmp
|
||||
|
||||
# tidy_check
|
||||
SWITCH_OFF=,-readability-magic-numbers,-readability-redundant-control-flow,-readability-redundant-member-init
|
||||
SWITCH_OFF+=,-readability-redundant-member-init,-readability-isolate-declaration
|
||||
#READABILITY=,readability*${SWITCH_OFF}
|
||||
#TIDYFLAGS = -checks=llvm-*,-llvm-header-guard -header-filter=.* -enable-check-profile -extra-arg="-std=c++17" -extra-arg="-fopenmp"
|
||||
TIDYFLAGS = -checks=llvm-*,-llvm-header-guard${READABILITY} -header-filter=.* -enable-check-profile -extra-arg="-std=c++17" -extra-arg="-fopenmp"
|
||||
#TIDYFLAGS += -checks='modernize*
|
||||
|
||||
MPI_COMPILE_FLAGS = `${MPI_BIN}mpicxx -showme:compile`
|
||||
MPI_LINK_FLAGS = `${MPI_BIN}mpicxx -showme:link`
|
||||
#TIDYFLAGS += ${MPI_COMPILE_FLAGS}
|
||||
TIDYFLAGS += -extra-arg="-I/usr/lib/x86_64-linux-gnu/openmpi/include"
|
||||
#check:
|
||||
# echo ${MPI_COMPILE_FLAGS}
|
||||
|
||||
default: ${PROGRAM}
|
||||
|
||||
${PROGRAM}: ${OBJECTS}
|
||||
@( ${EXPORT}; $(LINKER) $^ ${LINKFLAGS} -o $@ )
|
||||
@echo
|
||||
@echo "Start with : $(MPIRUN) -np num_proc $(MPIFLAGS) $(PROGRAM)"
|
||||
@echo
|
||||
|
||||
clean:
|
||||
rm -f ${PROGRAM} ${OBJECTS}
|
||||
|
||||
clean_all:: clean
|
||||
@rm -f *_ *~ *.bak *.log *.out *.tar
|
||||
|
||||
codecheck: tidy_check
|
||||
tidy_check:
|
||||
clang-tidy ${SOURCES} ${TIDYFLAGS} -- ${SOURCES}
|
||||
# see also http://clang-developers.42468.n3.nabble.com/Error-while-trying-to-load-a-compilation-database-td4049722.html
|
||||
|
||||
run: ${PROGRAM}
|
||||
${MPIRUN} -np 4 ./$^ ${PROG_ARGS}
|
||||
|
||||
# tar the current directory
|
||||
MY_DIR = `basename ${PWD}`
|
||||
tar: clean_all
|
||||
@echo "Tar the directory: " ${MY_DIR}
|
||||
@cd .. ;\
|
||||
tar cf ${MY_DIR}.tar ${MY_DIR} *default.mk ;\
|
||||
cd ${MY_DIR}
|
||||
# tar cf `basename ${PWD}`.tar *
|
||||
|
||||
doc:
|
||||
doxygen Doxyfile
|
||||
|
||||
#########################################################################
|
||||
|
||||
.cpp.o:
|
||||
@( ${EXPORT}; $(CXX) -c $(CXXFLAGS) -o $@ $< )
|
||||
|
||||
.c.o:
|
||||
@( ${EXPORT}; $(CC) -c $(CFLAGS) -o $@ $< )
|
||||
|
||||
.f.o:
|
||||
$(F77) -c $(FFLAGS) -o $@ $<
|
||||
|
||||
##################################################################################################
|
||||
# # some tools
|
||||
# # Cache behaviour (CXXFLAGS += -g tracks down to source lines)
|
||||
# cache: ${PROGRAM}
|
||||
# valgrind --tool=callgrind --simulate-cache=yes ./$^
|
||||
# # kcachegrind callgrind.out.<pid> &
|
||||
#
|
||||
# # Check for wrong memory accesses, memory leaks, ...
|
||||
# # use smaller data sets
|
||||
# mem: ${PROGRAM}
|
||||
# valgrind -v --leak-check=yes --tool=memcheck --undef-value-errors=yes --track-origins=yes --log-file=$^.addr.out --show-reachable=yes ./$^
|
||||
#
|
||||
# # Simple run time profiling of your code
|
||||
# # CXXFLAGS += -g -pg
|
||||
# # LINKFLAGS += -pg
|
||||
# prof: ${PROGRAM}
|
||||
# ./$^
|
||||
# gprof -b ./$^ > gp.out
|
||||
# # kprof -f gp.out -p gprof &
|
||||
#
|
||||
|
||||
|
||||
mem: inspector
|
||||
prof: amplifier
|
||||
cache: amplifier
|
||||
|
||||
gap_par_report:
|
||||
${CXX} -c -guide -parallel $(SOURCES) 2> gap.txt
|
||||
|
||||
# GUI for performance report
|
||||
amplifier: ${PROGRAM}
|
||||
${BINDIR}../vtune_amplifier_xe_2013/bin64/amplxe-gui &
|
||||
|
||||
# GUI for Memory and Thread analyzer (race condition)
|
||||
inspector: ${PROGRAM}
|
||||
# http://askubuntu.com/questions/41629/after-upgrade-gdb-wont-attach-to-process
|
||||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
||||
${BINDIR}../inspector_xe_2013/bin64/inspxe-gui &
|
||||
107
ex7/code/task2/OPENMPI_ICC_default.mk
Normal file
107
ex7/code/task2/OPENMPI_ICC_default.mk
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
# Basic Defintions for using OpenMPI with Intel compilers
|
||||
# requires setting of COMPILER=OPENMPI_ICC_
|
||||
|
||||
# Pass Intel Compilers to the OpenMPI wrappers
|
||||
# see: https://www.open-mpi.org/faq/?category=mpi-apps#override-wrappers-after-v1.0
|
||||
EXPORT = export OMPI_CXX=icpc; export OMPI_CC=icc; export OMPI_mpifort=ifort
|
||||
|
||||
CC = mpicc
|
||||
CXX = mpicxx
|
||||
F77 = mpifort
|
||||
LINKER = ${CXX}
|
||||
|
||||
MPIRUN = ${MPI_BIN}mpirun
|
||||
|
||||
WARNINGS = -Wall -Wextra -pedantic -Woverloaded-virtual -Wfloat-equal -Wshadow
|
||||
# -Weffc++ -Wunreachable-code -Winline
|
||||
CXXFLAGS += -fast -fargument-noalias -DNDEBUG -std=c++17 ${WARNINGS}
|
||||
CFLAGS += -O3 -fargument-noalias -DNDEBUG -Wall -Wextra -pedantic -Wfloat-equal -Wshadow
|
||||
# -vec-report=3 -mkl
|
||||
# -guide -parallel
|
||||
# -guide-opts=string -guide-par[=n] -guide-vec[=n]
|
||||
# -auto-p32 -simd
|
||||
|
||||
# use MKL by INTEL
|
||||
LINKFLAGS += -O3 -mkl ${MPI_LINK_FLAGS}
|
||||
# ipo: warning #11021: unresolved __GI_memset
|
||||
# see: https://software.intel.com/en-us/articles/ipo-warning-11021-unresolved-symbols-referenced-a-dynamic-library
|
||||
LINKFLAGS +=
|
||||
|
||||
default: ${PROGRAM}
|
||||
|
||||
${PROGRAM}: ${OBJECTS}
|
||||
@( ${EXPORT}; $(LINKER) $^ ${LINKFLAGS} -o $@ )
|
||||
@echo
|
||||
@echo "Start with : $(MPIRUN) -np num_proc $(MPIFLAGS) $(PROGRAM)"
|
||||
@echo
|
||||
|
||||
clean:
|
||||
rm -f ${PROGRAM} ${OBJECTS}
|
||||
|
||||
clean_all:: clean
|
||||
@rm -f *_ *~ *.bak *.log *.out *.tar
|
||||
|
||||
run: ${PROGRAM}
|
||||
${MPIRUN} -np 4 ./$^ ${PROG_ARGS}
|
||||
|
||||
# tar the current directory
|
||||
MY_DIR = `basename ${PWD}`
|
||||
tar: clean_all
|
||||
@echo "Tar the directory: " ${MY_DIR}
|
||||
@cd .. ;\
|
||||
tar cf ${MY_DIR}.tar ${MY_DIR} *default.mk ;\
|
||||
cd ${MY_DIR}
|
||||
# tar cf `basename ${PWD}`.tar *
|
||||
|
||||
doc:
|
||||
doxygen Doxyfile
|
||||
|
||||
#########################################################################
|
||||
|
||||
.cpp.o:
|
||||
@( ${EXPORT}; $(CXX) -c $(CXXFLAGS) -o $@ $< )
|
||||
|
||||
.c.o:
|
||||
@( ${EXPORT}; $(CC) -c $(CFLAGS) -o $@ $< )
|
||||
|
||||
.f.o:
|
||||
$(F77) -c $(FFLAGS) -o $@ $<
|
||||
|
||||
##################################################################################################
|
||||
# # some tools
|
||||
# # Cache behaviour (CXXFLAGS += -g tracks down to source lines)
|
||||
# cache: ${PROGRAM}
|
||||
# valgrind --tool=callgrind --simulate-cache=yes ./$^
|
||||
# # kcachegrind callgrind.out.<pid> &
|
||||
#
|
||||
# # Check for wrong memory accesses, memory leaks, ...
|
||||
# # use smaller data sets
|
||||
# mem: ${PROGRAM}
|
||||
# valgrind -v --leak-check=yes --tool=memcheck --undef-value-errors=yes --track-origins=yes --log-file=$^.addr.out --show-reachable=yes ./$^
|
||||
#
|
||||
# # Simple run time profiling of your code
|
||||
# # CXXFLAGS += -g -pg
|
||||
# # LINKFLAGS += -pg
|
||||
# prof: ${PROGRAM}
|
||||
# ./$^
|
||||
# gprof -b ./$^ > gp.out
|
||||
# # kprof -f gp.out -p gprof &
|
||||
#
|
||||
|
||||
|
||||
mem: inspector
|
||||
prof: amplifier
|
||||
cache: amplifier
|
||||
|
||||
gap_par_report:
|
||||
${CXX} -c -guide -parallel $(SOURCES) 2> gap.txt
|
||||
|
||||
# GUI for performance report
|
||||
amplifier: ${PROGRAM}
|
||||
${BINDIR}../vtune_amplifier_xe_2013/bin64/amplxe-gui &
|
||||
|
||||
# GUI for Memory and Thread analyzer (race condition)
|
||||
inspector: ${PROGRAM}
|
||||
# http://askubuntu.com/questions/41629/after-upgrade-gdb-wont-attach-to-process
|
||||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
|
||||
${BINDIR}../inspector_xe_2013/bin64/inspxe-gui &
|
||||
125
ex7/code/task2/PGI_NATIVE_default.mk
Normal file
125
ex7/code/task2/PGI_NATIVE_default.mk
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
# Use the MPI-wrappers from the PGI compiler suite.
|
||||
# requires setting of COMPILER=PGI_MPI_
|
||||
#
|
||||
# requires
|
||||
# sudo apt install librdmacm1
|
||||
|
||||
|
||||
|
||||
# Details for run time information
|
||||
# export PGI_ACC_TIME=1
|
||||
# unset PGI_ACC_TIME
|
||||
# export PGI_ACC_NOTIFY=1
|
||||
# export PGI_ACC_NOTIFY=3
|
||||
# unset PGI_ACC_NOTIFY
|
||||
|
||||
|
||||
PGI_PATH = /opt/pgi/linux86-64/2019/bin
|
||||
#ifeq "$(HOSTNAME)" "mephisto.uni-graz.at"
|
||||
# # mephisto
|
||||
# PGI_PATH = /share/apps/pgi/linux86-64/2016/bin
|
||||
#endif
|
||||
|
||||
|
||||
#MPI_ROOT=${PGI_PATH}mpi/mpich/bin/
|
||||
MPI_ROOT= ${PGI_PATH}/../mpi/openmpi-3.1.3/bin/
|
||||
MPIRUN = ${MPI_ROOT}mpirun
|
||||
|
||||
CC = ${MPI_ROOT}mpicc
|
||||
CXX = ${MPI_ROOT}mpicxx
|
||||
#F77 = ${MPI_ROOT}mpif77
|
||||
ifndef LINKER
|
||||
LINKER = ${CC}
|
||||
endif
|
||||
LINKER = ${CXX}
|
||||
|
||||
WARNINGS = -Minform=warn
|
||||
|
||||
PGI_PROFILING += -Minfo=loop,vect,opt,intensity,mp,accel
|
||||
#PGI_PROFILING += -Mprof=lines –Minfo=ccff
|
||||
|
||||
CXXFLAGS += -e3 -std=c++17 -fast ${PGI_PROFILING} ${WARNINGS} -Mnodepchk
|
||||
CFLAGS += -fast ${PGI_PROFILING} ${WARNINGS} -Mnodepchk
|
||||
#
|
||||
# for OpenACC
|
||||
# Target architecture (nvidia,host)
|
||||
TA_ARCH = host
|
||||
#TA_ARCH = nvidia,host
|
||||
#TA_ARCH = -ta=nvidia:cc2+,cuda5.5,fastmath
|
||||
#TA_ARCH = -acc -DNDEBUG -ta=nvidia:cc2+,cuda5.5,fastmath,keepgpu
|
||||
#TA_ARCH = -acc -DNDEBUG -ta=nvidia:cc2+,fastmath,keepgpu
|
||||
|
||||
#,keepgpu
|
||||
# CFLAGS = -O3 -ta=$(TA_ARCH)
|
||||
#CFLAGS += -B -gopt $(TA_ARCH)
|
||||
#CXXFLAGS += -B -gopt $(TA_ARCH)
|
||||
# -Minfo=all
|
||||
|
||||
# libcudart.a is needed for direct CUDA calls
|
||||
#LINKFLAGS = -gopt $(TA_ARCH) -L${BINDIR}../lib $(PGI_PROFILING)
|
||||
# -lcudart
|
||||
|
||||
default: ${PROGRAM}
|
||||
|
||||
${PROGRAM}: ${OBJECTS}
|
||||
$(LINKER) $^ ${LINKFLAGS} -o $@
|
||||
|
||||
clean:
|
||||
rm -f ${PROGRAM} ${OBJECTS} *.gpu *gprof.out
|
||||
|
||||
clean_all:: clean
|
||||
@rm -f *_ *~ *.bak *.log *.out *.tar
|
||||
|
||||
#run: clean ${PROGRAM}
|
||||
run: ${PROGRAM}
|
||||
${MPIRUN} -np 4 ${OPTIRUN} ./${PROGRAM}
|
||||
|
||||
# tar the current directory
|
||||
MY_DIR = `basename ${PWD}`
|
||||
tar: clean_all
|
||||
@echo "Tar the directory: " ${MY_DIR}
|
||||
@cd .. ;\
|
||||
tar cf ${MY_DIR}.tar ${MY_DIR} *default.mk ;\
|
||||
cd ${MY_DIR}
|
||||
# tar cf `basename ${PWD}`.tar *
|
||||
|
||||
doc:
|
||||
doxygen Doxyfile
|
||||
|
||||
#########################################################################
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) -o $@ $<
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
.f.o:
|
||||
$(F77) -c $(FFLAGS) -o $@ $<
|
||||
|
||||
##################################################################################################
|
||||
# # some tools
|
||||
# # Simple run time profiling of your code
|
||||
# # CXXFLAGS += -g -pg
|
||||
# # LINKFLAGS += -pg
|
||||
|
||||
|
||||
# Profiling options PGI, see: pgcollect -help
|
||||
CPU_PROF = -allcache
|
||||
GPU_PROF = -cuda=gmem,branch,cc13 -cudainit
|
||||
#GPU_PROF = -cuda=branch:cc20
|
||||
#
|
||||
PROF_FILE = pgprof.out
|
||||
|
||||
prof: ${PROGRAM}
|
||||
# ./$^
|
||||
# $(CUDA_HOME)/bin/nvvp &
|
||||
# export LD_LIBRARY_PATH=/state/partition1/apps/pgi/linux86-64/12.9/lib:$LD_LIBRARY_PATH
|
||||
${OPTIRUN} ${BINDIR}pgcollect $(GPU_PROF) ./$^
|
||||
${OPTIRUN} ${BINDIR}pgprof -exe ./$^ $(PROF_FILE) &
|
||||
|
||||
|
||||
# Memory checker (slooooow!!!):
|
||||
# see doc at /usr/local/cuda/doc/cuda-memcheck.pdf
|
||||
# mem: ${PROGRAM}
|
||||
# $(CUDA_HOME)memcheck ./$^
|
||||
2877
ex7/code/task2/first.template/Doxyfile
Normal file
2877
ex7/code/task2/first.template/Doxyfile
Normal file
File diff suppressed because it is too large
Load diff
23
ex7/code/task2/first.template/Makefile
Normal file
23
ex7/code/task2/first.template/Makefile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# Compile with
|
||||
# make 2>&1 | grep -v openmpi
|
||||
# to avoid warnings caused by OpenMPI
|
||||
|
||||
# use GNU-Compiler tools
|
||||
COMPILER=GCC_
|
||||
# alternatively from the shell
|
||||
# export COMPILER=GCC_
|
||||
# or, alternatively from the shell
|
||||
# make COMPILER=GCC_
|
||||
|
||||
MAIN = main
|
||||
SOURCES = ${MAIN}.cpp greetings.cpp
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
PROGRAM = ${MAIN}.${COMPILER}
|
||||
|
||||
# uncomment the next to lines for debugging and detailed performance analysis
|
||||
CXXFLAGS += -g
|
||||
LINKFLAGS +=
|
||||
|
||||
include ../${COMPILER}default.mk
|
||||
85
ex7/code/task2/first.template/greetings.cpp
Normal file
85
ex7/code/task2/first.template/greetings.cpp
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
#include "greetings.h"
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <mpi.h> // MPI
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
// see http://www.open-mpi.org/doc/current
|
||||
// for details on MPI functions
|
||||
|
||||
void greetings(MPI_Comm const &icomm)
|
||||
{
|
||||
int myrank, numprocs;
|
||||
MPI_Comm_rank(icomm, &myrank); // my MPI-rank
|
||||
MPI_Comm_size(icomm, &numprocs); // #MPI processes
|
||||
char *name = new char [MPI_MAX_PROCESSOR_NAME],
|
||||
*chbuf = new char [MPI_MAX_PROCESSOR_NAME];
|
||||
|
||||
int reslen, ierr;
|
||||
MPI_Get_processor_name( name, &reslen);
|
||||
|
||||
if (0==myrank) {
|
||||
cout << " " << myrank << " runs on " << name << endl;
|
||||
for (int i = 1; i < numprocs; ++i) {
|
||||
MPI_Status stat;
|
||||
stat.MPI_ERROR = 0; // M U S T be initialized!!
|
||||
|
||||
ierr = MPI_Recv(chbuf, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, MPI_ANY_SOURCE, MPI_ANY_TAG, icomm, &stat);
|
||||
assert(0==ierr);
|
||||
|
||||
cout << " " << stat.MPI_SOURCE << " runs on " << chbuf;
|
||||
int count;
|
||||
MPI_Get_count(&stat, MPI_CHAR, &count); // size of received data
|
||||
cout << " (length: " << count << " )" << endl;
|
||||
// stat.Get_error() // Error code
|
||||
}
|
||||
}
|
||||
else {
|
||||
int dest = 0;
|
||||
ierr = MPI_Send(name, strlen(name) + 1, MPI_CHAR, dest, myrank, icomm);
|
||||
assert(0==ierr);
|
||||
}
|
||||
delete [] chbuf;
|
||||
delete [] name;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void greetings_cpp(MPI_Comm const &icomm)
|
||||
{
|
||||
int myrank, numprocs;
|
||||
MPI_Comm_rank(icomm, &myrank); // my MPI-rank
|
||||
MPI_Comm_size(icomm, &numprocs); // #MPI processes
|
||||
string name(MPI_MAX_PROCESSOR_NAME,'#'), // C++
|
||||
recvbuf(MPI_MAX_PROCESSOR_NAME,'#'); // C++: receive buffer, don't change size
|
||||
|
||||
int reslen, ierr;
|
||||
MPI_Get_processor_name(name.data(), &reslen);
|
||||
name.resize(reslen); // C++
|
||||
|
||||
if (0==myrank) {
|
||||
cout << " " << myrank << " runs on " << name << endl;
|
||||
for (int i = 1; i < numprocs; ++i) {
|
||||
MPI_Status stat;
|
||||
stat.MPI_ERROR = 0; // M U S T be initialized!!
|
||||
|
||||
ierr = MPI_Recv(recvbuf.data(), MPI_MAX_PROCESSOR_NAME, MPI_CHAR, i, MPI_ANY_TAG, icomm, &stat);
|
||||
assert(0==ierr);
|
||||
|
||||
int count;
|
||||
MPI_Get_count(&stat, MPI_CHAR, &count); // size of received data
|
||||
string const chbuf(recvbuf,0,count); // C++
|
||||
cout << " " << stat.MPI_SOURCE << " runs on " << chbuf;
|
||||
cout << " (length: " << count << " )" << endl;
|
||||
// stat.Get_error() // Error code
|
||||
}
|
||||
}
|
||||
else {
|
||||
int dest = 0;
|
||||
ierr = MPI_Send(name.data(), name.size(), MPI_CHAR, dest, myrank, icomm);
|
||||
assert(0==ierr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
16
ex7/code/task2/first.template/greetings.h
Normal file
16
ex7/code/task2/first.template/greetings.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// general header for all functions in directory
|
||||
|
||||
#ifndef GREETINGS_FILE
|
||||
#define GREETINGS_FILE
|
||||
|
||||
#include <mpi.h>
|
||||
|
||||
/** Each process finds out its host, sends this information
|
||||
to root process 0 which prints this information for each process.
|
||||
@param[in] icomm the MPI process group that is used.
|
||||
*/
|
||||
|
||||
void greetings(MPI_Comm const &icomm);
|
||||
void greetings_cpp(MPI_Comm const &icomm);
|
||||
|
||||
#endif
|
||||
33
ex7/code/task2/first.template/main.cpp
Normal file
33
ex7/code/task2/first.template/main.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// MPI code in C++.
|
||||
// See [Gropp/Lusk/Skjellum, "Using MPI", p.33/41 etc.]
|
||||
// and /opt/mpich/include/mpi2c++/comm.h for details
|
||||
|
||||
#include "greetings.h"
|
||||
#include <iostream> // MPI
|
||||
#include <mpi.h>
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MPI_Comm icomm = MPI_COMM_WORLD;
|
||||
MPI_Init(&argc, &argv);
|
||||
int myrank, numprocs;
|
||||
// numprocs = 1; // delete this line when uncommenting the next line
|
||||
MPI_Comm_rank(icomm, &myrank); // my MPI-rank
|
||||
MPI_Comm_size(icomm, &numprocs);
|
||||
|
||||
if (0==myrank) {
|
||||
cout << "\n There are " << numprocs << " processes running.\n \n";
|
||||
}
|
||||
|
||||
// greetings(icomm);
|
||||
greetings_cpp(icomm);
|
||||
|
||||
if (0==myrank) cout << endl;
|
||||
|
||||
MPI_Finalize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue