2017-02-03 11:20:45 +00:00
|
|
|
class BoostMpi < Formula
|
|
|
|
desc "C++ library for C++/MPI interoperability"
|
|
|
|
homepage "https://www.boost.org/"
|
|
|
|
url "https://downloads.sourceforge.net/project/boost/boost/1.63.0/boost_1_63_0.tar.bz2"
|
|
|
|
sha256 "beae2529f759f6b3bf3f4969a19c2e9d6f0c503edcb2de4a61d1428519fcb3b0"
|
|
|
|
head "https://github.com/boostorg/boost.git"
|
|
|
|
|
2017-02-11 11:27:03 +00:00
|
|
|
bottle do
|
|
|
|
sha256 "6d177c60f72c4182d72e7ebff037edd4ec25520b090fba74a617cf6c596524bd" => :sierra
|
|
|
|
sha256 "e5ddc5c4b9362352c63e46f1af46e6b1eb2269972a954afa0e7b4b484f3564aa" => :el_capitan
|
|
|
|
sha256 "d758f5b2305f113f8be1d423a23e7486e2c30a931592613db2b756d3223d6a2b" => :yosemite
|
|
|
|
end
|
|
|
|
|
2017-02-03 11:20:45 +00:00
|
|
|
option :cxx11
|
|
|
|
|
|
|
|
if build.cxx11?
|
|
|
|
depends_on "boost" => "c++11"
|
|
|
|
depends_on "open-mpi" => "c++11"
|
|
|
|
else
|
|
|
|
depends_on "boost"
|
|
|
|
depends_on :mpi => [:cc, :cxx]
|
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
|
|
|
# "layout" should be synchronized with boost
|
|
|
|
args = ["--prefix=#{prefix}",
|
|
|
|
"--libdir=#{lib}",
|
|
|
|
"-d2",
|
|
|
|
"-j#{ENV.make_jobs}",
|
|
|
|
"--layout=tagged",
|
|
|
|
"--user-config=user-config.jam",
|
|
|
|
"threading=multi,single",
|
|
|
|
"link=shared,static"]
|
|
|
|
|
|
|
|
# Build in C++11 mode if boost was built in C++11 mode.
|
|
|
|
# Trunk starts using "clang++ -x c" to select C compiler which breaks C++11
|
|
|
|
# handling using ENV.cxx11. Using "cxxflags" and "linkflags" still works.
|
|
|
|
if build.cxx11?
|
|
|
|
args << "cxxflags=-std=c++11"
|
|
|
|
if ENV.compiler == :clang
|
|
|
|
args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++"
|
|
|
|
end
|
|
|
|
elsif Tab.for_name("boost").cxx11?
|
|
|
|
odie "boost was built in C++11 mode so boost-mpi must be built with --c++11."
|
|
|
|
end
|
|
|
|
|
|
|
|
open("user-config.jam", "a") do |file|
|
|
|
|
file.write "using darwin : : #{ENV.cxx} ;\n"
|
|
|
|
file.write "using mpi ;\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
system "./bootstrap.sh", "--prefix=#{prefix}", "--libdir=#{lib}", "--with-libraries=mpi"
|
|
|
|
|
|
|
|
system "./b2", *args
|
|
|
|
|
|
|
|
lib.install Dir["stage/lib/*mpi*"]
|
|
|
|
|
|
|
|
# libboost_mpi links to libboost_serialization, which comes from the main boost formula
|
|
|
|
boost = Formula["boost"]
|
|
|
|
MachO::Tools.change_install_name("#{lib}/libboost_mpi-mt.dylib",
|
|
|
|
"libboost_serialization-mt.dylib",
|
|
|
|
"#{boost.lib}/libboost_serialization-mt.dylib")
|
|
|
|
MachO::Tools.change_install_name("#{lib}/libboost_mpi.dylib",
|
|
|
|
"libboost_serialization.dylib",
|
|
|
|
"#{boost.lib}/libboost_serialization.dylib")
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
(testpath/"test.cpp").write <<-EOS.undent
|
|
|
|
#include <boost/mpi.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
#include <boost/serialization/string.hpp>
|
|
|
|
namespace mpi = boost::mpi;
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
mpi::environment env(argc, argv);
|
|
|
|
mpi::communicator world;
|
|
|
|
|
|
|
|
if (world.rank() == 0) {
|
|
|
|
world.send(1, 0, std::string("Hello"));
|
|
|
|
std::string msg;
|
|
|
|
world.recv(1, 1, msg);
|
|
|
|
std::cout << msg << "!" << std::endl;
|
|
|
|
} else {
|
|
|
|
std::string msg;
|
|
|
|
world.recv(0, 0, msg);
|
|
|
|
std::cout << msg << ", ";
|
|
|
|
std::cout.flush();
|
|
|
|
world.send(0, 1, std::string("world"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
boost = Formula["boost"]
|
|
|
|
system "mpic++", "test.cpp", "-L#{lib}", "-L#{boost.lib}", "-lboost_mpi", "-lboost_serialization", "-o", "test"
|
|
|
|
system "mpirun", "-np", "2", "./test"
|
|
|
|
end
|
|
|
|
end
|