Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,28 @@ jobs:
- name: Print Versions
run: |
.github/workflows/conda-versions.sh
mpich:
runs-on: ubuntu-latest
container:
image: quay.io/centos/centos:stream9
steps:
- name: Install packages
run: |
dnf group install -y "Development Tools"
dnf install -y python3-devel fftw3-devel mpich-devel hwloc-devel
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build
run: |
.github/workflows/pip-build-mpich.sh
- name: Test
run: |
.github/workflows/pip-tests-mpi.sh
- name: Print Versions
run: |
.github/workflows/pip-versions.sh
8 changes: 8 additions & 0 deletions .github/workflows/pip-build-mpich.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
python3 -m venv .po3
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
. .po3/bin/activate
mpirun -V
pip install -U pip
pip install -r requirements.txt
pip install -U setuptools
pip install --verbose --config-settings=setup-args="-DUSE_MPI=mpich" .
42 changes: 42 additions & 0 deletions .github/workflows/pip-tests-mpi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
. .po3/bin/activate

# Simple test to check if MPI was linked at all
mpirun -np 2 python examples/MPI_Tests/mpi_initialization_test.py | tee test.txt
calculated_sha1=$(sha1sum test.txt | awk '{ print $1 }')
[ "$calculated_sha1" != "d94e03044bf06c7a42d07505b50fa58b4b30e49a" ] && exit 1

# Uniformly charged sphere
echo "Run with Ellipsoid space charge"
mpirun -np 2 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py --SC ellipsoid| tee results.txt
python examples/SpaceCharge/sc3D/read_sc_numbers.py
[ $? != 0 ] && exit 1

echo "Run with FFT3D space charge"
mpirun -np 2 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py --SC fft3d| tee results.txt
python examples/SpaceCharge/sc3D/read_sc_numbers.py
[ $? != 0 ] && exit 1

# this should fail as no space charge will give incorrect sphere size
echo "Run with no space charge"
mpirun -np 2 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py --SC none| tee results.txt
python examples/SpaceCharge/sc3D/read_sc_numbers.py
[ $? == 0 ] && exit 1


# This tests that five nodes give the same result as one node
echo "Run with 1 node."
mpirun -np 1 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py | tee results1.txt
calculated_sha1=$(sha1sum results1.txt | awk '{ print $1 }')

echo "Run with 5 nodes."
mpirun -np 5 python examples/SpaceCharge/sc3D/sc_3d_drift_latt_uniform_sphere_bunch.py | tee results5.txt
calculated_sha5=$(sha1sum results5.txt | awk '{ print $1 }')

echo "Diff between two runs."
echo "$calculated_sha1" "$calculated_sha5"
diff results1.txt results5.txt

[ "$calculated_sha1" != "$calculated_sha5" ] && exit 1

exit 0

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,15 @@ Navigate to your **examples** directory and launch tracking of SNS linac.
cd examples/SNS_Linac/pyorbit3_linac_model/
python pyorbit3_sns_linac_mebt_hebt2.py
```

## 5. MPI consideration
By default, the build system will try to find MPI and compile against it. You can control which MPI to use with command line option when building.
```bash
pip install --config-settings=setup-args="-DMPI_USE=none" .
```
Above will build PyORBIT without MPI even if MPI is present. You can change that option to `mpich`, `ompi`, `none` or `auto` (default).<br>
Meson uses PKG_CONFIG to discover packages. It could be useful to help it to find your MPI installation:

```bash
PKG_CONFIG_PATH=/opt/lib/pkgconfig pip install --verbose .
```
2 changes: 1 addition & 1 deletion examples/MPI_Tests/mpi_initialization_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@


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

rank = orbit_mpi.MPI_Comm_rank(mpi_comm.MPI_COMM_WORLD)
size = orbit_mpi.MPI_Comm_size(mpi_comm.MPI_COMM_WORLD)

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

n_particles = 10
Expand Down
13 changes: 13 additions & 0 deletions examples/SpaceCharge/sc3D/read_sc_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys
with open('results.txt', 'r') as f:
for line in f.readlines():
if line.startswith('Final:'):
sizes = line.split()[3:7]
break
print(sizes)
for s in sizes:
if abs(float(s) - 14.65) > 0.2:
print(f'{s} out of range!')
sys.exit(1)

print('Uniform Sphere check - OK')
264 changes: 0 additions & 264 deletions examples/SpaceCharge/sc3D/sc_3D_fft_drift_latt_uniform_sphere_bunch.py

This file was deleted.

Loading