Skip to content

Commit 709a433

Browse files
committed
MPI build options and MPI testing.
1 parent 833bb2d commit 709a433

File tree

10 files changed

+436
-530
lines changed

10 files changed

+436
-530
lines changed

.github/workflows/compilation.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,28 @@ jobs:
121121
- name: Print Versions
122122
run: |
123123
.github/workflows/conda-versions.sh
124+
125+
mpich:
126+
runs-on: ubuntu-latest
127+
container:
128+
image: quay.io/centos/centos:stream9
129+
steps:
130+
- name: Install packages
131+
run: |
132+
dnf group install -y "Development Tools"
133+
dnf install -y python3-devel fftw3-devel mpich-devel hwloc-devel
134+
135+
- uses: actions/checkout@v4
136+
with:
137+
fetch-depth: 0
138+
- name: Build
139+
run: |
140+
.github/workflows/pip-build-mpich.sh
141+
142+
- name: Test
143+
run: |
144+
.github/workflows/pip-tests-mpi.sh
145+
146+
- name: Print Versions
147+
run: |
148+
.github/workflows/pip-versions.sh
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
python3 -m venv .po3
2+
sed -i 's|PATH="\$VIRTUAL_ENV\/"bin":\$PATH"|PATH="\$VIRTUAL_ENV\/"bin":\$PATH"\nsource /etc/profile.d/modules.sh\nmodule load mpi/mpich-x86_64|' .po3/bin/activate
3+
. .po3/bin/activate
4+
mpirun -V
5+
pip install -U pip
6+
pip install -r requirements.txt
7+
pip install -U setuptools
8+
pip install --verbose --config-settings=setup-args="-DUSE_MPI=mpich" .

.github/workflows/pip-tests-mpi.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
. .po3/bin/activate
2+
3+
# Simple test to check if MPI was linked at all
4+
mpirun -np 2 python examples/MPI_Tests/mpi_initialization_test.py | tee test.txt
5+
calculated_sha1=$(sha1sum test.txt | awk '{ print $1 }')
6+
[ "$calculated_sha1" != "d94e03044bf06c7a42d07505b50fa58b4b30e49a" ] && exit 1
7+
8+
# Uniformly charged sphere
9+
echo "Run with Ellipsoid space charge"
10+
mpirun -np 2 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py --SC ellipsoid| tee results.txt
11+
python examples/SpaceCharge/sc3D/read_sc_numbers.py
12+
[ $? != 0 ] && exit 1
13+
14+
echo "Run with FFT3D space charge"
15+
mpirun -np 2 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py --SC fft3d| tee results.txt
16+
python examples/SpaceCharge/sc3D/read_sc_numbers.py
17+
[ $? != 0 ] && exit 1
18+
19+
# this should fail as no space charge will give incorrect sphere size
20+
echo "Run with no space charge"
21+
mpirun -np 2 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py --SC none| tee results.txt
22+
python examples/SpaceCharge/sc3D/read_sc_numbers.py
23+
[ $? == 0 ] && exit 1
24+
25+
26+
# This tests that five nodes give the same result as one node
27+
echo "Run with 1 node."
28+
mpirun -np 1 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py | tee results1.txt
29+
calculated_sha1=$(sha1sum results1.txt | awk '{ print $1 }')
30+
31+
echo "Run with 5 nodes."
32+
mpirun -np 5 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py | tee results5.txt
33+
calculated_sha5=$(sha1sum results5.txt | awk '{ print $1 }')
34+
35+
echo "Diff between two runs."
36+
echo "$calculated_sha1" "$calculated_sha5"
37+
diff results1.txt results5.txt
38+
39+
[ "$calculated_sha1" != "$calculated_sha5" ] && exit 1
40+
41+
exit 0
42+

examples/MPI_Tests/mpi_initialization_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020

2121
mpi_init = orbit_mpi.MPI_Initialized()
22-
print ("debug mpi is initialized =",mpi_init," should be not zero.")
2322

2423
rank = orbit_mpi.MPI_Comm_rank(mpi_comm.MPI_COMM_WORLD)
2524
size = orbit_mpi.MPI_Comm_size(mpi_comm.MPI_COMM_WORLD)
2625

2726
if(rank == 0):
27+
print("debug mpi is initialized =", mpi_init, " should be not zero.")
2828
print ("debug there should only one line like this rank=",rank," N CPUs = ",size)
2929

3030
n_particles = 10
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sys
2+
with open('results.txt', 'r') as f:
3+
for line in f.readlines():
4+
if line.startswith('Final:'):
5+
sizes = line.split()[3:7]
6+
break
7+
print(sizes)
8+
for s in sizes:
9+
if abs(float(s) - 14.65) > 0.2:
10+
print(f'{s} out of range!')
11+
sys.exit(1)
12+
13+
print('Uniform Sphere check - OK')

examples/SpaceCharge/sc3D/sc_3D_fft_drift_latt_uniform_sphere_bunch.py

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

0 commit comments

Comments
 (0)