Skip to content

Commit ea6c69b

Browse files
committed
adjust examples and difftests to new safe functions
1 parent a5b1ccb commit ea6c69b

File tree

4 files changed

+12
-34
lines changed
  • examples/shaders/reduce/src
  • tests/difftests/tests/arch
    • atomic_ops/atomic_ops-rust/src
    • memory_barriers/memory_barriers-rust/src
    • workgroup_memory/workgroup_memory-rust/src

4 files changed

+12
-34
lines changed

examples/shaders/reduce/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn main(
5454
if subgroup_local_invocation_id == 0 {
5555
shared[subgroup_id as usize] = sum;
5656
}
57-
unsafe { spirv_std::arch::workgroup_memory_barrier_with_group_sync() };
57+
spirv_std::arch::workgroup_memory_barrier_with_group_sync();
5858
let mut sum = 0;
5959
if subgroup_id == 0 {
6060
if subgroup_local_invocation_id < num_subgroups {

tests/difftests/tests/arch/atomic_ops/atomic_ops-rust/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ pub fn main_cs(
3131
// Thread 0 stores the final values after all operations complete
3232
if tid == 0 {
3333
// Use atomic loads to ensure we read the final values
34-
unsafe {
35-
spirv_std::arch::workgroup_memory_barrier_with_group_sync();
36-
}
34+
spirv_std::arch::workgroup_memory_barrier_with_group_sync();
3735
output[0] = counters[0]; // Should be initial + 32
3836
output[1] = counters[1]; // Should be initial - 32
3937
output[2] = counters[2]; // Should be min(initial, 0)

tests/difftests/tests/arch/memory_barriers/memory_barriers-rust/src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ pub fn main_cs(
1919
shared[lid] = input[tid];
2020

2121
// Workgroup barrier to ensure all threads have loaded their data
22-
unsafe {
23-
workgroup_memory_barrier_with_group_sync();
24-
}
22+
workgroup_memory_barrier_with_group_sync();
2523

2624
// Perform operations on shared memory
2725
let mut result = shared[lid];
@@ -53,17 +51,13 @@ pub fn main_cs(
5351
}
5452

5553
// Another barrier before writing back
56-
unsafe {
57-
workgroup_memory_barrier_with_group_sync();
58-
}
54+
workgroup_memory_barrier_with_group_sync();
5955

6056
// Write result back to shared memory
6157
shared[lid] = result;
6258

6359
// Memory barrier to ensure writes are visible
64-
unsafe {
65-
workgroup_memory_barrier_with_group_sync();
66-
}
60+
workgroup_memory_barrier_with_group_sync();
6761

6862
// Final read and output
6963
output[tid] = shared[lid];

tests/difftests/tests/arch/workgroup_memory/workgroup_memory-rust/src/shader.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,59 +14,45 @@ pub fn main_cs(
1414
shared[lid] = input[lid];
1515

1616
// Synchronize to ensure all threads have loaded
17-
unsafe {
18-
workgroup_memory_barrier_with_group_sync();
19-
}
17+
workgroup_memory_barrier_with_group_sync();
2018

2119
// Each thread sums its value with its neighbor (reduction step)
2220
if lid < 32 {
2321
shared[lid] += shared[lid + 32];
2422
}
2523

2624
// Synchronize again
27-
unsafe {
28-
workgroup_memory_barrier_with_group_sync();
29-
}
25+
workgroup_memory_barrier_with_group_sync();
3026

3127
if lid < 16 {
3228
shared[lid] += shared[lid + 16];
3329
}
3430

35-
unsafe {
36-
workgroup_memory_barrier_with_group_sync();
37-
}
31+
workgroup_memory_barrier_with_group_sync();
3832

3933
if lid < 8 {
4034
shared[lid] += shared[lid + 8];
4135
}
4236

43-
unsafe {
44-
workgroup_memory_barrier_with_group_sync();
45-
}
37+
workgroup_memory_barrier_with_group_sync();
4638

4739
if lid < 4 {
4840
shared[lid] += shared[lid + 4];
4941
}
5042

51-
unsafe {
52-
workgroup_memory_barrier_with_group_sync();
53-
}
43+
workgroup_memory_barrier_with_group_sync();
5444

5545
if lid < 2 {
5646
shared[lid] += shared[lid + 2];
5747
}
5848

59-
unsafe {
60-
workgroup_memory_barrier_with_group_sync();
61-
}
49+
workgroup_memory_barrier_with_group_sync();
6250

6351
if lid < 1 {
6452
shared[lid] += shared[lid + 1];
6553
}
6654

67-
unsafe {
68-
workgroup_memory_barrier_with_group_sync();
69-
}
55+
workgroup_memory_barrier_with_group_sync();
7056

7157
// Write final result
7258
if lid == 0 {

0 commit comments

Comments
 (0)