Skip to content

Instantly share code, notes, and snippets.

@tinybike
Last active August 29, 2015 14:06
Show Gist options
  • Save tinybike/a5d96f797ab4a8973f88 to your computer and use it in GitHub Desktop.
Save tinybike/a5d96f797ab4a8973f88 to your computer and use it in GitHub Desktop.
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
// 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