dynamite.tools

Various tools useful for writing and analyzing dynamite programs.

dynamite.tools.MPI_COMM_WORLD()[source]

Returns PETSc’s COMM_WORLD object. Can be converted to an mpi4py communicator object via the .tompi4py() method.

dynamite.tools.mpi_print(*args, rank=0, **kwargs)[source]

Print from only a single MPI rank, default rank 0.

Aside from the extra “rank” keywork argument, call signature is the same as Python 3’s print() function.

dynamite.tools.get_version()[source]

Gets the version information for dynamite, and the PETSc and SLEPc libraries it’s built on.

Returns:

A dictionary with the keys ‘PETSc’, ‘SLEPc’, and ‘dynamite’

Return type:

dict

dynamite.tools.get_version_str()[source]

Get a string with the version information for PETSc, SLEPc, and dynamite.

Returns:

The version string

Return type:

str

dynamite.tools.track_memory()[source]

Begin tracking memory usage for a later call to get_memory_usage(..., max_usage=True).

dynamite.tools.get_memory_usage(group_by='all', max_usage=False)[source]

Get the memory usage, in gigabytes.

Note

track_memory() must be called before this function is called with max_usage=True.

Note

Grouping by node only works if MPI is configured to allow shared memory between ranks on the same node. If it is not, it may consider each rank its own “node.” Whether this is the case can be seen by observing whether the value returned by this function is identical for all ranks on the same node, or if it is instead the same as the value returned for group_by='rank'.

Parameters:
  • group_by (str) – What ranks to sum memory usage over. Options are “rank”, which will return each rank’s individual memory usage (which may be different across ranks); “node”, which will sum over ranks sharing the same memory (and thus again the result may differ between ranks); and “all”, which returns the total memory usage of all ranks.

  • max_usage (bool) – Instead of current memory usage, report maximum since the call to track_memory(). Note that maximum is only updated when PETSc objects are destroyed, which may be delayed due to garbage collection.

Returns:

The memory usage in gigabytes

Return type:

float

dynamite.tools.get_max_memory_usage(which='all')[source]

[deprecated]

dynamite.tools.get_cur_memory_usage(which='all')[source]

[deprecated]

dynamite.tools.complex_enabled()[source]