# Makefile for the optimize matrix multiply assignment # #CC = /usr/mill/bin/icc #F77 = /usr/mill/bin/ifort CC = icc F77 = ifort OPTFLAGS = -tpp2 -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) # BLASLIB = -lblas2 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) $(BLASLIB) # 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