Skip to content

Modify skip condition for tests not involving MPI to include compile-time and runtime check#3209

Merged
oskooi merged 2 commits intoNanoComp:masterfrom
oskooi:unit_test_skip_nonmpi
Apr 28, 2026
Merged

Modify skip condition for tests not involving MPI to include compile-time and runtime check#3209
oskooi merged 2 commits intoNanoComp:masterfrom
oskooi:unit_test_skip_nonmpi

Conversation

@oskooi
Copy link
Copy Markdown
Collaborator

@oskooi oskooi commented Apr 26, 2026

Root cause: The test_mpi skip condition used in test_simulation.py (as well as test_dump_load.py) only checks the compile-time flag mp.with_mpi() (was Meep built with MPI?), but contains an assertion which requires a runtime condition (multiple MPI processes via mpirun). When compiled with --with-mpi --with-openmp and run directly (e.g., OMP_NUM_THREADS=2 python -m unittest, i.e., not as part of make check which uses mpirun -np 2 python ...), the test is not skipped but the assertion fails because Get_size() returns 1 (no mpirun).

Fix: Add mp.count_processors() < 2 to the skip condition, so the test is skipped (not failed) when not running mpirun with multiple processes. Also switch from mp.comm.Get_size() to mp.count_processors() for consistency with the C++ API.

@oskooi oskooi merged commit 04d3e70 into NanoComp:master Apr 28, 2026
4 checks passed
@oskooi oskooi deleted the unit_test_skip_nonmpi branch April 28, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant