Benchmarks for PhD work of Thomas Preud'homme
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

117 lines
4.0 KiB

# Directories
OBJDIR:=obj
BINDIR:=bin
SRCDIR:=src
INCDIR:=include
LIBDIR:=lib
LOGDIR:=logs
LOCALDIR:=$(HOME)/local
CALCDIR:=calculation
COMMDIR:=communication
# Compilation flags
# I know -finline-functions and -finline-functions-called-once are enabled by
# -O3 but I did this in case gcc behaviour change one day
CFLAGS:=-c -O3 -finline-functions -finline-functions-called-once -Wall -Wextra -Werror
LDFLAGS:=-L$(LIBDIR) -lpthread -ldl -lrt
# Executables
CC=gcc
# Files
BINNAMES:=batch_queue_2_comm batch_queue_4_comm batch_queue_8_comm
BINNAMES+=batch_queue_16_comm batch_queue_32_comm batch_queue_64_comm
BINNAMES+=batch_queue_128_comm batch_queue_256_comm batch_queue_512_comm
BINNAMES+=batch_queue_1024_comm batch_queue_2048_comm batch_queue_4096_comm
BINNAMES+=lamport_comm shared_mem_opt_comm none_comm csq_comm csq_2_1_comm
BINNAMES+=csq_2_32_comm csq_2_64_comm csq_64_1_comm fast_forward_comm
BINNAMES+=mcringbuffer_comm pipe_comm gomp_stream_comm gomp_stream_64_comm
#BINNAMES+=jikes_barrier_comm
CALCLIBSNAMES:=calc_mat calc_line calc_useless_loop
BINS:=$(patsubst %,$(BINDIR)/%,$(BINNAMES))
CALCLIBS:=$(patsubst %,$(LIBDIR)/$(CALCDIR)/lib%.so.1,$(CALCLIBSNAMES))
MAIN_OBJS:=main.o
COMMON_LIB_OBJS:=
.PHONY: all tidy clean distclean
.SECONDARY:
.SUFFIXES: .c .o
default: $(BINS) $(CALCLIBS)
# Compilation of binary
$(BINDIR)/%_comm: $(patsubst %,$(OBJDIR)/\%/%,$(MAIN_OBJS)) $(LIBDIR)/$(COMMDIR)/lib%.a
if [ ! -d $(BINDIR) ] ; then mkdir $(BINDIR) ; fi
$(CC) -o $@ $^ $(LDFLAGS)
# Creation of comm library
$(LIBDIR)/$(COMMDIR)/lib%.a: $(OBJDIR)/$(COMMDIR)/%.o $(patsubst %,$(OBJDIR)/$(COMMDIR)/\%/%,$(COMMON_LIB_OBJS))
if [ ! -d $(LIBDIR) ] ; then mkdir $(LIBDIR) ; fi
if [ ! -d $(LIBDIR)/$(COMMDIR) ] ; then mkdir $(LIBDIR)/$(COMMDIR) ; fi
$(AR) -rcus $@ $^
# Creation of calc library
$(LIBDIR)/$(CALCDIR)/libcalc_%.so.1: $(OBJDIR)/$(CALCDIR)/calc_%.o
if [ ! -d $(LIBDIR) ] ; then mkdir $(LIBDIR) ; fi
if [ ! -d $(LIBDIR)/$(CALCDIR) ] ; then mkdir $(LIBDIR)/$(CALCDIR) ; fi
$(CC) -shared -Wl,-soname,libcalc_$*.so.1 -o $@ $<
cd $(@D) ; ln -sf libcalc_$*.so.1 libcalc_$*.so
# Compile lib specific source files
$(OBJDIR)/$(COMMDIR)/%.o: $(SRCDIR)/$(COMMDIR)/%.c $(INCDIR)/%_comm.h $(INCDIR)/commtech.h
if [ ! -d $(OBJDIR) ] ; then mkdir $(OBJDIR) ; fi
if [ ! -d $(OBJDIR)/$(COMMDIR) ] ; then mkdir $(OBJDIR)/$(COMMDIR) ; fi
cd $(INCDIR) ; ln -sfT $*_comm.h specific_comm.h
$(CC) $(CFLAGS) -I$(INCDIR) $< -o $@
# Rule for compiling common source files using libcomm is at the end of
# this file, after the .SECONDEXPANSION target
# Compile source files not using libcomm
$(OBJDIR)/$(CALCDIR)/%.o: $(SRCDIR)/$(CALCDIR)/%.c
if [ ! -d $(OBJDIR) ] ; then mkdir $(OBJDIR) ; fi
if [ ! -d $(OBJDIR)/$(CALCDIR) ] ; then mkdir $(OBJDIR)/$(CALCDIR) ; fi
$(CC) $(CFLAGS) -fPIC -I$(INCDIR) $< -o $@
#.%.d: %.c
# gcc $(CFLAGS) -MM $^ | sed -e 's/\([^:]*\):\(.*\)/\1 $@: \2 Makefile/' > $@
tidy:
rm -f $(SRCDIR)/*~ \#*
clean:
rm -f $(INCDIR)/specific_comm.h
rm -rf $(OBJDIR)
logclean:
rm -rf $(LOGDIR)
distclean: clean
rm -rf $(BINDIR) $(LIBDIR)
#ifneq ($(MAKECMDGOALS),tidy)
#ifneq ($(MAKECMDGOALS),clean)
#ifneq ($(MAKECMDGOALS),distclean)
# If the rules called is not a phony rules, then include the %.d makefile
# corresponding to all objects
#include $(patsubst %.o, .%.d, $(OBJ))
#endif
#endif
#endif
.SECONDEXPANSION:
# Compile common source files using libcomm
$(OBJDIR)/$(COMMDIR)/%.o: $(SRCDIR)/$(COMMDIR)/$$(*F).c $(INCDIR)/$$(*D)_comm.h $(INCDIR)/commtech.h
if [ ! -d $(OBJDIR) ] ; then mkdir $(OBJDIR) ; fi
if [ ! -d $(OBJDIR)/$(COMMDIR) ] ; then mkdir $(OBJDIR)/$(COMMDIR) ; fi
if [ ! -d $(OBJDIR)/$(COMMDIR)/$(*D) ] ; then mkdir $(OBJDIR)/$(COMMDIR)/$(*D) ; fi
cd $(INCDIR) ; ln -sfT $(*D)_comm.h specific_comm.h
$(CC) $(CFLAGS) -I$(INCDIR) $< -o $@
$(OBJDIR)/%.o: $(SRCDIR)/$$(*F).c $(INCDIR)/$$(*D)_comm.h $(INCDIR)/commtech.h
if [ ! -d $(OBJDIR) ] ; then mkdir $(OBJDIR) ; fi
if [ ! -d $(OBJDIR)/$(*D) ] ; then mkdir $(OBJDIR)/$(*D) ; fi
cd $(INCDIR) ; ln -sfT $(*D)_comm.h specific_comm.h
$(CC) $(CFLAGS) -I$(INCDIR) $< -o $@