Skip to content

Commit ac20928

Browse files
authored
Merge pull request #34 from EuropeanSpallationSource/orbit-mpi
Automated enabling of MPI support
2 parents 54a6ab2 + 03f448f commit ac20928

File tree

10 files changed

+31
-206
lines changed

10 files changed

+31
-206
lines changed

py/orbit/core/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import orbit_mpi

py/orbit/core/meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
py_sources = files([
3+
'__init__.py',
4+
])
5+
6+
python.install_sources(
7+
py_sources,
8+
subdir: 'orbit/core',
9+
# pure: true,
10+
)

py/orbit/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
subdir('bumps')
3+
subdir('core')
34
subdir('matching')
45
subdir('time_dep')
56
subdir('bunch_utils')

src/libmain/libmain.cc

Lines changed: 0 additions & 111 deletions
This file was deleted.

src/libmain/module_template/__init__.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/libmain/orbit/__init__.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/libmain/orbit/_module_loader.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/libmain/orbit/pyORBIT.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/meson.build

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ dependencies = []
1414

1515
dependencies += dependency('fftw3', version: '>= 3.0.0', required: true)
1616

17+
# Detecting if MPICH or OPENMPI are installed and enabling support if present
18+
mpich_dependency = dependency('mpich', version: '>= 4.0.0', required: false)
19+
openmpi_dependency = dependency('ompi', version: '>= 5.0.0', required: false)
20+
21+
if mpich_dependency.found()
22+
cpp_args = ['-fPIC', '-std=c++11', '-DUSE_MPI=1']
23+
dependencies += mpich_dependency
24+
elif openmpi_dependency.found()
25+
cpp_args = ['-fPIC', '-std=c++11', '-DUSE_MPI=1']
26+
dependencies += openmpi_dependency
27+
else
28+
cpp_args = ['-fPIC', '-std=c++11']
29+
endif
30+
1731
sources = files([
1832
'linac/wrap_linacmodule.cc',
1933
'linac/tracking/linac_tracking.cc',
@@ -111,7 +125,6 @@ sources = files([
111125
'trackerrk4/PyExternalEffects.cc',
112126
'trackerrk4/RungeKuttaTracker.cc',
113127
'trackerrk4/wrap_ext_effects_container.cc',
114-
'libmain/libmain.cc',
115128
'mpi/wrap_orbit_mpi.cc',
116129
'mpi/wrap_mpi_comm.cc',
117130
'mpi/orbit_mpi.cc',
@@ -208,7 +221,7 @@ sources = files([
208221
'teapot/wrap_matrix_generator.cc',
209222
'teapot/teapotbase.cc',
210223
'teapot/MatrixGenerator.cc'
211-
])
224+
])
212225
inc = include_directories([
213226
python.get_variable('INCLUDEPY', ''),
214227
'main',
@@ -237,31 +250,26 @@ inc = include_directories([
237250
'orbit/BunchDiagnostics',
238251
'orbit',
239252
'utils/integration',
240-
'libmain',
241253
'orbit/Apertures'
242-
254+
243255
])
244256

245257

246258
core_lib = library('core',
247259
sources: sources,
248260
include_directories: inc,
249-
cpp_args: ['-fPIC', '-std=c++11'],
261+
cpp_args: cpp_args,
250262
override_options: ['b_lundef=false'],
251263
dependencies: dependencies,
252264
install: true,
253-
254265
)
255266

256267
core_dep = declare_dependency(link_with : core_lib)
257268

258-
259-
260-
261269
python.extension_module('orbit_mpi',
262270
sources: [base + '/mpi_init.cc'],
263271
include_directories: inc,
264-
cpp_args: ['-fPIC', '-std=c++11'],
272+
cpp_args: cpp_args,
265273
dependencies: [core_dep],
266274
install: true,
267275
subdir: 'orbit/core',
@@ -393,9 +401,3 @@ python.extension_module('error_base',
393401
install: true,
394402
subdir: 'orbit/core',
395403
)
396-
397-
398-
399-
400-
401-

src/mpi/wrap_orbit_mpi.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace wrap_orbit_mpi{
178178
};
179179

180180
PyMODINIT_FUNC initorbit_mpi(void) {
181-
// Initialize MPI
181+
// Initialize MPI
182182
ORBIT_MPI_Init();
183183

184184
PyObject *m, *d;

0 commit comments

Comments
 (0)