ppvm_vihaco::shots
shots¶
ppvm_vihaco::shots
Running a compiled program for many shots, optionally across threads.
Each shot runs on a fresh PPVM so shots are fully independent; the module is compiled once and cloned into each shot’s machine. With the `rayon` feature, run_shots parallelizes across shots when the global pool (sized once by set_global_threads) has more than one thread and there are enough shots to amortize the overhead.
classShotRecord¶source
ppvm_vihaco::shots::ShotRecord
Bases: Debug, Clone, StructuralPartialEq, PartialEq, Default
Rust struct. One shot's full output: the measurement record and the trace-instruction record. Either may be empty depending on what the program emits.
pub struct ShotRecordFields
| Name | Type | Description |
|---|---|---|
measurements | Vec<MeasurementResult> | |
traces | Vec<f64> |
propertyPARALLEL_SHOT_THRESHOLD¶
ppvm_vihaco::shots::PARALLEL_SHOT_THRESHOLD
pub const PARALLEL_SHOT_THRESHOLD: usizeBelow this many shots, parallelism’s overhead outweighs its benefit and we always run serially. Provisional — tune with benchmarks.
functionrun_shots¶source
ppvm_vihaco::shots::run_shots
Signature
pub fn run_shots(module: &PPVMModule, shots: usize, seed: Option<u64>) -> Result<Vec<ShotRecord>>Parameters
| Name | Type | Description |
|---|---|---|
module | &PPVMModule | |
shots | usize | |
seed | Option<u64> |
Returns
Result<Vec<ShotRecord>>
Run `shots` shots, choosing serial or parallel execution. Goes parallel only when built with `rayon`, the global pool has more than one thread, and there are enough shots to be worth it; otherwise runs serially. The pool size is set once at startup by set_global_threads.
sourcefunctionrun_shots_serial¶source
ppvm_vihaco::shots::run_shots_serial
Signature
pub fn run_shots_serial(module: &PPVMModule, shots: usize, seed: Option<u64>) -> Result<Vec<ShotRecord>>Parameters
| Name | Type | Description |
|---|---|---|
module | &PPVMModule | |
shots | usize | |
seed | Option<u64> |
Returns
Result<Vec<ShotRecord>>
Run `shots` shots serially. One entry per shot, in order.
sourcefunctionset_global_threads¶source
ppvm_vihaco::shots::set_global_threads
pub fn set_global_threads(threads: usize) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
threads | usize |
Returns
Result<()>
Without the `rayon` feature there is no pool to size; anything but a single thread is meaningless, so reject it rather than silently run serially.
source