-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecipe_mpi.py
106 lines (83 loc) · 3.36 KB
/
recipe_mpi.py
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
"""
HPCCM recipe for MRChem Singularity image (MPI+OpenMP)
Contents:
Ubuntu 18.04
GNU compilers (upstream)
OpenMPI
OFED/MOFED
PMI2 (SLURM)
UCX
Generating recipe (stdout):
$ hpccm --recipe recipe_mpi.py --format singularity --singularity-version=3.2
"""
os_version='18.04'
mrchem_version='1.0.1'
cmake_version='3.16.3'
openmpi_version='4.0.5'
# CentOS base image
Stage0 += baseimage(image='ubuntu:{}'.format(os_version), _as='build')
# GNU compilers
compiler = gnu()
Stage0 += compiler
# (M)OFED
Stage0 += mlnx_ofed()
# UCX
Stage0 += ucx(cuda=False, ofed=True)
# PMI2
Stage0 += slurm_pmi2()
# OpenMPI (use UCX instead of IB directly)
Stage0 += openmpi(cuda=False,
infiniband=False,
pmi='/usr/local/slurm-pmi2',
ucx='/usr/local/ucx',
toolchain=compiler.toolchain,
version=openmpi_version)
# CMake
Stage0 += cmake(eula=True, version=cmake_version)
# Python 3
Stage0 += python(python2=False, python3=True)
# MRChem
Stage0 += packages(apt=['patch'])
Stage0 += generic_cmake(cmake_opts=['-D CMAKE_BUILD_TYPE=Release',
'-D ENABLE_MPI=ON',
'-D ENABLE_OPENMP=ON',
'-D ENABLE_ARCH_FLAGS=OFF',
'-D CXX_COMPILER=mpicxx'],
prefix='/usr/local/mrchem',
url='http://github.com/MRChemSoft/mrchem/archive/v{}.tar.gz'.format(mrchem_version),
directory='mrchem-{}'.format(mrchem_version))
# Runtime distributable stage
Stage1 += baseimage(image='ubuntu:{}'.format(os_version))
Stage1 += Stage0.runtime()
Stage1 += environment(variables={'PATH': '$PATH:/usr/local/mrchem/bin'})
Stage1 += runscript(commands=['mrchem'])
Stage1 += label(metadata={
'Author': 'Stig Rune Jensen <[email protected]>',
'Version': 'v{}'.format(mrchem_version),
'Description': 'MRChem program (MPI+OpenMP version)',
'Dependency': 'OpenMPI v4.0'
})
help_str="""
%help
Hybrid parallel (MPI + OpenMP) build of MRChem using OpenMPI-{} on a
Ubuntu-{} base image. Requires compatible OpenMPI version on the host.
The image includes Mellanox OFED, UCX and PMI2 for compatibility with
common HPC environments with InfiniBand and SLURM.
For a pure OpenMP run (n threads on one process) you can run the container
just as the regular mrchem executable, here with input file molecule.inp:
$ export OMP_NUM_THREADS=n
$ ./<image-name>.sif molecule
In order to run with more that one MPI process you must first manually run
the input parser to obtain the JSON input file. This is done by dry-running
(--dryrun) the container on the main input file, here called molecule.inp:
$ ./<image-name>.sif --dryrun molecule
This will produce a new file molecule.json in the current directory which can
be passed to the mrchem.x program inside the container using the singularity
exec command:
$ singularity exec <image-name>.sif mrchem.x mrchem.json
To run in hybrid parallel (n threads on N processes) you should launch the
singularity execution with mpirun/srun:
$ export OMP_NUM_THREADS=n
$ mpirun -np N singularity exec <image-name>.sif mrchem.x mrchem.json
""".format(openmpi_version, os_version)
Stage1 += raw(singularity=help_str)