-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
Copy pathopen-mpi.rb
164 lines (144 loc) · 5.76 KB
/
open-mpi.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class OpenMpi < Formula
desc "High performance message passing library"
homepage "https://www.open-mpi.org/"
url "https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.7.tar.bz2"
sha256 "119f2009936a403334d0df3c0d74d5595a32d99497f9b1d41e90019fee2fc2dd"
license "BSD-3-Clause"
livecheck do
url :homepage
regex(/MPI v?(\d+(?:\.\d+)+) release/i)
end
bottle do
sha256 arm64_sequoia: "29d2b61321a1b307229996e2a8cc6ad9f502bc1aeb32851bdc4b4baee8c90385"
sha256 arm64_sonoma: "850bb2b559721fb00e5f4df1e545940b504fd4ac2594b0be223c06915d66a20c"
sha256 arm64_ventura: "4adde9da7b928971c0204baa3d22015b2e593bea4bd382a070b0feeea7a53b74"
sha256 sonoma: "b3649a0c27cc4b8dc7dd12afeb0f4ef771add7edcc915552380ae960d95b3a12"
sha256 ventura: "20e6dd96c8535dceffb1fef0943a780d23c129f8ecb88b1e84b0d98db8048d0c"
sha256 arm64_linux: "8457a4d6716736c3c58fe9f2b34f1e4205e20e0ffb42e21071b1264d9820f173"
sha256 x86_64_linux: "35c717284633ea4e0524d2efa8bd9ad3e88809a5c5cbb7fb71eee5eede885bf5"
end
head do
url "https://github.com/open-mpi/ompi.git", branch: "main"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "gcc" # for gfortran
depends_on "hwloc"
depends_on "libevent"
depends_on "pmix"
conflicts_with "mpich", because: "both install MPI compiler wrappers"
def install
ENV.runtime_cpu_detection
# Otherwise libmpi_usempi_ignore_tkr gets built as a static library
ENV["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version if OS.mac?
# Remove bundled copies of libraries that shouldn't be used
unbundled_packages = %w[hwloc libevent openpmix].join(",")
rm_r Dir["3rd-party/{#{unbundled_packages}}*"]
# Avoid references to the Homebrew shims directory
inreplace_files = %w[
ompi/tools/ompi_info/param.c
oshmem/tools/oshmem_info/param.c
]
cxx = OS.linux? ? "g++" : ENV.cxx
cc = OS.linux? ? "gcc" : ENV.cc
inreplace inreplace_files, "OMPI_CXX_ABSOLUTE", "\"#{cxx}\""
inreplace inreplace_files, "OPAL_CC_ABSOLUTE", "\"#{cc}\""
inreplace "3rd-party/prrte/src/tools/prte_info/param.c", "PRTE_CC_ABSOLUTE", "\"#{cc}\""
args = %W[
--disable-silent-rules
--enable-ipv6
--enable-mca-no-build=reachable-netlink
--sysconfdir=#{etc}
--with-hwloc=#{Formula["hwloc"].opt_prefix}
--with-libevent=#{Formula["libevent"].opt_prefix}
--with-pmix=#{Formula["pmix"].opt_prefix}
--with-sge
]
if build.head?
args << "--with-platform-optimized"
system "./autogen.pl", "--force", "--no-3rdparty=#{unbundled_packages}"
end
system "./configure", *args, *std_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 lib.glob("*.mod")
# Avoid references to cellar paths.
inreplace (lib/"pkgconfig").glob("*.pc"), prefix, opt_prefix, audit_result: false
# Avoid conflict with `putty` by renaming pterm to prte-term which matches
# upstream change[^1]. In future release, we may want to split out `prrte`
# to a separate formula and pass `--without-legacy-names`[^2].
#
# [^1]: https://github.com/openpmix/prrte/issues/1836#issuecomment-2564882033
# [^2]: https://github.com/openpmix/prrte/blob/master/config/prte_configure_options.m4#L390-L393
odie "Update configure for PRRTE or split to separate formula as prte-term exists" if (bin/"prte-term").exist?
bin.install bin/"pterm" => "prte-term"
man1.install man1/"pterm.1" => "prte-term.1"
end
test do
(testpath/"hello.c").write <<~'C'
#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;
}
C
system bin/"mpicc", "hello.c", "-o", "hello"
system "./hello"
system bin/"mpirun", "./hello"
(testpath/"hellof.f90").write <<~FORTRAN
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
FORTRAN
system bin/"mpifort", "hellof.f90", "-o", "hellof"
system "./hellof"
system bin/"mpirun", "./hellof"
(testpath/"hellousempi.f90").write <<~FORTRAN
program hello
use mpi
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
FORTRAN
system bin/"mpifort", "hellousempi.f90", "-o", "hellousempi"
system "./hellousempi"
system bin/"mpirun", "./hellousempi"
(testpath/"hellousempif08.f90").write <<~FORTRAN
program hello
use mpi_f08
integer rank, size, tag, status(MPI_STATUS_SIZE)
call MPI_INIT()
call MPI_COMM_SIZE(MPI_COMM_WORLD, size)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank)
print*, 'node', rank, ': Hello Fortran world'
call MPI_FINALIZE()
end
FORTRAN
system bin/"mpifort", "hellousempif08.f90", "-o", "hellousempif08"
system "./hellousempif08"
system bin/"mpirun", "./hellousempif08"
end
end