-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jess Frazelle <github@jessfraz.com>
- Loading branch information
Showing
10 changed files
with
1,471 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,6 @@ cuda_builder = "0.3.0" | |
|
||
[workspace] | ||
members = [ | ||
"generator", | ||
#"generator", | ||
"gpu", | ||
] |
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,46 @@ | ||
//! CUDA Kernel for day 08: Haunted Wasteland | ||
|
||
use cuda_std::*; | ||
|
||
/// Traverse the graph from nodes ending with A until all nodes reach nodes | ||
/// ending with Z. | ||
#[kernel] | ||
#[allow(clippy::missing_safety_doc)] | ||
pub unsafe fn graph_traversal( | ||
graph: &[(u32, u32)], | ||
start: &[u32], | ||
goals: &[u32], | ||
directions: &[bool], // true for left, false for right | ||
nodes: *mut u32, | ||
steps: *mut u64, | ||
) { | ||
let nodes_len = goals.len(); | ||
let mut items = start.to_vec(); | ||
for i in directions { | ||
let idx = thread::index_1d() as usize; | ||
let mut found = true; | ||
|
||
if idx < nodes_len { | ||
let mut node = items[idx]; | ||
if *i { | ||
node = graph[node as usize].0; | ||
} else { | ||
node = graph[node as usize].1; | ||
} | ||
|
||
if found && !goals.contains(&node) { | ||
found = false; | ||
} | ||
|
||
items.insert(idx, node); | ||
let elem = &mut *nodes.add(idx); | ||
*elem = node; | ||
let elem = &mut *steps.add(idx); | ||
*elem = 1; | ||
} | ||
|
||
if found { | ||
break; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -28,3 +28,4 @@ | |
extern crate alloc; | ||
|
||
pub mod add; | ||
pub mod day08; |
Oops, something went wrong.