Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rust/loop-reduction/src/runtime/reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ impl PolynomialPlan {
precision: Option<u32>,
engine: &str,
) -> ExecutionResult<Self> {
// Standalone generation callers also parse Symbolica expressions here.
let _unlock = pyamplicol::unlock();
let (arithmetic, bits) = arithmetic_mode(arithmetic, precision)?;
if !matches!(engine, "generic" | "fast" | "fast-tensor") {
return Err(error("engine must be generic, fast or fast-tensor"));
Expand Down
44 changes: 44 additions & 0 deletions rust/loop-reduction/tests/runtime_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,50 @@
//! Real scalar masters and epsilon assembly are available without PyO3.
use rusticol_loop_reduction::runtime::{Batch, PolynomialPlan};

#[test]
fn standalone_reducer_construction_keeps_package_scope() {
assert!(
pyamplicol::is_active(),
"pyAmpliCol's package key must be active"
);
let ready = std::sync::Barrier::new(2);
std::thread::scope(|scope| {
let workers: Vec<_> = (0..2)
.map(|_| {
scope.spawn(|| {
let mut plans = Vec::new();
for (arithmetic, precision, engine) in [
("double", None, "generic"),
("double", None, "fast"),
("double", None, "fast-tensor"),
("double-double", None, "generic"),
("arbitrary", Some(60), "generic"),
] {
plans.push(
PolynomialPlan::new(
1,
["1".into(), "0".into(), "0".into()],
vec![],
arithmetic,
precision,
engine,
)
.unwrap(),
);
}
// Keep both calling threads alive: an unguarded constructor
// consumes a restricted permit and makes the other abort.
ready.wait();
assert_eq!(plans.len(), 5);
})
})
.collect();
for worker in workers {
worker.join().unwrap();
}
});
}

#[test]
fn standalone_reduction_preserves_epsilon_order_and_sparse_results() {
for (arithmetic, precision, engine) in [
Expand Down