(
atom_count: usize,
partitions: &[MoleculePartition],
runtime: Duration,
progress: Vec<ProgressSnapshot>,
)
| 407 | } |
| 408 | |
| 409 | fn build_metrics( |
| 410 | atom_count: usize, |
| 411 | partitions: &[MoleculePartition], |
| 412 | runtime: Duration, |
| 413 | progress: Vec<ProgressSnapshot>, |
| 414 | ) -> HpcParallelMetrics { |
| 415 | let molecules = partitions.len(); |
| 416 | let seconds = runtime.as_secs_f64(); |
| 417 | let throughput_atoms_per_sec = if seconds > 0.0 { atom_count as f64 / seconds } else { 0.0 }; |
| 418 | let throughput_molecules_per_sec = if seconds > 0.0 { molecules as f64 / seconds } else { 0.0 }; |
| 419 | |
| 420 | let sizes: Vec<usize> = partitions.iter().map(|p| p.len()).collect(); |
| 421 | let mean = if sizes.is_empty() { |
| 422 | 0.0 |
| 423 | } else { |
| 424 | sizes.iter().sum::<usize>() as f64 / sizes.len() as f64 |
| 425 | }; |
| 426 | let max = sizes.iter().copied().max().unwrap_or(0) as f64; |
| 427 | let partition_imbalance_ratio = if mean > 0.0 { max / mean } else { 0.0 }; |
| 428 | |
| 429 | HpcParallelMetrics { |
| 430 | atoms_total: atom_count, |
| 431 | molecules_total: molecules, |
| 432 | runtime, |
| 433 | throughput_atoms_per_sec, |
| 434 | throughput_molecules_per_sec, |
| 435 | partition_imbalance_ratio, |
| 436 | progress, |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | fn validate_config(cfg: HpcParallelConfig) -> Result<(), HpcParallelError> { |
| 441 | if cfg.mp_batches == 0 { |
no test coverage detected