From deca68407afd053776d25997118050a5509375c8 Mon Sep 17 00:00:00 2001 From: test2 Date: Wed, 17 Jun 2020 22:20:27 +0300 Subject: [PATCH] examples --- examples/Makefile | 51 +++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 8940ce4..eb2ed3d 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,24 +1,37 @@ -all: config install log - - DIRhosts=/home/ubuntu/hosts -DIR=/home/ubuntu/ -swarmlab-getworkers > $(DIRhosts) +DIR=/home/ubuntu +options=-env I_MPI_DEBUG=3 +number=10 + +ex= -helloworld: - @mpicc -o $(DIR)/mpi_hello_world ./mpi_hello_world.c ; \ - cat $DIRhosts | while read -r line ; \ - do \ - scp $(DIR)/mpi_hello_world ubuntu@$(line):$(DIR)/mpi_hello_world ; \ - done \ - mpirun -n 10 -f $(DIRhosts) $(DIR)/mpi_hello_world 2>&1 | tee /tmp/output.log ; \ +all: mpi_hello_world example +.PHONY: all +mpi_hello_world: + @swarmlab-getworkers > $(DIRhosts) ;\ + mpicc ./mpi_hello_world.c -o $(DIR)/mpi_hello_world ;\ + while read line; do\ + echo "scp $(DIR)/mpi_hello_world ubuntu@$$line:$(DIR)/mpi_hello_world " ;\ + scp $(DIR)/mpi_hello_world ubuntu@$$line:$(DIR)/mpi_hello_world ;\ + echo "$$line" ;\ + done < $(DIRhosts);\ + echo "mpirun $(options) -wdir=$(DIR) -n $(number) -f $(DIRhosts) $(DIR)/mpi_hello_world" ; \ + mpirun $(options) -wdir=$(DIR) -n $(number) -f $(DIRhosts) $(DIR)/mpi_hello_world -cpi: - @mpicc -o $(DIR)/cpi ./cpi.c ; \ - cat $(DIRhosts) | while read -r line ; \ - do \ - scp $(DIR)/cpi ubuntu@$(line):$(DIR)/cpi.c ; \ - done \ - mpirun -n 10 -f $(DIRhosts) $(DIR)/cpi 2>&1 | tee /tmp/output.log ; \ +example: + @if [ ! -z $(ex) ]; then\ + swarmlab-getworkers > $(DIRhosts) ;\ + mpicc ./$(ex).c -o $(DIR)/$(ex) ;\ + while read line; do\ + echo "scp $(DIR)/$(ex) ubuntu@$$line:$(DIR)/$(ex) " ;\ + scp $(DIR)/$(ex) ubuntu@$$line:$(DIR)/$(ex) ;\ + echo "$$line" ;\ + done < $(DIRhosts);\ + echo "mpirun $(options) -wdir=$(DIR) -n $(number) -f $(DIRhosts) $(DIR)/$(ex)" ; \ + mpirun $(options) -wdir=$(DIR) -n $(number) -f $(DIRhosts) $(DIR)/$(ex) ; \ + else\ + echo "usage: make example ex=source file" ; \ + echo "e.g.: make example ex=mv" ; \ + fi\