Last active
February 13, 2020 11:46
-
-
Save Mattamorphic/d2067ecaaa425419c01408aea3cf4852 to your computer and use it in GitHub Desktop.
Reusable makefile to use with Vagrant Open-MPI cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | |
| # 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