(
atoms: &[A],
partitions: &[MoleculePartition],
progress_every: usize,
callback: &F,
)
| 237 | } |
| 238 | |
| 239 | fn run_serial<A, R, F, E>( |
| 240 | atoms: &[A], |
| 241 | partitions: &[MoleculePartition], |
| 242 | progress_every: usize, |
| 243 | callback: &F, |
| 244 | ) -> Result<(Vec<R>, Vec<ProgressSnapshot>), HpcParallelError> |
| 245 | where |
| 246 | F: Fn(&[A]) -> Result<R, E>, |
| 247 | E: Display, |
| 248 | { |
| 249 | let total = partitions.len(); |
| 250 | let started = Instant::now(); |
| 251 | let mut outputs = Vec::with_capacity(total); |
| 252 | let mut progress = Vec::new(); |
| 253 | let mut completed_atoms = 0usize; |
| 254 | |
| 255 | for part in partitions { |
| 256 | let out = callback(&atoms[part.start..part.end]).map_err(|err| { |
| 257 | HpcParallelError::CallbackFailed { |
| 258 | molecule_id: part.molecule_id, |
| 259 | message: err.to_string(), |
| 260 | } |
| 261 | })?; |
| 262 | outputs.push(out); |
| 263 | completed_atoms += part.len(); |
| 264 | maybe_record_progress( |
| 265 | &mut progress, |
| 266 | started.elapsed(), |
| 267 | outputs.len(), |
| 268 | total, |
| 269 | completed_atoms, |
| 270 | progress_every, |
| 271 | ); |
| 272 | } |
| 273 | Ok((outputs, progress)) |
| 274 | } |
| 275 | |
| 276 | fn run_threaded<A, R, F, E>( |
| 277 | atoms: &[A], |
no test coverage detected