synthesizer.utils.profiling_utils

A submodule containing some utility functions for profiling Synthesizer.

This module defines a set of helper functions for running different types of “onboard” performance tests on the Synthesizer package.

For further details see the documentation on the functions below.

Functions

synthesizer.utils.profiling_utils.get_instrument_profile(label, filepath, filters=None, resolution=None)[source]

Load an instrument from a file or create and save it if not found.

This ensures that instruments (and their filters) are cached locally, allowing scripts to run on systems without internet access.

Parameters:
  • label (str) – The label of the instrument.

  • filepath (str) – The path to the HDF5 file.

  • filters (FilterCollection, optional) – The filters to use if creating.

  • resolution (unyt_quantity, optional) – The resolution to use if creating.

Returns:

The loaded or created instrument.

Return type:

Instrument

synthesizer.utils.profiling_utils.parse_and_collect_runtimes(threads, run_data_list, average_over, log_outpath, low_thresh)[source]

Process per-run timing data and prepare for plotting.

This function takes the list of per-run timing dictionaries and processes them into the format expected by the plotting functions. It groups runs by thread count, averages them, and filters out operations that don’t meet the low_thresh criterion.

Parameters:
  • threads (list) – The list of thread counts used in the test.

  • run_data_list (list) – List of dicts with per-run timing data.

  • average_over (int) – The number of times to average the test over.

  • log_outpath (str) – The path to save the log file.

  • low_thresh (float) – Fraction of total time threshold for inclusion.

Returns:

A dictionary containing the runtimes for each key. linestyles (dict):

A dictionary mapping keys to their respective linestyles.

Return type:

atomic_runtimes (dict)

synthesizer.utils.profiling_utils.plot_speed_up_plot(atomic_runtimes, threads, linestyles, call_counts, outpath, paper_style)[source]

Plot a strong scaling test, optionally in paper style.

Parameters:
  • atomic_runtimes (dict) – A dictionary containing the runtimes for each key.

  • threads (list) – A list of thread counts.

  • linestyles (dict) – A dictionary mapping keys to their respective linestyles.

  • call_counts (dict) – A dictionary containing call counts for each operation.

  • outpath (str) – The path to save the plot.

  • paper_style (bool) – If True, produces a figure sized 3.5” x 8” with the main legend placed below the speedup plot’s x-axis.

synthesizer.utils.profiling_utils.run_scaling_test(max_threads, average_over, log_outpath, plot_outpath, operation_function, kwargs, total_msg, low_thresh, paper_style=True)[source]

Run a scaling test for the Synthesizer package.

For this to deliver the full profiling potential Synthesizer should be installed with the ATOMIC_TIMING configuration option.

Parameters:
  • max_threads (int) – The maximum number of threads to test.

  • average_over (int) – The number of times to average the test over.

  • log_outpath (str) – The path to save the log file.

  • plot_outpath (str) – The path to save the plot.

  • operation_function (function) – The function to test.

  • kwargs (dict) – The keyword arguments to pass to the function.

  • total_msg (str) – The message to print for the total time.

  • low_thresh (float) – The threshold for low runtimes.

  • paper_style (bool) – If True, produces a figure sized 3.5” x 8” with the main legend placed below the speedup plot’s x-axis.