cs205-lecture-examples

Example codes used during Harvard CS205 lectures
git clone https://git.0xfab.ch/cs205-lecture-examples.git
Log | Files | Refs | README | LICENSE

Makefile (1980B)


      1 include Makefile.defs
      2 
      3 # If CFLAGS_CRAY is empty set it to CFLAGS
      4 ifeq ($(CFLAGS_CRAY),)
      5 CFLAGS_CRAY = ${CFLAGS}
      6 endif
      7 
      8 .c.o:
      9 	${CC} ${CFLAGS} $(OMPFLAG) -c $*.c 
     10 
     11 SYNCOBJS =  syncbench.o common.o 
     12 SCHEDOBJS = schedbench.o common_sched.o 
     13 ARRAYOBJS = arraybench_$(IDA).o common.o 
     14 TASKOBJS =  taskbench.o common.o 
     15 SCHEDFLAGS = -DSCHEDBENCH
     16 
     17 all:	syncbench schedbench taskbench
     18 	$(MAKE) IDA=1 prog
     19 	$(MAKE) IDA=3 prog
     20 	$(MAKE) IDA=9 prog
     21 	$(MAKE) IDA=27 prog
     22 	$(MAKE) IDA=81 prog
     23 	$(MAKE) IDA=243 prog
     24 	$(MAKE) IDA=729 prog
     25 	$(MAKE) IDA=2187 prog
     26 	$(MAKE) IDA=6561 prog
     27 	$(MAKE) IDA=19683 prog
     28 	$(MAKE) IDA=59049 prog
     29 
     30 prog: arraybench_$(IDA) 
     31 
     32 syncbench: $(SYNCOBJS)
     33 	$(CC) -o syncbench $(LDFLAGS) $(SYNCOBJS) $(CLOCKOBJS) $(LIBS) -lm
     34 
     35 # Rule to ensure the lower optimisation level is picked up for common.c 
     36 # with the Cray compiler
     37 common.o:	
     38 	${CC} ${CFLAGS_CRAY} $(OMPFLAG) -c $*.c 
     39 
     40 # Separate rule to build common_sched.o as we need to ensure the correct 
     41 # DEFAULT_DELAY_TIME is used. 
     42 common_sched.o:	
     43 	${CC} ${CFLAGS_CRAY} $(SCHEDFLAGS) $(OMPFLAG) -o common_sched.o -c common.c
     44 
     45 schedbench: $(SCHEDOBJS)
     46 	$(CC) -o schedbench  $(LDFLAGS) $(SCHEDOBJS) $(CLOCKOBJS) $(LIBS) -lm 
     47 
     48 # Multiple header files due to multiple array sizes, makes header file arraybench_*.h
     49 arraybench_$(IDA).h: arraybench.h
     50 	$(CPP) -DIDA=$(IDA) $(OMPFLAG) -P arraybench.h -o $@
     51 
     52 # Multiple object files due to multiple array sizes, makes object file arraybench_*.o
     53 arraybench_$(IDA).o: arraybench_$(IDA).h arraybench.c
     54 	$(CC) $(CFLAGS) -DIDA=$(IDA) $(OMPFLAG) arraybench.c -c -o $@
     55 
     56 # Multiple executables due to multiple array sizes, makes exe file arraybench_*
     57 arraybench_$(IDA): $(ARRAYOBJS) $(CLOCKOBJS) arraybench.c
     58 	$(CC) $(LDFLAGS) $(ARRAYOBJS) $(CLOCKOBJS) $(LIBS) -lm -o $@ 
     59 
     60 taskbench: $(TASKOBJS)
     61 	$(CC) -o taskbench $(LDFLAGS) $(OMPFLAG) $(TASKOBJS) $(CLOCKOBJS) $(LIBS) -lm 
     62 
     63 clean: 
     64 	-rm *.o syncbench schedbench arraybench_* taskbench
     65 
     66 clean-all: clean 	
     67 	-rm OpenMPBench.* *.all
     68 
     69