From 21ce87d1f026b2fb3d3de3b9c7bbe58a872a7c2d Mon Sep 17 00:00:00 2001 From: "James A. Ross" Date: Wed, 20 Dec 2017 22:04:12 +0000 Subject: [PATCH] Updating makefiles to improve run/check process --- Makefile | 40 +++++++++++++++++++++++++++ example/Makefile | 14 +++++++++- example/c_conjugate_gradient/Makefile | 6 ++++ example/c_diag_spmv/Makefile | 5 +++- example/c_dynamic_calls/Makefile | 5 ++++ example/c_gups/Makefile | 3 ++ example/c_nbody/Makefile | 3 ++ example/e_hello/Makefile | 3 ++ src/Makefile | 2 ++ test/Makefile | 2 +- 10 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b8303b7 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +SUBDIRS = src example test + +COPRCC := $(shell command -v coprcc 2> /dev/null) +ifndef COPRCC +$(warning Building libshmem_esdk.a without COPRTHR-2 SDK!) +SUBDIRS = src +endif + +.PHONY: all $(SUBDIRS) check run clean distclean + +all: $(SUBDIRS) + +src: +ifndef COPRCC + $(MAKE) -C src -f Makefile.esdk +else + $(MAKE) -C src +endif + +# dependencies on libshmem +example: src +test: src + +check: src + $(MAKE) -C test check; + +run: all + for d in $(SUBDIRS); do \ + $(MAKE) -C $$d run; \ + done + +clean: + for d in $(SUBDIRS); do \ + $(MAKE) -C $$d clean; \ + done + +distclean: + for d in $(SUBDIRS); do \ + $(MAKE) -C $$d distclean; \ + done diff --git a/example/Makefile b/example/Makefile index 33f7d99..b4f0a75 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,4 +1,5 @@ -SUBDIRS := $(wildcard */.) +SUBDIRS_ = $(wildcard */.) +SUBDIRS = $(SUBDIRS_:/.=) .PHONY: all $(SUBDIRS) clean distclean @@ -7,6 +8,17 @@ all: $(SUBDIRS) $(SUBDIRS): $(MAKE) -C $@ +run: $(SUBDIRS) + @$(foreach x,$(SUBDIRS), \ + printf '\n======================= ' && \ + printf '%0.30s' '$x =========================' && \ + printf '==========================\n' && \ + cd $x && \ + $(MAKE) -s run 2> /dev/null && \ + cd .. && \ + ) printf '\n' + + clean: for d in $(SUBDIRS); do \ $(MAKE) -C $$d clean; \ diff --git a/example/c_conjugate_gradient/Makefile b/example/c_conjugate_gradient/Makefile index 50a8c7d..aa89861 100644 --- a/example/c_conjugate_gradient/Makefile +++ b/example/c_conjugate_gradient/Makefile @@ -18,6 +18,9 @@ TARGETS = main.x $(KERNEL) all: $(TARGETS) +run: main.x + ./$< + .PHONY: clean distclean .SUFFIXES: @@ -26,6 +29,9 @@ all: $(TARGETS) main.x: main.c $(CC) $(CFLAGS) $(INCS) main.c -o main.x $(LIBS) +foo.x: foo.c + $(CC) $(CFLAGS) $(INCS) foo.c -o foo.x $(LIBS) + shmem_tfunc.e32: shmem_tfunc.c dotprod.o coprcc $(INCS) $(EDEFS) $(ELIBS) shmem_tfunc.c dotprod.o -o shmem_tfunc.e32 diff --git a/example/c_diag_spmv/Makefile b/example/c_diag_spmv/Makefile index 400970a..8de6ff3 100644 --- a/example/c_diag_spmv/Makefile +++ b/example/c_diag_spmv/Makefile @@ -9,12 +9,15 @@ SHMEM = ../../src INCS = -I. -I$(COPRTHR)/include -I$(SHMEM) -I../../common LIBS = -L$(COPRTHR)/lib -lcoprthr -lcoprthrcc -lm -ELIBS = -L$(COPRTHR)/lib -lcoprthr_mpi -lcoprthr2_dev -L$(SHMEM) -lshmem_coprthr +ELIBS = -L$(COPRTHR)/lib -lcoprthr2_dev -L$(SHMEM) -lshmem_coprthr TARGET = main.x shmem_tfunc.e32 all: $(TARGET) +run: main.x + ./$< + .PHONY: clean install uninstall $(SUBDIRS) .SUFFIXES: diff --git a/example/c_dynamic_calls/Makefile b/example/c_dynamic_calls/Makefile index 9a9da5c..e4c5988 100644 --- a/example/c_dynamic_calls/Makefile +++ b/example/c_dynamic_calls/Makefile @@ -14,6 +14,11 @@ TARGETS = $(SRC_FILES:.c=.x) all: $(TARGETS) +run: all + @$(foreach x,$(TARGETS), \ + ./run.sh \ + ) + info: all $(OBJ_FILES) .PHONY: clean install uninstall diff --git a/example/c_gups/Makefile b/example/c_gups/Makefile index 8c8c1ff..9b799b3 100644 --- a/example/c_gups/Makefile +++ b/example/c_gups/Makefile @@ -17,6 +17,9 @@ TARGETS = main.x $(KERNEL) all: $(TARGETS) +run: main.x + ./$< + .PHONY: clean distclean .SUFFIXES: diff --git a/example/c_nbody/Makefile b/example/c_nbody/Makefile index 4b8f1d0..e05a712 100644 --- a/example/c_nbody/Makefile +++ b/example/c_nbody/Makefile @@ -15,6 +15,9 @@ TARGET = main.x shmem_tfunc.e32 shmem_tfunc2.e32 all: $(TARGET) +run: main.x + ./$< + .PHONY: clean install uninstall $(SUBDIRS) .SUFFIXES: diff --git a/example/e_hello/Makefile b/example/e_hello/Makefile index 384ab7d..0711144 100644 --- a/example/e_hello/Makefile +++ b/example/e_hello/Makefile @@ -16,6 +16,9 @@ OBJS = main.x e_task.elf all: $(OBJS) +run: main.x + ./$< + # Build HOST side application .c.x: gcc -O3 $< -o $@ $(EINCS) $(ELIBS) -lpthread diff --git a/src/Makefile b/src/Makefile index 5012fac..8d1dfb9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,6 +14,8 @@ OBJS = $(SRC_FILES:.c=.o) $(ASM_FILES:.S=.o) all: $(TARGETS) +run: + .PHONY: clean install uninstall .SUFFIXES: diff --git a/test/Makefile b/test/Makefile index 60be2c2..952463d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -82,7 +82,7 @@ report.pdf: figures version.dat git.dat pes.dat report.tex run: $(TARGETS) @$(foreach x,$(TARGETS),coprsh -np $(CORES) ./$(x) 2> /dev/null &&) echo "Complete" -test: $(TARGETS) +check: $(TARGETS) @$(foreach x,$(TARGETS), \ $(foreach n,$(NP), \ printf "%-3d%-27.27s " $(n) "$(x) .........................." && coprsh -np $(n) ./$(x) 2> /dev/null | \