Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20230415 rayon parallel propagation #216

Closed
wants to merge 13 commits into from

Conversation

shnarazk
Copy link
Owner

@shnarazk shnarazk commented Apr 15, 2023

  • separate check and perform
  • rename PropagationContext to ClauseTransformer; then we have to make an entry point to ClauseDB that takes a ClauseTransformer???
  • collect transformers in parallel, then execute them under an immutable context sequentially
  • revise to the new IF
  • refactor check_in debug codes

Wow!!! It's getting slow!

I found Rayon was not good for this. I need something better.

The first idea

  • current implementation
for watch in &mut watchlist {
  check_another_watcher()?;
}
  • (watchlist-level) parallel propagate
let bucket = watchlist[lit].into_par_iter().map(|w| seek_another_watcher(self: &AssignStack));
if bucket.iter().any(conflicting) {
   return Conflict();
)
for (cid, to) in bucket.iter().map(|p| p.unwrap()) {
   watchlist[to].push(cid);
}
watchlist[lit].clear();

a problem caused by inappropriate evaluation assumption

A new assignment (implication) modifies the checking context. We have to purge the remains and rebuild them.

'new_context: while start < watch_list.len() {
  // parallel part
  let transformers = watch_list[start..start+bucket_size].iter().map().collect();
  // sequential part
  let mut processed = 0;
  for (i, transformer) in transformers.iter() {
     processed += 1;
     ...
     if got_new_assign {
        start = i + 1;
        continue 'new_context;
     }
  }
  start += processed;
}

@shnarazk shnarazk self-assigned this Apr 15, 2023
@shnarazk shnarazk changed the title rayon-propagete as 0.18.0-alpha.2 20230415 rayon propagation Apr 15, 2023
@shnarazk shnarazk mentioned this pull request Apr 15, 2023
4 tasks
src/assign/propagate.rs Outdated Show resolved Hide resolved
}
PropagationContext::UpdateWatch(cid, new_watch, k, false_watch_pos) => {
cdb.detach_watch_cache(propagating, &mut source);
cdb.transform_by_updating_watch(cid, false_watch_pos, k, true);
Copy link
Owner Author

@shnarazk shnarazk Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 This function reorders the items in the watchlist by calling swap_remove! 🐛

Copy link
Owner Author

@shnarazk shnarazk Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have to

  1. build a new list during the iteration, then swap to the original.
  2. execute in-place shrinking, then resize after the iteration
  3. use $O(n)$ remove

@shnarazk shnarazk changed the title 20230415 rayon propagation 20230415 rayon parallel propagation Apr 16, 2023
@shnarazk shnarazk mentioned this pull request Jul 5, 2023
4 tasks
@shnarazk shnarazk closed this Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🙂 Done
Development

Successfully merging this pull request may close these issues.

1 participant