We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
MVAPICH2 depends on libibverbs
I was testing out Spack by attempting an installation of mvapich2 on my Fedora laptop. Of course, I don't have any libibverbs installed on my laptop, and even with all of the variants disabled, I was unable to build mvapich2:
```
configure: error: 'libibverbs not found. Did you specify --with-ib-libpath=?'
```
I could use the system package manager to do this, but how would people feel about a Spack package for libibverbs? It looks like you can download it here:
https://www.openfabrics.org/downloads/libibverbs/

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `var/spack/repos/builtin/packages/mvapich2/package.py`
Content:
```
1 ##############################################################################
2 # Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
3 # Produced at the Lawrence Livermore National Laboratory.
4 #
5 # This file is part of Spack.
6 # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7 # LLNL-CODE-647188
8 #
9 # For details, see https://github.com/spack/spack
10 # Please also see the NOTICE and LICENSE files for our notice and the LGPL.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License (as
14 # published by the Free Software Foundation) version 2.1, February 1999.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19 # conditions of the GNU Lesser General Public License for more details.
20 #
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ##############################################################################
25 import sys
26 
27 from spack import *
28 from spack.error import SpackError
29 
30 
31 def _process_manager_validator(values):
32     if len(values) > 1 and 'slurm' in values:
33         raise SpackError(
34             'slurm cannot be activated along with other process managers'
35         )
36 
37 
38 class Mvapich2(AutotoolsPackage):
39     """MVAPICH2 is an MPI implementation for Infiniband networks."""
40     homepage = "http://mvapich.cse.ohio-state.edu/"
41     url = "http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.2.tar.gz"
42     list_url = "http://mvapich.cse.ohio-state.edu/downloads/"
43 
44     version('2.3rc2', '6fcf22fe2a16023b462ef57614daa357')
45     version('2.3rc1', '386d79ae36b2136d203826465ad8b6cc')
46     version('2.3a', '87c3fbf8a755b53806fa9ecb21453445')
47 
48     # Prefer the latest stable release
49     version('2.3', sha256='01d5fb592454ddd9ecc17e91c8983b6aea0e7559aa38f410b111c8ef385b50dd', preferred=True)
50     version('2.2', '939b65ebe5b89a5bc822cdab0f31f96e')
51     version('2.1', '0095ceecb19bbb7fb262131cb9c2cdd6')
52     version('2.0', '9fbb68a4111a8b6338e476dc657388b4')
53 
54     provides('mpi')
55     provides('mpi@:3.0')
56 
57     variant('debug', default=False,
58             description='Enable debug info and error messages at run-time')
59 
60     variant('cuda', default=False,
61             description='Enable CUDA extension')
62 
63     variant('regcache', default=True,
64             description='Enable memory registration cache')
65 
66     # Accepted values are:
67     #   single      - No threads (MPI_THREAD_SINGLE)
68     #   funneled    - Only the main thread calls MPI (MPI_THREAD_FUNNELED)
69     #   serialized  - User serializes calls to MPI (MPI_THREAD_SERIALIZED)
70     #   multiple    - Fully multi-threaded (MPI_THREAD_MULTIPLE)
71     #   runtime     - Alias to "multiple"
72     variant(
73         'threads',
74         default='multiple',
75         values=('single', 'funneled', 'serialized', 'multiple'),
76         multi=False,
77         description='Control the level of thread support'
78     )
79 
80     # 32 is needed when job size exceeds 32768 cores
81     variant(
82         'ch3_rank_bits',
83         default='32',
84         values=('16', '32'),
85         multi=False,
86         description='Number of bits allocated to the rank field (16 or 32)'
87     )
88 
89     variant(
90         'process_managers',
91         description='List of the process managers to activate',
92         values=('slurm', 'hydra', 'gforker', 'remshell'),
93         multi=True,
94         validator=_process_manager_validator
95     )
96 
97     variant(
98         'fabrics',
99         description='The fabric enabled for this build',
100         default='psm',
101         values=(
102             'psm', 'sock', 'nemesisib', 'nemesis', 'mrail', 'nemesisibtcp',
103             'nemesistcpib'
104         )
105     )
106 
107     variant(
108         'alloca',
109         default=False,
110         description='Use alloca to allocate temporary memory if available'
111     )
112 
113     variant(
114         'file_systems',
115         description='List of the ROMIO file systems to activate',
116         values=('lustre', 'gpfs', 'nfs', 'ufs'),
117         multi=True
118     )
119 
120     depends_on('bison', type='build')
121     depends_on('libpciaccess', when=(sys.platform != 'darwin'))
122     depends_on('cuda', when='+cuda')
123     depends_on('psm', when='fabrics=psm')
124 
125     filter_compiler_wrappers(
126         'mpicc', 'mpicxx', 'mpif77', 'mpif90', 'mpifort', relative_root='bin'
127     )
128 
129     @property
130     def libs(self):
131         query_parameters = self.spec.last_query.extra_parameters
132         libraries = ['libmpi']
133 
134         if 'cxx' in query_parameters:
135             libraries = ['libmpicxx'] + libraries
136 
137         return find_libraries(
138             libraries, root=self.prefix, shared=True, recursive=True
139         )
140 
141     @property
142     def process_manager_options(self):
143         spec = self.spec
144 
145         other_pms = []
146         for x in ('hydra', 'gforker', 'remshell'):
147             if 'process_managers={0}'.format(x) in spec:
148                 other_pms.append(x)
149 
150         opts = []
151         if len(other_pms) > 0:
152             opts = ['--with-pm=%s' % ':'.join(other_pms)]
153 
154         # See: http://slurm.schedmd.com/mpi_guide.html#mvapich2
155         if 'process_managers=slurm' in spec:
156             opts = [
157                 '--with-pmi=pmi2',
158                 '--with-pm=slurm'
159             ]
160 
161         return opts
162 
163     @property
164     def network_options(self):
165         opts = []
166         # From here on I can suppose that only one variant has been selected
167         if 'fabrics=psm' in self.spec:
168             opts = [
169                 "--with-device=ch3:psm",
170                 "--with-psm={0}".format(self.spec['psm'].prefix)
171             ]
172         elif 'fabrics=sock' in self.spec:
173             opts = ["--with-device=ch3:sock"]
174         elif 'fabrics=nemesistcpib' in self.spec:
175             opts = ["--with-device=ch3:nemesis:tcp,ib"]
176         elif 'fabrics=nemesisibtcp' in self.spec:
177             opts = ["--with-device=ch3:nemesis:ib,tcp"]
178         elif 'fabrics=nemesisib' in self.spec:
179             opts = ["--with-device=ch3:nemesis:ib"]
180         elif 'fabrics=nemesis' in self.spec:
181             opts = ["--with-device=ch3:nemesis"]
182         elif 'fabrics=mrail' in self.spec:
183             opts = ["--with-device=ch3:mrail", "--with-rdma=gen2"]
184         return opts
185 
186     @property
187     def file_system_options(self):
188         spec = self.spec
189 
190         fs = []
191         for x in ('lustre', 'gpfs', 'nfs', 'ufs'):
192             if 'file_systems={0}'.format(x) in spec:
193                 fs.append(x)
194 
195         opts = []
196         if len(fs) > 0:
197             opts.append('--with-file-system=%s' % '+'.join(fs))
198 
199         return opts
200 
201     def setup_environment(self, spack_env, run_env):
202         spec = self.spec
203         # mvapich2 configure fails when F90 and F90FLAGS are set
204         spack_env.unset('F90')
205         spack_env.unset('F90FLAGS')
206         if 'process_managers=slurm' in spec:
207             run_env.set('SLURM_MPI_TYPE', 'pmi2')
208 
209     def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
210         spack_env.set('MPICC',  join_path(self.prefix.bin, 'mpicc'))
211         spack_env.set('MPICXX', join_path(self.prefix.bin, 'mpicxx'))
212         spack_env.set('MPIF77', join_path(self.prefix.bin, 'mpif77'))
213         spack_env.set('MPIF90', join_path(self.prefix.bin, 'mpif90'))
214 
215         spack_env.set('MPICH_CC', spack_cc)
216         spack_env.set('MPICH_CXX', spack_cxx)
217         spack_env.set('MPICH_F77', spack_f77)
218         spack_env.set('MPICH_F90', spack_fc)
219         spack_env.set('MPICH_FC', spack_fc)
220 
221     def setup_dependent_package(self, module, dependent_spec):
222         self.spec.mpicc  = join_path(self.prefix.bin, 'mpicc')
223         self.spec.mpicxx = join_path(self.prefix.bin, 'mpicxx')
224         self.spec.mpifc  = join_path(self.prefix.bin, 'mpif90')
225         self.spec.mpif77 = join_path(self.prefix.bin, 'mpif77')
226         self.spec.mpicxx_shared_libs = [
227             join_path(self.prefix.lib, 'libmpicxx.{0}'.format(dso_suffix)),
228             join_path(self.prefix.lib, 'libmpi.{0}'.format(dso_suffix))
229         ]
230 
231     @run_before('configure')
232     def die_without_fortran(self):
233         # Until we can pass variants such as +fortran through virtual
234         # dependencies depends_on('mpi'), require Fortran compiler to
235         # avoid delayed build errors in dependents.
236         if (self.compiler.f77 is None) or (self.compiler.fc is None):
237             raise InstallError(
238                 'Mvapich2 requires both C and Fortran compilers!'
239             )
240 
241     def configure_args(self):
242         spec = self.spec
243         args = [
244             '--enable-shared',
245             '--enable-romio',
246             '--disable-silent-rules',
247             '--disable-new-dtags',
248             '--enable-fortran=all',
249             "--enable-threads={0}".format(spec.variants['threads'].value),
250             "--with-ch3-rank-bits={0}".format(
251                 spec.variants['ch3_rank_bits'].value),
252         ]
253 
254         args.extend(self.enable_or_disable('alloca'))
255 
256         if '+debug' in self.spec:
257             args.extend([
258                 '--disable-fast',
259                 '--enable-error-checking=runtime',
260                 '--enable-error-messages=all',
261                 # Permits debugging with TotalView
262                 '--enable-g=dbg',
263                 '--enable-debuginfo'
264             ])
265         else:
266             args.append('--enable-fast=all')
267 
268         if '+cuda' in self.spec:
269             args.extend([
270                 '--enable-cuda',
271                 '--with-cuda={0}'.format(spec['cuda'].prefix)
272             ])
273         else:
274             args.append('--disable-cuda')
275 
276         if '+regcache' in self.spec:
277             args.append('--enable-registration-cache')
278         else:
279             args.append('--disable-registration-cache')
280 
281         args.extend(self.process_manager_options)
282         args.extend(self.network_options)
283         args.extend(self.file_system_options)
284         return args
285
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/var/spack/repos/builtin/packages/mvapich2/package.py b/var/spack/repos/builtin/packages/mvapich2/package.py
--- a/var/spack/repos/builtin/packages/mvapich2/package.py
+++ b/var/spack/repos/builtin/packages/mvapich2/package.py
@@ -121,6 +121,10 @@
     depends_on('libpciaccess', when=(sys.platform != 'darwin'))
     depends_on('cuda', when='+cuda')
     depends_on('psm', when='fabrics=psm')
+    depends_on('rdma-core', when='fabrics=mrail')
+    depends_on('rdma-core', when='fabrics=nemesisib')
+    depends_on('rdma-core', when='fabrics=nemesistcpib')
+    depends_on('rdma-core', when='fabrics=nemesisibtcp')
 
     filter_compiler_wrappers(
         'mpicc', 'mpicxx', 'mpif77', 'mpif90', 'mpifort', relative_root='bin'
@@ -180,7 +184,8 @@
         elif 'fabrics=nemesis' in self.spec:
             opts = ["--with-device=ch3:nemesis"]
         elif 'fabrics=mrail' in self.spec:
-            opts = ["--with-device=ch3:mrail", "--with-rdma=gen2"]
+            opts = ["--with-device=ch3:mrail", "--with-rdma=gen2",
+                    "--disable-mcast"]
         return opts
 
     @property

{"golden_diff": "diff --git a/var/spack/repos/builtin/packages/mvapich2/package.py b/var/spack/repos/builtin/packages/mvapich2/package.py\n--- a/var/spack/repos/builtin/packages/mvapich2/package.py\n+++ b/var/spack/repos/builtin/packages/mvapich2/package.py\n@@ -121,6 +121,10 @@\n     depends_on('libpciaccess', when=(sys.platform != 'darwin'))\n     depends_on('cuda', when='+cuda')\n     depends_on('psm', when='fabrics=psm')\n+    depends_on('rdma-core', when='fabrics=mrail')\n+    depends_on('rdma-core', when='fabrics=nemesisib')\n+    depends_on('rdma-core', when='fabrics=nemesistcpib')\n+    depends_on('rdma-core', when='fabrics=nemesisibtcp')\n \n     filter_compiler_wrappers(\n         'mpicc', 'mpicxx', 'mpif77', 'mpif90', 'mpifort', relative_root='bin'\n@@ -180,7 +184,8 @@\n         elif 'fabrics=nemesis' in self.spec:\n             opts = [\"--with-device=ch3:nemesis\"]\n         elif 'fabrics=mrail' in self.spec:\n-            opts = [\"--with-device=ch3:mrail\", \"--with-rdma=gen2\"]\n+            opts = [\"--with-device=ch3:mrail\", \"--with-rdma=gen2\",\n+                    \"--disable-mcast\"]\n         return opts\n \n     @property\n", "issue": "MVAPICH2 depends on libibverbs\nI was testing out Spack by attempting an installation of mvapich2 on my Fedora laptop. Of course, I don't have any libibverbs installed on my laptop, and even with all of the variants disabled, I was unable to build mvapich2:\r\n```\r\nconfigure: error: 'libibverbs not found. Did you specify --with-ib-libpath=?'\r\n```\r\nI could use the system package manager to do this, but how would people feel about a Spack package for libibverbs? It looks like you can download it here:\r\nhttps://www.openfabrics.org/downloads/libibverbs/\n", "before_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/spack/spack\n# Please also see the NOTICE and LICENSE files for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\nimport sys\n\nfrom spack import *\nfrom spack.error import SpackError\n\n\ndef _process_manager_validator(values):\n    if len(values) > 1 and 'slurm' in values:\n        raise SpackError(\n            'slurm cannot be activated along with other process managers'\n        )\n\n\nclass Mvapich2(AutotoolsPackage):\n    \"\"\"MVAPICH2 is an MPI implementation for Infiniband networks.\"\"\"\n    homepage = \"http://mvapich.cse.ohio-state.edu/\"\n    url = \"http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.2.tar.gz\"\n    list_url = \"http://mvapich.cse.ohio-state.edu/downloads/\"\n\n    version('2.3rc2', '6fcf22fe2a16023b462ef57614daa357')\n    version('2.3rc1', '386d79ae36b2136d203826465ad8b6cc')\n    version('2.3a', '87c3fbf8a755b53806fa9ecb21453445')\n\n    # Prefer the latest stable release\n    version('2.3', sha256='01d5fb592454ddd9ecc17e91c8983b6aea0e7559aa38f410b111c8ef385b50dd', preferred=True)\n    version('2.2', '939b65ebe5b89a5bc822cdab0f31f96e')\n    version('2.1', '0095ceecb19bbb7fb262131cb9c2cdd6')\n    version('2.0', '9fbb68a4111a8b6338e476dc657388b4')\n\n    provides('mpi')\n    provides('mpi@:3.0')\n\n    variant('debug', default=False,\n            description='Enable debug info and error messages at run-time')\n\n    variant('cuda', default=False,\n            description='Enable CUDA extension')\n\n    variant('regcache', default=True,\n            description='Enable memory registration cache')\n\n    # Accepted values are:\n    #   single      - No threads (MPI_THREAD_SINGLE)\n    #   funneled    - Only the main thread calls MPI (MPI_THREAD_FUNNELED)\n    #   serialized  - User serializes calls to MPI (MPI_THREAD_SERIALIZED)\n    #   multiple    - Fully multi-threaded (MPI_THREAD_MULTIPLE)\n    #   runtime     - Alias to \"multiple\"\n    variant(\n        'threads',\n        default='multiple',\n        values=('single', 'funneled', 'serialized', 'multiple'),\n        multi=False,\n        description='Control the level of thread support'\n    )\n\n    # 32 is needed when job size exceeds 32768 cores\n    variant(\n        'ch3_rank_bits',\n        default='32',\n        values=('16', '32'),\n        multi=False,\n        description='Number of bits allocated to the rank field (16 or 32)'\n    )\n\n    variant(\n        'process_managers',\n        description='List of the process managers to activate',\n        values=('slurm', 'hydra', 'gforker', 'remshell'),\n        multi=True,\n        validator=_process_manager_validator\n    )\n\n    variant(\n        'fabrics',\n        description='The fabric enabled for this build',\n        default='psm',\n        values=(\n            'psm', 'sock', 'nemesisib', 'nemesis', 'mrail', 'nemesisibtcp',\n            'nemesistcpib'\n        )\n    )\n\n    variant(\n        'alloca',\n        default=False,\n        description='Use alloca to allocate temporary memory if available'\n    )\n\n    variant(\n        'file_systems',\n        description='List of the ROMIO file systems to activate',\n        values=('lustre', 'gpfs', 'nfs', 'ufs'),\n        multi=True\n    )\n\n    depends_on('bison', type='build')\n    depends_on('libpciaccess', when=(sys.platform != 'darwin'))\n    depends_on('cuda', when='+cuda')\n    depends_on('psm', when='fabrics=psm')\n\n    filter_compiler_wrappers(\n        'mpicc', 'mpicxx', 'mpif77', 'mpif90', 'mpifort', relative_root='bin'\n    )\n\n    @property\n    def libs(self):\n        query_parameters = self.spec.last_query.extra_parameters\n        libraries = ['libmpi']\n\n        if 'cxx' in query_parameters:\n            libraries = ['libmpicxx'] + libraries\n\n        return find_libraries(\n            libraries, root=self.prefix, shared=True, recursive=True\n        )\n\n    @property\n    def process_manager_options(self):\n        spec = self.spec\n\n        other_pms = []\n        for x in ('hydra', 'gforker', 'remshell'):\n            if 'process_managers={0}'.format(x) in spec:\n                other_pms.append(x)\n\n        opts = []\n        if len(other_pms) > 0:\n            opts = ['--with-pm=%s' % ':'.join(other_pms)]\n\n        # See: http://slurm.schedmd.com/mpi_guide.html#mvapich2\n        if 'process_managers=slurm' in spec:\n            opts = [\n                '--with-pmi=pmi2',\n                '--with-pm=slurm'\n            ]\n\n        return opts\n\n    @property\n    def network_options(self):\n        opts = []\n        # From here on I can suppose that only one variant has been selected\n        if 'fabrics=psm' in self.spec:\n            opts = [\n                \"--with-device=ch3:psm\",\n                \"--with-psm={0}\".format(self.spec['psm'].prefix)\n            ]\n        elif 'fabrics=sock' in self.spec:\n            opts = [\"--with-device=ch3:sock\"]\n        elif 'fabrics=nemesistcpib' in self.spec:\n            opts = [\"--with-device=ch3:nemesis:tcp,ib\"]\n        elif 'fabrics=nemesisibtcp' in self.spec:\n            opts = [\"--with-device=ch3:nemesis:ib,tcp\"]\n        elif 'fabrics=nemesisib' in self.spec:\n            opts = [\"--with-device=ch3:nemesis:ib\"]\n        elif 'fabrics=nemesis' in self.spec:\n            opts = [\"--with-device=ch3:nemesis\"]\n        elif 'fabrics=mrail' in self.spec:\n            opts = [\"--with-device=ch3:mrail\", \"--with-rdma=gen2\"]\n        return opts\n\n    @property\n    def file_system_options(self):\n        spec = self.spec\n\n        fs = []\n        for x in ('lustre', 'gpfs', 'nfs', 'ufs'):\n            if 'file_systems={0}'.format(x) in spec:\n                fs.append(x)\n\n        opts = []\n        if len(fs) > 0:\n            opts.append('--with-file-system=%s' % '+'.join(fs))\n\n        return opts\n\n    def setup_environment(self, spack_env, run_env):\n        spec = self.spec\n        # mvapich2 configure fails when F90 and F90FLAGS are set\n        spack_env.unset('F90')\n        spack_env.unset('F90FLAGS')\n        if 'process_managers=slurm' in spec:\n            run_env.set('SLURM_MPI_TYPE', 'pmi2')\n\n    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):\n        spack_env.set('MPICC',  join_path(self.prefix.bin, 'mpicc'))\n        spack_env.set('MPICXX', join_path(self.prefix.bin, 'mpicxx'))\n        spack_env.set('MPIF77', join_path(self.prefix.bin, 'mpif77'))\n        spack_env.set('MPIF90', join_path(self.prefix.bin, 'mpif90'))\n\n        spack_env.set('MPICH_CC', spack_cc)\n        spack_env.set('MPICH_CXX', spack_cxx)\n        spack_env.set('MPICH_F77', spack_f77)\n        spack_env.set('MPICH_F90', spack_fc)\n        spack_env.set('MPICH_FC', spack_fc)\n\n    def setup_dependent_package(self, module, dependent_spec):\n        self.spec.mpicc  = join_path(self.prefix.bin, 'mpicc')\n        self.spec.mpicxx = join_path(self.prefix.bin, 'mpicxx')\n        self.spec.mpifc  = join_path(self.prefix.bin, 'mpif90')\n        self.spec.mpif77 = join_path(self.prefix.bin, 'mpif77')\n        self.spec.mpicxx_shared_libs = [\n            join_path(self.prefix.lib, 'libmpicxx.{0}'.format(dso_suffix)),\n            join_path(self.prefix.lib, 'libmpi.{0}'.format(dso_suffix))\n        ]\n\n    @run_before('configure')\n    def die_without_fortran(self):\n        # Until we can pass variants such as +fortran through virtual\n        # dependencies depends_on('mpi'), require Fortran compiler to\n        # avoid delayed build errors in dependents.\n        if (self.compiler.f77 is None) or (self.compiler.fc is None):\n            raise InstallError(\n                'Mvapich2 requires both C and Fortran compilers!'\n            )\n\n    def configure_args(self):\n        spec = self.spec\n        args = [\n            '--enable-shared',\n            '--enable-romio',\n            '--disable-silent-rules',\n            '--disable-new-dtags',\n            '--enable-fortran=all',\n            \"--enable-threads={0}\".format(spec.variants['threads'].value),\n            \"--with-ch3-rank-bits={0}\".format(\n                spec.variants['ch3_rank_bits'].value),\n        ]\n\n        args.extend(self.enable_or_disable('alloca'))\n\n        if '+debug' in self.spec:\n            args.extend([\n                '--disable-fast',\n                '--enable-error-checking=runtime',\n                '--enable-error-messages=all',\n                # Permits debugging with TotalView\n                '--enable-g=dbg',\n                '--enable-debuginfo'\n            ])\n        else:\n            args.append('--enable-fast=all')\n\n        if '+cuda' in self.spec:\n            args.extend([\n                '--enable-cuda',\n                '--with-cuda={0}'.format(spec['cuda'].prefix)\n            ])\n        else:\n            args.append('--disable-cuda')\n\n        if '+regcache' in self.spec:\n            args.append('--enable-registration-cache')\n        else:\n            args.append('--disable-registration-cache')\n\n        args.extend(self.process_manager_options)\n        args.extend(self.network_options)\n        args.extend(self.file_system_options)\n        return args\n", "path": "var/spack/repos/builtin/packages/mvapich2/package.py"}], "after_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/spack/spack\n# Please also see the NOTICE and LICENSE files for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\nimport sys\n\nfrom spack import *\nfrom spack.error import SpackError\n\n\ndef _process_manager_validator(values):\n    if len(values) > 1 and 'slurm' in values:\n        raise SpackError(\n            'slurm cannot be activated along with other process managers'\n        )\n\n\nclass Mvapich2(AutotoolsPackage):\n    \"\"\"MVAPICH2 is an MPI implementation for Infiniband networks.\"\"\"\n    homepage = \"http://mvapich.cse.ohio-state.edu/\"\n    url = \"http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.2.tar.gz\"\n    list_url = \"http://mvapich.cse.ohio-state.edu/downloads/\"\n\n    version('2.3rc2', '6fcf22fe2a16023b462ef57614daa357')\n    version('2.3rc1', '386d79ae36b2136d203826465ad8b6cc')\n    version('2.3a', '87c3fbf8a755b53806fa9ecb21453445')\n\n    # Prefer the latest stable release\n    version('2.3', sha256='01d5fb592454ddd9ecc17e91c8983b6aea0e7559aa38f410b111c8ef385b50dd', preferred=True)\n    version('2.2', '939b65ebe5b89a5bc822cdab0f31f96e')\n    version('2.1', '0095ceecb19bbb7fb262131cb9c2cdd6')\n    version('2.0', '9fbb68a4111a8b6338e476dc657388b4')\n\n    provides('mpi')\n    provides('mpi@:3.0')\n\n    variant('debug', default=False,\n            description='Enable debug info and error messages at run-time')\n\n    variant('cuda', default=False,\n            description='Enable CUDA extension')\n\n    variant('regcache', default=True,\n            description='Enable memory registration cache')\n\n    # Accepted values are:\n    #   single      - No threads (MPI_THREAD_SINGLE)\n    #   funneled    - Only the main thread calls MPI (MPI_THREAD_FUNNELED)\n    #   serialized  - User serializes calls to MPI (MPI_THREAD_SERIALIZED)\n    #   multiple    - Fully multi-threaded (MPI_THREAD_MULTIPLE)\n    #   runtime     - Alias to \"multiple\"\n    variant(\n        'threads',\n        default='multiple',\n        values=('single', 'funneled', 'serialized', 'multiple'),\n        multi=False,\n        description='Control the level of thread support'\n    )\n\n    # 32 is needed when job size exceeds 32768 cores\n    variant(\n        'ch3_rank_bits',\n        default='32',\n        values=('16', '32'),\n        multi=False,\n        description='Number of bits allocated to the rank field (16 or 32)'\n    )\n\n    variant(\n        'process_managers',\n        description='List of the process managers to activate',\n        values=('slurm', 'hydra', 'gforker', 'remshell'),\n        multi=True,\n        validator=_process_manager_validator\n    )\n\n    variant(\n        'fabrics',\n        description='The fabric enabled for this build',\n        default='psm',\n        values=(\n            'psm', 'sock', 'nemesisib', 'nemesis', 'mrail', 'nemesisibtcp',\n            'nemesistcpib'\n        )\n    )\n\n    variant(\n        'alloca',\n        default=False,\n        description='Use alloca to allocate temporary memory if available'\n    )\n\n    variant(\n        'file_systems',\n        description='List of the ROMIO file systems to activate',\n        values=('lustre', 'gpfs', 'nfs', 'ufs'),\n        multi=True\n    )\n\n    depends_on('bison', type='build')\n    depends_on('libpciaccess', when=(sys.platform != 'darwin'))\n    depends_on('cuda', when='+cuda')\n    depends_on('psm', when='fabrics=psm')\n    depends_on('rdma-core', when='fabrics=mrail')\n    depends_on('rdma-core', when='fabrics=nemesisib')\n    depends_on('rdma-core', when='fabrics=nemesistcpib')\n    depends_on('rdma-core', when='fabrics=nemesisibtcp')\n\n    filter_compiler_wrappers(\n        'mpicc', 'mpicxx', 'mpif77', 'mpif90', 'mpifort', relative_root='bin'\n    )\n\n    @property\n    def libs(self):\n        query_parameters = self.spec.last_query.extra_parameters\n        libraries = ['libmpi']\n\n        if 'cxx' in query_parameters:\n            libraries = ['libmpicxx'] + libraries\n\n        return find_libraries(\n            libraries, root=self.prefix, shared=True, recursive=True\n        )\n\n    @property\n    def process_manager_options(self):\n        spec = self.spec\n\n        other_pms = []\n        for x in ('hydra', 'gforker', 'remshell'):\n            if 'process_managers={0}'.format(x) in spec:\n                other_pms.append(x)\n\n        opts = []\n        if len(other_pms) > 0:\n            opts = ['--with-pm=%s' % ':'.join(other_pms)]\n\n        # See: http://slurm.schedmd.com/mpi_guide.html#mvapich2\n        if 'process_managers=slurm' in spec:\n            opts = [\n                '--with-pmi=pmi2',\n                '--with-pm=slurm'\n            ]\n\n        return opts\n\n    @property\n    def network_options(self):\n        opts = []\n        # From here on I can suppose that only one variant has been selected\n        if 'fabrics=psm' in self.spec:\n            opts = [\n                \"--with-device=ch3:psm\",\n                \"--with-psm={0}\".format(self.spec['psm'].prefix)\n            ]\n        elif 'fabrics=sock' in self.spec:\n            opts = [\"--with-device=ch3:sock\"]\n        elif 'fabrics=nemesistcpib' in self.spec:\n            opts = [\"--with-device=ch3:nemesis:tcp,ib\"]\n        elif 'fabrics=nemesisibtcp' in self.spec:\n            opts = [\"--with-device=ch3:nemesis:ib,tcp\"]\n        elif 'fabrics=nemesisib' in self.spec:\n            opts = [\"--with-device=ch3:nemesis:ib\"]\n        elif 'fabrics=nemesis' in self.spec:\n            opts = [\"--with-device=ch3:nemesis\"]\n        elif 'fabrics=mrail' in self.spec:\n            opts = [\"--with-device=ch3:mrail\", \"--with-rdma=gen2\",\n                    \"--disable-mcast\"]\n        return opts\n\n    @property\n    def file_system_options(self):\n        spec = self.spec\n\n        fs = []\n        for x in ('lustre', 'gpfs', 'nfs', 'ufs'):\n            if 'file_systems={0}'.format(x) in spec:\n                fs.append(x)\n\n        opts = []\n        if len(fs) > 0:\n            opts.append('--with-file-system=%s' % '+'.join(fs))\n\n        return opts\n\n    def setup_environment(self, spack_env, run_env):\n        spec = self.spec\n        # mvapich2 configure fails when F90 and F90FLAGS are set\n        spack_env.unset('F90')\n        spack_env.unset('F90FLAGS')\n        if 'process_managers=slurm' in spec:\n            run_env.set('SLURM_MPI_TYPE', 'pmi2')\n\n    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):\n        spack_env.set('MPICC',  join_path(self.prefix.bin, 'mpicc'))\n        spack_env.set('MPICXX', join_path(self.prefix.bin, 'mpicxx'))\n        spack_env.set('MPIF77', join_path(self.prefix.bin, 'mpif77'))\n        spack_env.set('MPIF90', join_path(self.prefix.bin, 'mpif90'))\n\n        spack_env.set('MPICH_CC', spack_cc)\n        spack_env.set('MPICH_CXX', spack_cxx)\n        spack_env.set('MPICH_F77', spack_f77)\n        spack_env.set('MPICH_F90', spack_fc)\n        spack_env.set('MPICH_FC', spack_fc)\n\n    def setup_dependent_package(self, module, dependent_spec):\n        self.spec.mpicc  = join_path(self.prefix.bin, 'mpicc')\n        self.spec.mpicxx = join_path(self.prefix.bin, 'mpicxx')\n        self.spec.mpifc  = join_path(self.prefix.bin, 'mpif90')\n        self.spec.mpif77 = join_path(self.prefix.bin, 'mpif77')\n        self.spec.mpicxx_shared_libs = [\n            join_path(self.prefix.lib, 'libmpicxx.{0}'.format(dso_suffix)),\n            join_path(self.prefix.lib, 'libmpi.{0}'.format(dso_suffix))\n        ]\n\n    @run_before('configure')\n    def die_without_fortran(self):\n        # Until we can pass variants such as +fortran through virtual\n        # dependencies depends_on('mpi'), require Fortran compiler to\n        # avoid delayed build errors in dependents.\n        if (self.compiler.f77 is None) or (self.compiler.fc is None):\n            raise InstallError(\n                'Mvapich2 requires both C and Fortran compilers!'\n            )\n\n    def configure_args(self):\n        spec = self.spec\n        args = [\n            '--enable-shared',\n            '--enable-romio',\n            '--disable-silent-rules',\n            '--disable-new-dtags',\n            '--enable-fortran=all',\n            \"--enable-threads={0}\".format(spec.variants['threads'].value),\n            \"--with-ch3-rank-bits={0}\".format(\n                spec.variants['ch3_rank_bits'].value),\n        ]\n\n        args.extend(self.enable_or_disable('alloca'))\n\n        if '+debug' in self.spec:\n            args.extend([\n                '--disable-fast',\n                '--enable-error-checking=runtime',\n                '--enable-error-messages=all',\n                # Permits debugging with TotalView\n                '--enable-g=dbg',\n                '--enable-debuginfo'\n            ])\n        else:\n            args.append('--enable-fast=all')\n\n        if '+cuda' in self.spec:\n            args.extend([\n                '--enable-cuda',\n                '--with-cuda={0}'.format(spec['cuda'].prefix)\n            ])\n        else:\n            args.append('--disable-cuda')\n\n        if '+regcache' in self.spec:\n            args.append('--enable-registration-cache')\n        else:\n            args.append('--disable-registration-cache')\n\n        args.extend(self.process_manager_options)\n        args.extend(self.network_options)\n        args.extend(self.file_system_options)\n        return args\n", "path": "var/spack/repos/builtin/packages/mvapich2/package.py"}]}