MCPcopy Create free account
hub / github.com/Open-Quant/openquant / run_serial

Function run_serial

crates/openquant/src/hpc_parallel.rs:239–274  ·  view source on GitHub ↗
(
    atoms: &[A],
    partitions: &[MoleculePartition],
    progress_every: usize,
    callback: &F,
)

Source from the content-addressed store, hash-verified

237}
238
239fn 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>
245where
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
276fn run_threaded<A, R, F, E>(
277 atoms: &[A],

Callers 1

run_parallelFunction · 0.85

Calls 2

maybe_record_progressFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected