ssapy_toolkit.hpc

Helpers for distributing work across CPUs or nodes.

These utilities provide simple index-based partitioning that works with or without MPI.

Functions

distribute_array_no_mpi(unique_id, ...)

Compute a contiguous slice of work for a given worker.

get_unique_id(rank, run_number, cpus_per_node)

Calculates a unique ID based on the rank, run number, and CPUs per node.

get_unique_id2(rank, run_number, cpus_per_node)

Return a unique integer ID for a worker.

ssapy_toolkit.hpc.distribute_array_no_mpi(unique_id, total_jobs, array_size)[source]

Compute a contiguous slice of work for a given worker.

Parameters:
  • unique_id (int) – Unique worker identifier (e.g., from get_unique_id).

  • total_jobs (int) – Total number of workers sharing the work.

  • array_size (int) – Length of the 1D array being partitioned.

Returns:

(start_idx, end_idx) for the slice assigned to the worker, or (None, None) if no work is assigned.

Return type:

tuple[int | None, int | None]

ssapy_toolkit.hpc.get_unique_id(rank, run_number, cpus_per_node)[source]

Calculates a unique ID based on the rank, run number, and CPUs per node.

Parameters: rank (int): The rank of the CPU within the node. run_number (int): The current run number. cpus_per_node (int): The number of CPUs per node.

Returns: int: The unique ID for the given rank, run number, and CPUs per node.

ssapy_toolkit.hpc.get_unique_id2(rank, run_number, cpus_per_node)[source]

Return a unique integer ID for a worker.

Parameters:
  • rank (int) – Rank or index for the worker on a node.

  • run_number (int) – Index of the current run or batch.

  • cpus_per_node (int) – Number of CPUs available per node.

Returns:

Unique ID derived from rank, run number, and CPUs per node.

Return type:

int