10#ifndef SIM_FIELD_STATS_RUNTIME_H
11#define SIM_FIELD_STATS_RUNTIME_H
15#include "sim_field_stats.h"
47#define SIM_FIELD_STATS_FEATURE_MASK_NONE 0u
50#define SIM_FIELD_STATS_FEATURE_MASK_DEFAULT \
51 (SIM_FIELD_STATS_FEATURE_PHASE_SUMMARY | SIM_FIELD_STATS_FEATURE_SPECTRAL | \
52 SIM_FIELD_STATS_FEATURE_PHASE_ADVANCED)
244 size_t *out_dominant_k);
346 size_t field_index,
size_t step_index,
359 size_t field_index,
size_t step_index,
370 uint64_t phase_lock_ns);
Multidimensional contiguous field abstraction with configurable layout.
Shared standalone buffer and buffer-view types.
SimBufferDataType
Scalar storage types supported by standalone buffers and generic views.
Definition sim_buffer.h:26
@ SIM_BUFFER_I32
Definition sim_buffer.h:30
@ SIM_BUFFER_U64
Definition sim_buffer.h:33
@ SIM_BUFFER_UNKNOWN
Definition sim_buffer.h:29
@ SIM_BUFFER_I64
Definition sim_buffer.h:31
@ SIM_BUFFER_DOUBLE
Definition sim_buffer.h:27
@ SIM_BUFFER_U32
Definition sim_buffer.h:32
@ SIM_BUFFER_U8
Definition sim_buffer.h:35
@ SIM_BUFFER_I8
Definition sim_buffer.h:34
@ SIM_BUFFER_COMPLEX_DOUBLE
Definition sim_buffer.h:28
bool sim_field_stats_compute_spectral_view(const SimFieldView *view, SimFieldStats *stats, size_t *out_dominant_k)
Compute FFT-derived spectral metrics for a generic field view.
uint32_t sim_field_stats_normalize_feature_mask(uint32_t feature_mask)
Clamp and expand a stats feature mask to supported dependencies.
SimFieldStatsFeature
Optional field-statistics feature families.
Definition sim_field_stats_runtime.h:40
@ SIM_FIELD_STATS_FEATURE_PHASE_ADVANCED
Definition sim_field_stats_runtime.h:43
@ SIM_FIELD_STATS_FEATURE_PHASE_SUMMARY
Definition sim_field_stats_runtime.h:41
@ SIM_FIELD_STATS_FEATURE_SPECTRAL
Definition sim_field_stats_runtime.h:42
void sim_field_stats_update_phase_lock(struct SimContext *context, size_t field_index, SimFieldStats *stats)
Update per-field EMA phase lock state and write it into stats.
void sim_field_stats_accumulator_finish(SimFieldStatsAccumulator *acc)
Finalize accumulated statistics into the destination snapshot.
SimFieldView sim_field_view_from_field(SimField *field)
Build a generic field view over a SimField.
void sim_field_stats_set_phase_thresholds(double abs_threshold, double rel_threshold)
Update global absolute and relative phase sample thresholds.
void sim_field_stats_set_phase_lock_thresholds(double on_threshold, double off_threshold)
Update global phase-lock hysteresis thresholds.
const SimPhaseCoherenceConfig * sim_field_stats_get_phase_config(void)
Return the global phase-coherence configuration.
void sim_field_stats_set_phase_smoothing(double smoothing_seconds)
Update the global phase-lock EMA smoothing time constant.
void sim_field_stats_accumulate_complex(SimFieldStatsAccumulator *acc, double real, double imag)
Accumulate one complex sample.
void sim_field_stats_profile_record_request(SimFieldStatsRuntimeProfile *profile, size_t field_index, size_t step_index, SimFieldStatsProfileSource source)
Record a field-statistics request and its cache/source path.
void sim_field_stats_set_phase_config(const SimPhaseCoherenceConfig *config)
Replace the global phase-coherence configuration.
void sim_field_stats_compute_phase_metrics(const SimFieldView *view, SimFieldStats *stats, const SimPhaseCoherenceConfig *config, size_t dominant_k)
Compute thresholded, weighted, and deramped phase metrics for a view.
@ SIM_FIELD_I8
Definition sim_field_stats_runtime.h:121
@ SIM_FIELD_DOUBLE
Definition sim_field_stats_runtime.h:114
@ SIM_FIELD_U64
Definition sim_field_stats_runtime.h:120
@ SIM_FIELD_U8
Definition sim_field_stats_runtime.h:122
@ SIM_FIELD_I32
Definition sim_field_stats_runtime.h:117
@ SIM_FIELD_UNKNOWN
Definition sim_field_stats_runtime.h:116
@ SIM_FIELD_I64
Definition sim_field_stats_runtime.h:118
@ SIM_FIELD_U32
Definition sim_field_stats_runtime.h:119
@ SIM_FIELD_COMPLEX_DOUBLE
Definition sim_field_stats_runtime.h:115
SimFieldStatsProfileSource
Source path recorded for the most recent stats request or computation.
Definition sim_field_stats_runtime.h:74
@ SIM_FIELD_STATS_PROFILE_SOURCE_DRIFT_COMPUTE
Definition sim_field_stats_runtime.h:79
@ SIM_FIELD_STATS_PROFILE_SOURCE_VIS_DRIFT_CACHE
Definition sim_field_stats_runtime.h:77
@ SIM_FIELD_STATS_PROFILE_SOURCE_DIRECT_COMPUTE
Definition sim_field_stats_runtime.h:80
@ SIM_FIELD_STATS_PROFILE_SOURCE_VIS_CACHE
Definition sim_field_stats_runtime.h:76
@ SIM_FIELD_STATS_PROFILE_SOURCE_NONE
Definition sim_field_stats_runtime.h:75
@ SIM_FIELD_STATS_PROFILE_SOURCE_VIS_COMPUTE
Definition sim_field_stats_runtime.h:78
void sim_field_stats_profile_record_compute(SimFieldStatsRuntimeProfile *profile, size_t field_index, size_t step_index, SimFieldStatsProfileSource source, const SimFieldStatsComputeTimings *timings)
Record a field-statistics computation and optional timings.
void sim_field_stats_profile_record_phase_lock(SimFieldStatsRuntimeProfile *profile, uint64_t phase_lock_ns)
Record phase-lock update duration.
void sim_field_stats_reset_topology_fields(SimFieldStats *stats)
Clear topology-related fields in a stats snapshot.
void sim_field_stats_set_phase_deramp(bool enabled)
Enable or disable dominant-bin deramping for advanced phase metrics.
void sim_field_stats_set_phase_weighted(bool weighted)
Select whether phase-lock decisions use weighted coherence.
void sim_field_stats_accumulate_real(SimFieldStatsAccumulator *acc, double value)
Accumulate one real sample.
SimBufferDataType SimFieldDataType
Legacy field-data type alias backed by SimBufferDataType.
Definition sim_field_stats_runtime.h:108
SimBufferView SimFieldView
Legacy field view alias backed by SimBufferView.
Definition sim_field_stats_runtime.h:128
void sim_field_stats_accumulator_begin(SimFieldStatsAccumulator *acc, SimFieldStats *stats)
Initialize a streaming accumulator with the default compute config.
void sim_field_stats_profile_reset(SimFieldStatsRuntimeProfile *profile, const SimFieldStatsComputeConfig *config)
Reset runtime stats profiling counters.
SimFieldStatsComputeConfig sim_field_stats_default_compute_config(void)
Return the default stats compute configuration.
bool sim_field_stats_feature_enabled(const SimFieldStatsComputeConfig *config, uint32_t feature)
Test whether feature is enabled in a compute config.
void sim_field_stats_compute_with_config(const struct SimField *field, SimFieldStats *out, const SimFieldStatsComputeConfig *config, SimFieldStatsComputeTimings *timings)
Compute field statistics with optional feature selection and timings.
void sim_field_stats_accumulator_begin_with_config(SimFieldStatsAccumulator *acc, SimFieldStats *stats, const SimFieldStatsComputeConfig *config)
Initialize a streaming accumulator with an explicit compute config.
Non-owning typed view over contiguous, strided, or indexed scalar storage.
Definition sim_buffer.h:41
Simulation runtime state.
Definition sim_context.h:70
Streaming accumulator for incrementally building SimFieldStats.
Definition sim_field_stats_runtime.h:133
double mean_square_im
Definition sim_field_stats_runtime.h:140
size_t phase_sample_count
Definition sim_field_stats_runtime.h:142
double max_abs
Definition sim_field_stats_runtime.h:139
double M2_im
Definition sim_field_stats_runtime.h:135
double sum_mag_sq
Definition sim_field_stats_runtime.h:138
SimFieldStats * stats
Definition sim_field_stats_runtime.h:145
double phase_mean_im
Definition sim_field_stats_runtime.h:141
uint32_t feature_mask
Definition sim_field_stats_runtime.h:144
double M2_re
Definition sim_field_stats_runtime.h:134
double M2_abs
Definition sim_field_stats_runtime.h:136
size_t sample_count
Definition sim_field_stats_runtime.h:143
Feature selection for one field-statistics computation.
Definition sim_field_stats_runtime.h:57
uint32_t feature_mask
Definition sim_field_stats_runtime.h:58
Wall-clock timings captured for one statistics computation.
Definition sim_field_stats_runtime.h:64
uint64_t spectral_wall_ns
Definition sim_field_stats_runtime.h:67
uint64_t phase_wall_ns
Definition sim_field_stats_runtime.h:68
uint64_t total_wall_ns
Definition sim_field_stats_runtime.h:65
uint64_t reduction_wall_ns
Definition sim_field_stats_runtime.h:66
Rolling counters for runtime field-statistics requests and costs.
Definition sim_field_stats_runtime.h:86
uint64_t drift_cache_hit_count
Definition sim_field_stats_runtime.h:90
uint64_t direct_compute_count
Definition sim_field_stats_runtime.h:94
size_t last_step_index
Definition sim_field_stats_runtime.h:101
uint64_t request_count
Definition sim_field_stats_runtime.h:88
uint64_t compute_count
Definition sim_field_stats_runtime.h:92
size_t last_field_index
Definition sim_field_stats_runtime.h:100
uint64_t drift_compute_count
Definition sim_field_stats_runtime.h:93
uint64_t phase_lock_last_ns
Definition sim_field_stats_runtime.h:97
uint64_t cache_hit_count
Definition sim_field_stats_runtime.h:89
SimFieldStatsComputeTimings total_compute
Definition sim_field_stats_runtime.h:98
SimFieldStatsComputeConfig config
Definition sim_field_stats_runtime.h:87
uint64_t cache_miss_count
Definition sim_field_stats_runtime.h:91
SimFieldStatsProfileSource last_source
Definition sim_field_stats_runtime.h:102
uint64_t phase_lock_total_ns
Definition sim_field_stats_runtime.h:96
uint64_t phase_lock_count
Definition sim_field_stats_runtime.h:95
SimFieldStatsComputeTimings last_compute
Definition sim_field_stats_runtime.h:99
Summary statistics for a scalar or complex field slice.
Definition sim_field_stats.h:14
Owning multidimensional field.
Definition field.h:157
Controls thresholded phase-coherence metrics and phase-lock detection.
Definition sim_field_stats_runtime.h:27
bool weighted
Definition sim_field_stats_runtime.h:30
double smoothing_constant
Definition sim_field_stats_runtime.h:33
double lock_off
Definition sim_field_stats_runtime.h:32
double lock_on
Definition sim_field_stats_runtime.h:31
bool deramp_enabled
Definition sim_field_stats_runtime.h:34
double abs_threshold
Definition sim_field_stats_runtime.h:28
double rel_threshold
Definition sim_field_stats_runtime.h:29