Skip to content

Commit b6bd93d

Browse files
committed
difftest: cleanup wgpu runner, remove variants of runners, use shader passthrough for rust-gpu
1 parent 77942bb commit b6bd93d

File tree

19 files changed

+365
-885
lines changed

19 files changed

+365
-885
lines changed

tests/difftests/runner/src/runner.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use bytesize::ByteSize;
22
use difftest_types::config::{OutputType, TestMetadata};
33
use serde::{Deserialize, Serialize};
4-
use std::process::Stdio;
54
use std::{
65
collections::{HashMap, HashSet},
76
fs,
@@ -292,8 +291,6 @@ impl Runner {
292291

293292
let output = cmd
294293
.current_dir(&package.absolute_path)
295-
.stdout(Stdio::inherit())
296-
.stderr(Stdio::inherit())
297294
.output()
298295
.map_err(|e| RunnerError::Io { source: e })?;
299296
let exit_code = output.status.code().unwrap_or(-1);

tests/difftests/tests/arch/push_constants/push_constants-rust/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use difftest::config::Config;
2+
use difftest::scaffold::compute::wgpu::Features;
23
use difftest::scaffold::compute::{
3-
BufferConfig, BufferUsage, RustComputeShader, WgpuComputeTestPushConstants,
4+
BufferConfig, BufferUsage, RustComputeShader, WgpuComputeTestMultiBuffer,
45
};
56

67
#[repr(C)]
@@ -30,7 +31,7 @@ fn main() {
3031
count: num_elements as u32,
3132
};
3233

33-
let test = WgpuComputeTestPushConstants::new(
34+
let test = WgpuComputeTestMultiBuffer::new(
3435
RustComputeShader::default(),
3536
[4, 1, 1], // 256 / 64 = 4 workgroups
3637
vec![
@@ -45,9 +46,9 @@ fn main() {
4546
initial_data: None,
4647
},
4748
],
48-
std::mem::size_of::<PushConstants>() as u32,
49-
bytemuck::bytes_of(&push_constants).to_vec(),
50-
);
49+
)
50+
.with_feature(Features::PUSH_CONSTANTS)
51+
.with_push_constant(&push_constants);
5152

5253
test.run_test(&config).unwrap();
5354
}

tests/difftests/tests/arch/push_constants/push_constants-wgsl/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use difftest::config::Config;
2+
use difftest::scaffold::compute::wgpu::Features;
23
use difftest::scaffold::compute::{
3-
BufferConfig, BufferUsage, WgpuComputeTestPushConstants, WgslComputeShader,
4+
BufferConfig, BufferUsage, WgpuComputeTestMultiBuffer, WgslComputeShader,
45
};
56

67
#[repr(C)]
@@ -30,7 +31,7 @@ fn main() {
3031
count: num_elements as u32,
3132
};
3233

33-
let test = WgpuComputeTestPushConstants::new(
34+
let test = WgpuComputeTestMultiBuffer::new(
3435
WgslComputeShader::default(),
3536
[4, 1, 1], // 256 / 64 = 4 workgroups
3637
vec![
@@ -45,9 +46,9 @@ fn main() {
4546
initial_data: None,
4647
},
4748
],
48-
std::mem::size_of::<PushConstants>() as u32,
49-
bytemuck::bytes_of(&push_constants).to_vec(),
50-
);
49+
)
50+
.with_feature(Features::PUSH_CONSTANTS)
51+
.with_push_constant(&push_constants);
5152

5253
test.run_test(&config).unwrap();
5354
}

tests/difftests/tests/arch/vector_extract_insert/vector_extract_insert-wgsl/shader.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@group(0) @binding(0) var<storage, read> input: array<vec4<f32>>;
2-
@group(0) @binding(1) var<storage, read> indices: array<u32>;
1+
@group(0) @binding(0) var<storage, read_write> input: array<vec4<f32>>;
2+
@group(0) @binding(1) var<storage, read_write> indices: array<u32>;
33
@group(0) @binding(2) var<storage, read_write> output: array<vec4<f32>>;
44

55
@compute @workgroup_size(64)

tests/difftests/tests/lang/control_flow_complex/control_flow_complex-wgsl/shader.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@group(0) @binding(0) var<storage, read> input: array<u32>;
1+
@group(0) @binding(0) var<storage, read_write> input: array<u32>;
22
@group(0) @binding(1) var<storage, read_write> output: array<u32>;
33

44
@compute @workgroup_size(64)

tests/difftests/tests/lang/core/intrinsics/black_box_noop/with-black-box/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
use difftest::config::{Config, TestMetadata};
2-
use difftest::scaffold::compute::{RustComputeShader, WgpuComputeTest};
2+
use difftest::scaffold::compute::{RustComputeShader, WgpuComputeTestMultiBuffer};
33

44
fn main() {
55
let config = Config::from_path(std::env::args().nth(1).unwrap()).unwrap();
6-
let test = WgpuComputeTest::new(RustComputeShader::default(), [1, 1, 1], 12 * 4);
6+
let test = WgpuComputeTestMultiBuffer::new_single_buffer(
7+
RustComputeShader::default(),
8+
[1, 1, 1],
9+
12 * 4,
10+
);
711
test.run_test(&config).unwrap();
812
config
913
.write_metadata(&TestMetadata::u32())

tests/difftests/tests/lang/core/intrinsics/black_box_noop/without-black-box/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
use difftest::config::{Config, TestMetadata};
2-
use difftest::scaffold::compute::{RustComputeShader, WgpuComputeTest};
2+
use difftest::scaffold::compute::{RustComputeShader, WgpuComputeTestMultiBuffer};
33

44
fn main() {
55
let config = Config::from_path(std::env::args().nth(1).unwrap()).unwrap();
6-
let test = WgpuComputeTest::new(RustComputeShader::default(), [1, 1, 1], 12 * 4);
6+
let test = WgpuComputeTestMultiBuffer::new_single_buffer(
7+
RustComputeShader::default(),
8+
[1, 1, 1],
9+
12 * 4,
10+
);
711
test.run_test(&config).unwrap();
812
config
913
.write_metadata(&TestMetadata::u32())

tests/difftests/tests/lang/core/ops/bitwise_ops/bitwise_ops-wgsl/shader.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@group(0) @binding(0) var<storage, read> input_a: array<u32>;
2-
@group(0) @binding(1) var<storage, read> input_b: array<u32>;
1+
@group(0) @binding(0) var<storage, read_write> input_a: array<u32>;
2+
@group(0) @binding(1) var<storage, read_write> input_b: array<u32>;
33
@group(0) @binding(2) var<storage, read_write> output: array<u32>;
44

55
@compute @workgroup_size(64)

tests/difftests/tests/lang/core/ops/trig_ops/trig_ops-wgsl/shader.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@group(0) @binding(0) var<storage, read> input: array<f32>;
1+
@group(0) @binding(0) var<storage, read_write> input: array<f32>;
22
@group(0) @binding(1) var<storage, read_write> output: array<f32>;
33

44
@compute @workgroup_size(64)

tests/difftests/tests/lang/core/ops/vector_swizzle/vector_swizzle-wgsl/shader.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@group(0) @binding(0) var<storage, read> input: array<vec4<f32>>;
1+
@group(0) @binding(0) var<storage, read_write> input: array<vec4<f32>>;
22
@group(0) @binding(1) var<storage, read_write> output: array<vec4<f32>>;
33

44
@compute @workgroup_size(64)

0 commit comments

Comments
 (0)