settings.h#
#include <sif/core/settings.h>
-
SIF_CORE_SETTINGS_H#
Persistent key/value runtime settings.
The table is process-global, populated by sif_init() from the settings file and written back on sif_finalize() if anything changed. Values may reference environment variables (
$HOME,${USER}), which are expanded on write and stored alongside the raw text.Warning
The table is not synchronized. Reads are safe once the settings are populated, but calling sif_setting_set() concurrently with any other access is a data race – and so is sif_setting_get() with a fallback, which writes the fallback into the table when the key is absent.
-
SIF__FFT_TUNING_MAX_GIB_DEFAULT#
Default for the
fft_tuning_max_gibsetting.FFTW_MEASURE picks its plan by running the transform, repeatedly, so the cost of tuning grows with the transform while the benefit does not: one better plan, however large the grid. Past some size the planning outlasts the run it was meant to speed up – measured on a 2250^3 grid it does not finish in any useful time at all – so above this many GiB of spectrum the library plans both transforms with FFTW_ESTIMATE and says so.
16 GiB sits just above a 1500^3 single-precision spectrum (12.6 GiB), which tunes in reasonable time, and below 2048^3 (32 GiB), which does not. Raise it if a grid between those is worth the wait; 0 turns tuning off outright.
This is a ceiling, not a request:
skip_tuningstill decides whether tuning is wanted at all, and the cap only ever takes it away.
-
SIF__CIC_TILE_PARTICLES_DEFAULT#
Default for the
cic_tile_particlessetting.The CIC deposit sorts particles by destination slab through an index array of 8 bytes each, and does it a tile at a time so that array does not scale with the field: 512 MiB here, against 27 GB for a 3.4e9-tracer field sorted in one go and 69 GB at 8.6e9.
Tiling is also the faster arrangement – the deposit’s indirect reads stay inside a slice of the coordinates instead of ranging over all of them – and the gain is broad enough that this does not want tuning. Lower it if the scratch is still too much; the cost is one extra pass over the slabs per tile, which only starts to show when the tiles get small.
-
void sif_setting_set(const char *key, const char *value)#
Set a runtime setting, creating it if absent and overwriting if not.
The value takes effect immediately and the table is flagged for saving at finalization. Environment references in
valueare expanded now, not at read time, so a later change to the environment is not picked up.Keys are truncated at 63 characters, values at 255, with a warning.
- Parameters:
key – Setting name. Ignored if NULL, or if called before sif_init().
value – Raw value, possibly containing environment references.
Note
The file format is one
key = valueper line with no escaping, so a key containing=or a newline, or a value containing a newline, would not read back as what was written and is rejected with a warning.Warning
Adding a new key may reallocate the table, which invalidates every pointer previously returned by sif_setting_get().
-
const char *sif_setting_get(const char *key, const char *fallback)#
Look up a runtime setting, with an optional default.
If
keyis missing andfallbackis non-NULL, the fallback is inserted into the table underkeyand then returned, so the next call finds it.- Parameters:
key – Setting name.
fallback – Value to install and return if the key is absent. May be NULL to query without creating.
- Returns:
The expanded value, owned by the settings table – the caller must neither free nor modify it. Returns
fallbackunexpanded if the table is not yet populated or the entry could not be created, and NULL if the key is absent and no fallback was given.
Warning
The returned pointer is valid only until the next sif_setting_set(), including the implicit one this function performs when it installs a fallback. Copy the string if it has to outlive that.