Skip to content

Commit 538d8b7

Browse files
committed
feat: add load and alloc operation
1 parent 68c1ef2 commit 538d8b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+449
-178
lines changed

descend_derive/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ edition = "2018"
99
[lib]
1010
proc-macro = true
1111

12+
[build-dependencies]
13+
1214
[dependencies]
1315
syn = { version = "1.0", features = ["full"] }
1416
quote = "1.0"

descend_derive/build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use std::fs;
2+
use std::path::Path;
3+
4+
fn main() {
5+
// Tell Cargo to re-run this build script if any .desc files change
6+
let examples_dir = "examples/core";
7+
8+
if Path::new(examples_dir).exists() {
9+
// Walk through the directory and tell Cargo to re-run if any .desc files change
10+
if let Ok(entries) = fs::read_dir(examples_dir) {
11+
for entry in entries.flatten() {
12+
if let Some(path) = entry.path().to_str() {
13+
if path.ends_with(".desc") {
14+
println!("cargo:rerun-if-changed={}", path);
15+
}
16+
}
17+
}
18+
}
19+
}
20+
21+
// Also watch the entire directory for new files
22+
println!("cargo:rerun-if-changed={}", examples_dir);
23+
}

descend_derive/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ pub fn span_derive(attr: TokenStream, input: TokenStream) -> TokenStream {
152152
/// Proc macro to automatically generate tests for all .desc files in examples/core/
153153
#[proc_macro]
154154
pub fn generate_desc_tests(_input: TokenStream) -> TokenStream {
155-
// Use include_dir! to properly track filesystem dependencies
156-
// This ensures Cargo knows to re-run the macro when files change
155+
// Use include_dir! as a fallback for compile-time file inclusion
156+
// This ensures the files are available even if the directory structure changes
157157
let dir = include_dir::include_dir!("$CARGO_MANIFEST_DIR/../examples/core");
158158

159159
let mut test_functions = Vec::new();
@@ -197,7 +197,7 @@ pub fn generate_desc_tests(_input: TokenStream) -> TokenStream {
197197
"use" => "use_stmt".to_string(),
198198
"where" => "where_clause".to_string(),
199199
"while" => "while_loop".to_string(),
200-
"unit" => "simple_unit".to_string(),
200+
"unit" => "core_unit".to_string(),
201201
"func" => "func_call".to_string(),
202202
"test_no_main" => "no_main".to_string(),
203203
_ => test_name,

examples/core/lazy_load_ub.desc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn memory_load<n: nat, r: prv>(
2+
a: &r shrd gpu.global [i16; 16],
3+
b: &r uniq gpu.global [i16; 16]
4+
) -[grid: gpu.grid<X<1>, X<16>>]-> () {
5+
()
6+
}

examples/core/load_ub.desc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn memory_load<n: nat, r: prv>(
2+
a: &r shrd gpu.global [i16; 16]
3+
) -[grid: gpu.grid<X<1>, X<16>>]-> () {
4+
a;
5+
()
6+
}

examples/core/load_ub_twice.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn memory_load<n: nat, r: prv>(
2+
a: &r shrd gpu.global [i16; 16],
3+
b: &r uniq gpu.global [i16; 16]
4+
) -[grid: gpu.grid<X<1>, X<16>>]-> () {
5+
a;
6+
b;
7+
()
8+
}

examples/core/vec_add.desc.off

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn add<n: nat, r: prv>(
2+
a: &r shrd gpu.global [i16; 16],
3+
b: &r shrd gpu.global [i16; 16],
4+
c: &r uniq gpu.global [i16; 16]
5+
) -[grid: gpu.grid<X<1>, X<16>>]-> () {
6+
a + b;
7+
()
8+
}

examples/core/vec_add_1.desc.off

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn add<n: nat, r: prv>(
2+
a: &r shrd gpu.global [i16; 16],
3+
b: &r shrd gpu.global [i16; 16],
4+
c: &r uniq gpu.global [i16; 16]
5+
) -[grid: gpu.grid<X<1>, X<16>>]-> () {
6+
c = a + b;
7+
()
8+
}

examples/core/vec_add_2.desc.off

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn add<n: nat, r: prv>(
2+
a: &r shrd gpu.global [i16; 16],
3+
b: &r shrd gpu.global [i16; 16],
4+
c: &r uniq gpu.global [i16; 16],
5+
d: &r uniq gpu.global [i16; 16],
6+
e: &r uniq gpu.global [i16; 16]
7+
) -[grid: gpu.grid<X<1>, X<16>>]-> () {
8+
d = a + b;
9+
e = b + c;
10+
()
11+
}

examples/core/vec_add_3.desc.off

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn add<n: nat, r: prv>(
2+
a: &r shrd gpu.global [i16; 16],
3+
b: &r shrd gpu.global [i16; 16]
4+
) -[grid: gpu.grid<X<1>, X<16>>]-> () {
5+
a + b;
6+
()
7+
}

0 commit comments

Comments
 (0)