-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f608ff8
commit 8e4ca38
Showing
12 changed files
with
109 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use rayon::iter::{FromParallelIterator, IntoParallelIterator, ParallelIterator}; | ||
|
||
use crate::Database; | ||
|
||
pub fn par_map<Db, D, E, C>( | ||
db: &Db, | ||
inputs: impl IntoParallelIterator<Item = D>, | ||
op: fn(&Db, D) -> E, | ||
) -> C | ||
where | ||
Db: Database, | ||
D: Send, | ||
E: Send + Sync, | ||
C: FromParallelIterator<E>, | ||
{ | ||
dbg!(db.zalsa().views()); | ||
let fork_db_a: Box<dyn Database> = db.fork_db(); | ||
let db: &Db = fork_db_a.as_view::<Db>(); | ||
|
||
todo!() | ||
// inputs | ||
// .into_par_iter() | ||
// .map_with(wrapper, |db, element| op(db, element)) | ||
// .collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use common::{LogDatabase, LoggerDatabase}; | ||
use salsa::{plumbing::ZalsaDatabase, Database}; | ||
|
||
mod common; | ||
|
||
#[salsa::input] | ||
struct ParallelInput { | ||
field: u32, | ||
} | ||
|
||
#[salsa::tracked] | ||
struct TrackedData<'db> { | ||
field: u32, | ||
} | ||
|
||
#[salsa::tracked] | ||
fn tracked_fn(db: &dyn LogDatabase, input: ParallelInput) -> u32 { | ||
db.push_log(format!("tracked_fn({input:?})")); | ||
let t = TrackedData::new(db, input.field(db) * 2); | ||
tracked_fn_extra::specify(db, t, 2222); | ||
tracked_fn_extra(db, t) | ||
} | ||
|
||
#[salsa::tracked(specify)] | ||
fn tracked_fn_extra<'db>(db: &dyn LogDatabase, input: TrackedData<'db>) -> u32 { | ||
db.push_log(format!("tracked_fn_extra({input:?})")); | ||
0 | ||
} | ||
|
||
#[test] | ||
fn execute() { | ||
let db = common::LoggerDatabase::default(); | ||
|
||
let inputs = (1..=10) | ||
.map(|field| { | ||
let input = ParallelInput::new(&db, field); | ||
let i = tracked_fn(&db, input); | ||
input | ||
}) | ||
.collect::<Vec<ParallelInput>>(); | ||
|
||
dbg!(db.zalsa().views()); | ||
|
||
let _foo: Vec<u32> = salsa::par_map(&db, inputs, |db, field| field.field(db)); | ||
} |