Coverage for pySDC/helpers/fft_helper.py: 83%

6 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-25 20:28 +0000

1""" 

2Ownership of ``mpi4py-fft`` transform objects. 

3 

4A ``PFFT`` allocates MPI communicators -- ``MPI_Cart_create`` plus an ``MPI_Cart_sub`` per axis -- 

5and does not release them when the Python object is collected. A process that builds many of them 

6therefore runs out of communicator contexts: measured at **1022 creations** on MPICH 4.3.2, failing 

7with ``MPI_Cart_create(MPI_COMM_WORLD, ndims=3, ...) failed``. 

8 

9This never surfaced while every MPI test got its own short-lived ``mpirun``, since no single process 

10lived long enough to reach the limit. It does surface once a whole test session shares one process, 

11and it would equally hit any long-running driver that builds many problems. 

12 

13``PFFT.destroy()`` is the release path. It is idempotent, and arrays already created with 

14``newDistArray`` stay usable afterwards, so tying it to garbage collection is safe. 

15""" 

16 

17from mpi4py_fft import PFFT as _PFFT 

18 

19 

20class PFFT(_PFFT): 

21 """A :class:`mpi4py_fft.PFFT` that frees its MPI communicators when it is collected.""" 

22 

23 def __del__(self): 

24 try: 

25 self.destroy() 

26 except Exception: 

27 # Nothing useful can be done here: this runs during garbage collection, possibly at 

28 # interpreter shutdown with MPI already finalized, and raising would only print noise. 

29 pass