mpi.scm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014, 2015, 2018, 2019 Eric Bavier <bavier@member.fsf.org>
  3. ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
  5. ;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
  6. ;;; Copyright © 2017 Dave Love <fx@gnu.org>
  7. ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
  8. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  9. ;;; Copyright © 2018 Paul Garlick <pgarlick@tourbillion-technology.com>
  10. ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
  11. ;;;
  12. ;;; This file is part of GNU Guix.
  13. ;;;
  14. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  15. ;;; under the terms of the GNU General Public License as published by
  16. ;;; the Free Software Foundation; either version 3 of the License, or (at
  17. ;;; your option) any later version.
  18. ;;;
  19. ;;; GNU Guix is distributed in the hope that it will be useful, but
  20. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. ;;; GNU General Public License for more details.
  23. ;;;
  24. ;;; You should have received a copy of the GNU General Public License
  25. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  26. (define-module (gnu packages mpi)
  27. #:use-module (guix packages)
  28. #:use-module ((guix licenses)
  29. #:hide (expat))
  30. #:use-module (guix download)
  31. #:use-module (guix utils)
  32. #:use-module (guix build-system gnu)
  33. #:use-module (guix build-system python)
  34. #:use-module (gnu packages)
  35. #:use-module (gnu packages fabric-management)
  36. #:use-module (gnu packages gcc)
  37. #:use-module (gnu packages libevent)
  38. #:use-module (gnu packages linux)
  39. #:use-module (gnu packages pciutils)
  40. #:use-module (gnu packages xorg)
  41. #:use-module (gnu packages gtk)
  42. #:use-module (gnu packages xml)
  43. #:use-module (gnu packages perl)
  44. #:use-module (gnu packages ncurses)
  45. #:use-module (gnu packages parallel)
  46. #:use-module (gnu packages pkg-config)
  47. #:use-module (gnu packages valgrind)
  48. #:use-module (srfi srfi-1)
  49. #:use-module (ice-9 match))
  50. (define-public hwloc
  51. ;; Note: For now we keep 1.x as the default because many packages have yet
  52. ;; to migrate to 2.0.
  53. (package
  54. (name "hwloc")
  55. (version "1.11.12")
  56. (source (origin
  57. (method url-fetch)
  58. (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
  59. (version-major+minor version)
  60. "/downloads/hwloc-" version ".tar.bz2"))
  61. (sha256
  62. (base32
  63. "0za1b9lvrm3rhn0lrxja5f64r0aq1qs4m0pxn1ji2mbi8ndppyyx"))))
  64. (build-system gnu-build-system)
  65. (outputs '("out" ;'lstopo' & co., depends on Cairo, libx11, etc.
  66. "lib" ;small closure
  67. "debug"))
  68. (inputs
  69. `(("libx11" ,libx11)
  70. ("cairo" ,cairo)
  71. ("ncurses" ,ncurses)
  72. ("expat" ,expat)
  73. ,@(if (not (string-prefix? "armhf"
  74. (or (%current-target-system)
  75. (%current-system))))
  76. `(("numactl" ,numactl))
  77. '())))
  78. (propagated-inputs
  79. ;; hwloc.pc lists it in 'Requires.private'.
  80. `(("libpciaccess" ,libpciaccess)))
  81. (native-inputs
  82. `(("pkg-config" ,pkg-config)))
  83. (arguments
  84. `(#:configure-flags '("--localstatedir=/var")
  85. #:phases
  86. (modify-phases %standard-phases
  87. (add-before 'check 'skip-linux-libnuma-test
  88. (lambda _
  89. ;; Arrange to skip 'tests/linux-libnuma', which fails on some
  90. ;; machines: <https://github.com/open-mpi/hwloc/issues/213>.
  91. (substitute* "tests/linux-libnuma.c"
  92. (("numa_available\\(\\)")
  93. "-1"))
  94. #t))
  95. (add-after 'install 'refine-libnuma
  96. ;; Give -L arguments for libraries to avoid propagation
  97. (lambda* (#:key inputs outputs #:allow-other-keys)
  98. (let ((out (assoc-ref outputs "lib"))
  99. (numa (assoc-ref inputs "numactl")))
  100. (substitute* (map (lambda (f) (string-append out "/" f))
  101. '("lib/pkgconfig/hwloc.pc" "lib/libhwloc.la"))
  102. (("-lnuma" lib)
  103. (string-append "-L" numa "/lib " lib))))))
  104. (add-after 'install 'avoid-circular-references
  105. (lambda* (#:key outputs #:allow-other-keys)
  106. (let ((lib (assoc-ref outputs "lib")))
  107. ;; Suppress the 'prefix=' and 'exec_prefix=' lines so that the
  108. ;; "lib" output doesn't refer to "out".
  109. (substitute* (string-append lib "/lib/pkgconfig/hwloc.pc")
  110. (("^.*prefix=.*$")
  111. ""))
  112. #t))))))
  113. (home-page "https://www.open-mpi.org/projects/hwloc/")
  114. (synopsis "Abstraction of hardware architectures")
  115. (description
  116. "hwloc provides a portable abstraction (across OS,
  117. versions, architectures, ...) of the hierarchical topology of modern
  118. architectures, including NUMA memory nodes, sockets, shared caches, cores and
  119. simultaneous multithreading. It also gathers various attributes such as cache
  120. and memory information. It primarily aims at helping high-performance
  121. computing applications with gathering information about the hardware so as to
  122. exploit it accordingly and efficiently.
  123. hwloc may display the topology in multiple convenient formats. It also offers
  124. a powerful programming interface to gather information about the hardware,
  125. bind processes, and much more.")
  126. (license bsd-3)))
  127. (define-public hwloc-2.0
  128. ;; Note: 2.0 isn't the default yet, see above.
  129. (package
  130. (inherit hwloc)
  131. (version "2.0.3")
  132. (source (origin
  133. (method url-fetch)
  134. (uri (string-append "https://www.open-mpi.org/software/hwloc/v"
  135. (version-major+minor version)
  136. "/downloads/hwloc-" version ".tar.bz2"))
  137. (sha256
  138. (base32
  139. "09f7ajak8wv5issr0hw72vs3jkldc7crcc7z5fd34sspkvrsm4z3"))))
  140. ;; libnuma is no longer needed.
  141. (inputs (alist-delete "numactl" (package-inputs hwloc)))
  142. (arguments
  143. (substitute-keyword-arguments (package-arguments hwloc)
  144. ((#:phases phases)
  145. `(modify-phases ,phases
  146. (replace 'skip-linux-libnuma-test
  147. (lambda _
  148. ;; Arrange to skip 'tests/hwloc/linux-libnuma', which fails on
  149. ;; some machines: <https://github.com/open-mpi/hwloc/issues/213>.
  150. (substitute* "tests/hwloc/linux-libnuma.c"
  151. (("numa_available\\(\\)")
  152. "-1"))
  153. #t))))))))
  154. (define-public openmpi
  155. (package
  156. (name "openmpi")
  157. (version "4.0.0")
  158. (source
  159. (origin
  160. (method url-fetch)
  161. (uri (string-append "https://www.open-mpi.org/software/ompi/v"
  162. (version-major+minor version)
  163. "/downloads/openmpi-" version ".tar.bz2"))
  164. (sha256
  165. (base32
  166. "0srnjwzsmyhka9hhnmqm86qck4w3xwjm8g6sbns58wzbrwv8l2rg"))))
  167. (build-system gnu-build-system)
  168. (inputs
  169. `(("hwloc" ,hwloc "lib")
  170. ("gfortran" ,gfortran)
  171. ("libfabric" ,libfabric)
  172. ("libevent" ,libevent)
  173. ("opensm" ,opensm)
  174. ,@(if (and (not (%current-target-system))
  175. (member (%current-system) (package-supported-systems psm)))
  176. `(("psm" ,psm))
  177. '())
  178. ,@(if (and (not (%current-target-system))
  179. (member (%current-system) (package-supported-systems psm2)))
  180. `(("psm2" ,psm2))
  181. '())
  182. ("rdma-core" ,rdma-core)
  183. ("valgrind" ,valgrind)
  184. ("slurm" ,slurm))) ;for PMI support (launching via "srun")
  185. (native-inputs
  186. `(("pkg-config" ,pkg-config)
  187. ("perl" ,perl)))
  188. (outputs '("out" "debug"))
  189. (arguments
  190. `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
  191. "--enable-memchecker"
  192. "--with-sge"
  193. "--with-valgrind"
  194. "--with-hwloc=external"
  195. "--with-libevent"
  196. ;; InfiniBand support
  197. "--enable-openib-control-hdr-padding"
  198. "--enable-openib-dynamic-sl"
  199. "--enable-openib-udcm"
  200. "--enable-openib-rdmacm"
  201. "--enable-openib-rdmacm-ibaddr"
  202. ;; Enable support for SLURM's Process Manager
  203. ;; Interface (PMI).
  204. ,(string-append "--with-pmi="
  205. (assoc-ref %build-inputs "slurm")))
  206. #:phases (modify-phases %standard-phases
  207. ;; opensm is needed for InfiniBand support.
  208. (add-after 'unpack 'find-opensm-headers
  209. (lambda* (#:key inputs #:allow-other-keys)
  210. (setenv "C_INCLUDE_PATH"
  211. (string-append (assoc-ref inputs "opensm")
  212. "/include/infiniband/:"
  213. (getenv "C_INCLUDE_PATH")))
  214. (setenv "CPLUS_INCLUDE_PATH"
  215. (string-append (assoc-ref inputs "opensm")
  216. "/include/infiniband/:"
  217. (getenv "CPLUS_INCLUDE_PATH")))
  218. #t))
  219. (add-before 'build 'remove-absolute
  220. (lambda _
  221. ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
  222. ;; etc.) to reduce the closure size. See
  223. ;; <https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00388.html>
  224. ;; and
  225. ;; <https://www.mail-archive.com/users@lists.open-mpi.org//msg31397.html>.
  226. (substitute* '("orte/tools/orte-info/param.c"
  227. "oshmem/tools/oshmem_info/param.c"
  228. "ompi/tools/ompi_info/param.c")
  229. (("_ABSOLUTE") ""))
  230. ;; Avoid valgrind (which pulls in gdb etc.).
  231. (substitute*
  232. '("./ompi/mca/io/romio321/src/io_romio321_component.c")
  233. (("MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS")
  234. "\"[elided to reduce closure]\""))
  235. #t))
  236. (add-before 'build 'scrub-timestamps ;reproducibility
  237. (lambda _
  238. (substitute* '("ompi/tools/ompi_info/param.c"
  239. "orte/tools/orte-info/param.c"
  240. "oshmem/tools/oshmem_info/param.c")
  241. ((".*(Built|Configured) on.*") ""))
  242. #t))
  243. (add-after 'install 'remove-logs ;reproducibility
  244. (lambda* (#:key outputs #:allow-other-keys)
  245. (let ((out (assoc-ref outputs "out")))
  246. (for-each delete-file (find-files out "config.log"))
  247. #t))))))
  248. (home-page "http://www.open-mpi.org")
  249. (synopsis "MPI-3 implementation")
  250. (description
  251. "The Open MPI Project is an MPI-3 implementation that is developed and
  252. maintained by a consortium of academic, research, and industry partners. Open
  253. MPI is therefore able to combine the expertise, technologies, and resources
  254. from all across the High Performance Computing community in order to build the
  255. best MPI library available. Open MPI offers advantages for system and
  256. software vendors, application developers and computer science researchers.")
  257. ;; See file://LICENSE
  258. (license bsd-2)))
  259. (define-public openmpi-thread-multiple
  260. (package
  261. (inherit openmpi)
  262. (name "openmpi-thread-multiple")
  263. (arguments
  264. (substitute-keyword-arguments (package-arguments openmpi)
  265. ((#:configure-flags flags)
  266. `(cons "--enable-mpi-thread-multiple" ,flags))))
  267. (description " This version of Open@tie{}MPI has an implementation of
  268. @code{MPI_Init_thread} that provides @code{MPI_THREAD_MULTIPLE}. This won't
  269. work correctly with all transports (such as @code{openib}), and the
  270. performance is generally worse than the vanilla @code{openmpi} package, which
  271. only provides @code{MPI_THREAD_FUNNELED}.")))
  272. ;;; Build phase to be used for packages that execute MPI code.
  273. (define-public %openmpi-setup
  274. '(lambda _
  275. ;; By default, running the test suite would fail because 'ssh' could not
  276. ;; be found in $PATH. Define this variable to placate Open MPI without
  277. ;; adding a dependency on OpenSSH (the agent isn't used anyway.)
  278. (setenv "OMPI_MCA_plm_rsh_agent" (which "false"))
  279. ;; Allow oversubscription in case there are less physical cores available
  280. ;; in the build environment than the package wants while testing.
  281. (setenv "OMPI_MCA_rmaps_base_mapping_policy" "core:OVERSUBSCRIBE")
  282. #t))
  283. (define-public python-mpi4py
  284. (package
  285. (name "python-mpi4py")
  286. (version "3.0.1")
  287. (source
  288. (origin
  289. (method url-fetch)
  290. (uri (pypi-uri "mpi4py" version))
  291. (sha256
  292. (base32
  293. "0ld8rjmsjr0dklvj2g1gr3ax32sdq0xjxyh0cspknc1i36waajb5"))))
  294. (build-system python-build-system)
  295. (arguments
  296. `(#:phases
  297. (modify-phases %standard-phases
  298. (add-after 'build 'mpi-setup
  299. ,%openmpi-setup)
  300. (add-before 'check 'pre-check
  301. (lambda _
  302. ;; Skip BaseTestSpawn class (causes error 'ompi_dpm_dyn_init()
  303. ;; failed --> Returned "Unreachable"' in chroot environment).
  304. (substitute* "test/test_spawn.py"
  305. (("unittest.skipMPI\\('openmpi\\(<3.0.0\\)'\\)")
  306. "unittest.skipMPI('openmpi')"))
  307. #t)))))
  308. (inputs
  309. `(("openmpi" ,openmpi)))
  310. (home-page "https://bitbucket.org/mpi4py/mpi4py/")
  311. (synopsis "Python bindings for the Message Passing Interface standard")
  312. (description "MPI for Python (mpi4py) provides bindings of the Message
  313. Passing Interface (MPI) standard for the Python programming language, allowing
  314. any Python program to exploit multiple processors.
  315. mpi4py is constructed on top of the MPI-1/MPI-2 specification and provides an
  316. object oriented interface which closely follows MPI-2 C++ bindings. It
  317. supports point-to-point and collective communications of any picklable Python
  318. object as well as optimized communications of Python objects (such as NumPy
  319. arrays) that expose a buffer interface.")
  320. (license bsd-3)))