Skip to content

Instantly share code, notes, and snippets.

@Mattamorphic
Last active February 13, 2020 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mattamorphic/d2067ecaaa425419c01408aea3cf4852 to your computer and use it in GitHub Desktop.
Save Mattamorphic/d2067ecaaa425419c01408aea3cf4852 to your computer and use it in GitHub Desktop.
Reusable makefile to use with Vagrant Open-MPI cluster
##
# Reusable Makefile
#
# usage: `make [PROCESS] TARGET=[FILENAME_NO_EXT] NODES=node1,node2,node3`
# example: `make all TARGET=hello-world NODES=node1,node2,node3`
COMPILER=mpic++
COMPILER_FLAGS=-g -std=c++0x -O0
OBJECTS=$(TARGET).o
HOSTS=--host $(NODES)
PROCESS_COUNT = -np $(shell echo $(NODES), | grep -o "," | wc -l)
SUFFIXES: .cpp .o
all: $(OBJECTS)
$(COMPILER) -o $(TARGET) $(OBJECTS)
clean:
rm $(OBJECTS) $(TARGET)
.cpp.o:
$(COMPILER) $(COMPILER_FLAGS) -c $*.cpp
run:
mpirun --mca btl_tcp_if_exclude lo,eth0 $(PROCESS_COUNT) $(HOSTS) $(TARGET)
build-and-run: all run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment