can_allocate#

caput.util.mpitools.can_allocate(nbytes: int, scope: str = 'shared', comm: mpi4py.MPI.Comm | None = world, scomm: mpi4py.MPI.Comm | None = None) bool[source]#

Check if nbytes of memory is available to allocate.

nbytes can be the number of bytes allocated per process, number of bytes allocated in all shared memory, or number of bytes allocated globally when there are processes which do not share memory.

Parameters:
nbytesint

Number of bytes that we want to allocate.

scope{“shared”, “process”, “global”}, optional

Whether to find available memory on a per-node, per-process, or global basis. Default is “shared”.

commMPI.Comm | None, optional

MPI communicator.

scommMPI.Comm | None, optional

MPI shared memory communicator.

Returns:
memory_is_availablebool

True if there is enough memory available.