homebrew-core/Formula/open-mpi.rb
2019-10-18 02:38:25 -04:00

89 lines
2.7 KiB
Ruby

class OpenMpi < Formula
desc "High performance message passing library"
homepage "https://www.open-mpi.org/"
url "https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.2.tar.bz2"
sha256 "900bf751be72eccf06de9d186f7b1c4b5c2fa9fa66458e53b77778dffdfe4057"
bottle do
sha256 "ac579ec2df32c7cc06b8eed8763acc19ca60c2efcda202a9ed064f160a82d279" => :catalina
sha256 "414093834dd4f424b64131c8af489a4ce2154c104725fff666be34072f5622f0" => :mojave
sha256 "096f28e4f8b2bb81277ce390e6c4b207c3c97d63adf12b00d446d91eae096424" => :high_sierra
end
head do
url "https://github.com/open-mpi/ompi.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "gcc"
depends_on "hwloc"
depends_on "libevent"
conflicts_with "mpich", :because => "both install MPI compiler wrappers"
def install
# otherwise libmpi_usempi_ignore_tkr gets built as a static library
ENV["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version
ENV.cxx11
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--disable-silent-rules
--enable-ipv6
--with-libevent=#{Formula["libevent"].opt_prefix}
--with-sge
]
args << "--with-platform-optimized" if build.head?
system "./autogen.pl" if build.head?
system "./configure", *args
system "make", "all"
system "make", "check"
system "make", "install"
# Fortran bindings install stray `.mod` files (Fortran modules) in `lib`
# that need to be moved to `include`.
include.install Dir["#{lib}/*.mod"]
end
test do
(testpath/"hello.c").write <<~EOS
#include <mpi.h>
#include <stdio.h>
int main()
{
int size, rank, nameLen;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(NULL, NULL);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Get_processor_name(name, &nameLen);
printf("[%d/%d] Hello, world! My name is %s.\\n", rank, size, name);
MPI_Finalize();
return 0;
}
EOS
system bin/"mpicc", "hello.c", "-o", "hello"
system "./hello"
system bin/"mpirun", "./hello"
(testpath/"hellof.f90").write <<~EOS
program hello
include 'mpif.h'
integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
print*, 'node', rank, ': Hello Fortran world'
call MPI_FINALIZE(ierror)
end
EOS
system bin/"mpif90", "hellof.f90", "-o", "hellof"
system "./hellof"
system bin/"mpirun", "./hellof"
end
end