|
| 1 | +# Benchmarks for `s2fft` |
| 2 | + |
| 3 | +Scripts for benchmarking `ss2ft` with `timeit` (and optionally `memory_profiler`). |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +The benchmark scripts are as follows: |
| 8 | + |
| 9 | + * `wigner.py` contains benchmarks for Wigner transforms (forward and inverse) |
| 10 | + * `spherical.py` contains benchmarks for spherical transforms (forward and inverse) |
| 11 | + |
| 12 | +The `benchmarking.py` module contains shared utility functions for defining and running |
| 13 | +the benchmarks. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +Each benchmark script defines a set of default parameter values to run the benchmarks |
| 18 | +over. A set of command line arguments can be used to control the benchmark runs, |
| 19 | +and optionally override parameter values benchmarked and specify a file to output |
| 20 | +the JSON formatted benchmark results to. Pass a `--help` argument to the script to |
| 21 | +display the usage message: |
| 22 | + |
| 23 | +``` |
| 24 | +usage: Run benchmarks [-h] [-number-runs NUMBER_RUNS] [-repeats REPEATS] |
| 25 | + [-parameter-overrides [PARAMETER_OVERRIDES [PARAMETER_OVERRIDES ...]]] |
| 26 | + [-output-file OUTPUT_FILE] |
| 27 | +
|
| 28 | +optional arguments: |
| 29 | + -h, --help show this help message and exit |
| 30 | + -number-runs NUMBER_RUNS |
| 31 | + Number of times to run the benchmark in succession in each |
| 32 | + timing run. |
| 33 | + -repeats REPEATS Number of times to repeat the benchmark runs. |
| 34 | + -parameter-overrides [PARAMETER_OVERRIDES [PARAMETER_OVERRIDES ...]] |
| 35 | + Override for values to use for benchmark parameter. A parameter |
| 36 | + name followed by space separated list of values to use. May be |
| 37 | + specified multiple times to override multiple parameters. |
| 38 | + -output-file OUTPUT_FILE |
| 39 | + File path to write JSON formatted results to. |
| 40 | +``` |
| 41 | + |
| 42 | +For example to run the spherical transform benchmarks using only the JAX implementations, |
| 43 | +running on a CPU (in double-precision) for `L` values 64, 128, 256, 512 and 1024 we |
| 44 | +would run from the root of the repository: |
| 45 | + |
| 46 | +```sh |
| 47 | +JAX_PLATFORM_NAME=cpu JAX_ENABLE_X64=1 python benchmarks/spherical.py -p L 64 128 256 512 1024 -p method jax |
| 48 | +``` |
| 49 | + |
| 50 | +Note the usage of environment variables `JAX_PLATFORM_NAME` and `JAX_ENABLE_X64` to |
| 51 | +configure the default device used by JAX and whether to enable double-precision |
| 52 | +computations by default respectively. |
0 commit comments