Last active
August 29, 2015 14:06
-
-
Save tinybike/a5d96f797ab4a8973f88 to your computer and use it in GitHub Desktop.
Makefile for boost mpi test (from http://particlephysicsandcode.com/2013/03/11/installing-boost-1-52-ubuntu-12-04-fedora/)
This file contains 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
CC = mpic++ | |
CXXFLAGS = -g -W -Wall -Werror | |
LIBS = -lboost_mpi -lboost_serialization -lboost_system -lboost_filesystem -lboost_graph_parallel -lboost_iostreams | |
all: Boost | |
Boost: Boost.o | |
$(CC) $(CXXFLAGS) -o Boost Boost.o $(LIBS) | |
Boost.o: Boost.cpp | |
$(CC) $(CXXFLAGS) -c Boost.cpp | |
clean: | |
$(RM) Boost Boost.o |
This file contains 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
// M. Reid - Boost.cpp - Test of boost mpi interface | |
#include <iostream> | |
// The boost headers | |
#include "boost/mpi.hpp" | |
int main(int argc, char* argv[]) | |
{ | |
// Allows you to query the MPI environment | |
boost::mpi::environment env(argc, argv); | |
std::string processor_name(env.processor_name()); | |
// permits communication and synchronization among a set of processes | |
boost::mpi::communicator world; | |
unsigned int rank(world.rank()), numprocessors(world.size()); | |
if (rank == 0) { | |
std::cout << "Processor name: " << processor_name << "\n"; | |
std::cout << "Master (" << rank << "/" << numprocessors << ")\n"; | |
} else { | |
std::cout << "Slave (" << rank << "/" << numprocessors << ")\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment