# Makefile for the optimize matrix multiply assignment # #CC = gcc #F77 = f77 #OPTFLAGS = -IPF_FMA #CFLAGS = -std=c99 -Dg77Fortran $(OPTFLAGS) #FFLAGS = $(OPTFLAGS) #BLASLIB = -lblas2 /usr/lib/libg2c.so.0 # Alternate: using gcc compiler CC = gcc F77 = g77 OPTFLAGS = -O3 CFLAGS = -std=gnu9x $(OPTFLAGS) ACML_LIB = -lacml -lg2c ACML_LIBDIR = /opt/acml2.1.0/gnu64/lib ACML_INCDIR = /opt/acml2.1.0/include CPPFLAGS = "-DCOMPILER=\"$(CC)\"" "-DFLAGS=\"$(OPTFLAGS)\"" # Add -DDEBUG_RUN to CPPFLAGS to cut down on the cases. # Compile a C version (using basic_dgemm.c, in this case): LIBS = -lm -lrt OBJS = matmul.o timing.o .PHONY: all all: matmul matmul-blocked # --- matmul: $(OBJS) basic_dgemm.o $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) matmul-blocked: $(OBJS) blocked_dgemm.o $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) # An example of using Fortran. matmul-fortran: $(OBJS) fortran_dgemm.o fortran_dgemm_wrapper.o $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) # Platform BLAS, more or less. matmul-blas: $(OBJS) blas_dgemm.o $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) -I$(ACML_INCDIR) -L$(ACML_LIBDIR) $(ACML_LIB) -m64 # Generic Rules %.o:%.f $(F77) -c $(FFLAGS) $< %.o:%.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< # --- # This is just a suggestion on how to generate timing plots... Feel # free to improve on these, so long as you show MFlop/s v. matrix size. # For running outside of Millennium, use # make MILLRUN=env timing MILLRUN = gexec -n 1 timing: matmul $(MILLRUN) `pwd`/matmul > timing.raw perl -ne 'if (/Size:\s+(\S+).*s:\s+(\S+)/) {print "$1 $2\n";}' \ timing.raw > timing .PHONY: display display: timing echo "set term x11;" | gnuplot -persist - timing.gnuplot timing.ps: timing echo "set term postscript; set output 'timing.ps';" \ | gnuplot - timing.gnuplot timing.ppm: timing echo "set term pbm color; set output 'timing.ppm';" \ | gnuplot - timing.gnuplot # --- .PHONY: clean realclean clean: rm -f matmul matmul-blocked matmul-blas matmul-fortran *.o realclean: clean rm -f *~ timing timing.raw timing.ps timing.ppm