# # Open Systems Laboratory # http://www.lam-mpi.org/tutorials/ # Indiana University # # MPI Tutorial # Sample Makefile # # # Some conveniences # If you need any -I or -L flags for the tiff library, put them here # TIFFLDFLAGS = TIFFCFLAGS = # # Set the compilers and associated flags # CC = mpicc CXX = mpiCC F77 = mpif77 OPTFLAGS = DEBUGFLAGS = CFLAGS = $(OPTFLAGS) $(DEBUGFLAGS) $(TIFFCFLAGS) FFLAGS = $(OPTFLAGS) $(DEBUGFLAGS) $(TIFFCFLAGS) LDFLAGS = $(OPTFLAGS) $(DEBUGFLAGS) PROGRAMS = lab1c lab1cc lab1f \ lab2c lab2cc lab2f \ imageproc-c imageproc-cc imageproc-f \ average-c average-cc average-f \ dtypes-c dtypes-cc dtypes-f \ overlap-c overlap-cc overlap-f \ hier_comm-c hier_comm-cc hier_comm-f # # Targets, in order of appearance # default: @ echo "" @ echo "You must specify which target to make:" @ echo " lab1c, lab1cc, lab1f" @ echo " lab2c, lab2cc, lab2f" @ echo " imageproc-c, imageproc-cc, imageproc-f" @ echo " average-c, average-cc, average-f" @ echo " pring-c, pring-cc, pring-f" @ echo " dtypes-c, dtypes-cc, dtypes-f" @ echo " overlap-c, overlap-cc, overlap-f" @ echo "" all: lab1c lab1cc lab1f \ lab2c lab2cc lab2f \ imageproc-c imageproc-cc imageproc-f \ average-c average-cc average-f \ pring-c pring-cc pring-f \ dtypes-c dtypes-cc dtypes-f \ overlap-c overlap-cc overlap-f # # Lab number 1: Hello world # lab1: default lab1c: lab1.c $(CC) $(CFLAGS) lab1.c -o lab1c lab1cc: lab1.cc $(CXX) $(CFLAGS) lab1.cc -o lab1cc lab1f: lab1.f $(F77) $(FFLAGS) lab1.f -o lab1f # # Lab number 2: The cannonical ring program # lab2: default lab2c: lab2.c $(CC) $(CFLAGS) lab2.c -o lab2c lab2cc: lab2.cc $(CXX) $(CFLAGS) lab2.cc -o lab2cc lab2f: lab2.f $(F77) $(FFLAGS) lab2.f -o lab2f # # Lab: Image processing -- sum of squares # imageproc: default image.o: image.c $(CC) $(CFLAGS) image.c -c imageproc-c: imageproc.c image.o $(CC) $(CFLAGS) imageproc.c -o imageproc-c \ image.o $(TIFFLDFLAGS) -ltiff -lm imageproc-cc: imageproc.cc image.o $(CXX) $(CFLAGS) imageproc.cc -o imageproc-cc \ image.o $(TIFFLDFLAGS) -ltiff -lm imageproc-f: imageproc.f image.o $(F77) $(FFLAGS) imageproc.f -o imageproc-f \ image.o $(TIFFLDFLAGS) -ltiff -lm # # Homework: Manager/worker (calculate an average in parallel) # average: default average-c: average.c $(CC) $(CFLAGS) average.c -o average-c average-cc: average.cc $(CXX) $(CFLAGS) average.cc -o average-cc average-f: average.f $(F77) $(FFLAGS) average.f -o average-f # # Homework: Persistent Communication (make the ring program persistent) # pring: default pring-c: pring.c $(CC) $(CFLAGS) pring.c -o pring-c pring-cc: pring.cc $(CXX) $(CFLAGS) pring.cc -o pring-cc pring-f: pring.f $(F77) $(FFLAGS) pring.f -o pring-f # # Lab: Datatypes # dtypes: default dtypes-c: dtypes.c $(CC) $(CFLAGS) dtypes.c -o dtypes-c dtypes-cc: dtypes.cc $(CXX) $(CFLAGS) dtypes.cc -o dtypes-cc dtypes-f: dtypes.f $(F77) $(FFLAGS) dtypes.f -o dtypes-f # # Lab: Overlapping Comm. and Comp. # overlap: default overlap-c: overlap.c $(CC) $(CFLAGS) overlap.c -o overlap-c overlap-cc: overlap.cc $(CXX) $(CFLAGS) overlap.cc -o overlap-cc overlap-f: overlap.f $(F77) $(FFLAGS) overlap.f -o overlap-f # # Lab: Hierarchical Communications (matrix with rows and columns) # hier_comm: default hier_comm-c: hier_comm.c $(CC) $(CFLAGS) hier_comm.c -o hier_comm-c hier_comm-cc: hier_comm.cc $(CXX) $(CFLAGS) hier_comm.cc -o hier_comm-cc hier_comm-f: hier_comm.f $(F77) $(FFLAGS) hier_comm.f -o hier_comm-f # # Other nice thingys # clean: rm -f *% *~ core *.o $(PROGRAMS)