adding spirv interpreter results table dump
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,3 +14,4 @@ scripts/__pycache__/
|
||||
*.html
|
||||
*.pyc
|
||||
*.spv
|
||||
*_table_dump.txt
|
||||
|
||||
@@ -299,6 +299,8 @@ fn addMultithreadedCTS(b: *std.Build, target: std.Build.ResolvedTarget, impl: *c
|
||||
run.addArg(b.fmt("{s}{s}", .{ cache_path, mustpass_path }));
|
||||
run.addArg("--output");
|
||||
run.addArg("./cts");
|
||||
run.addArg("--timeout");
|
||||
run.addArg("300");
|
||||
if (jobs_count) |count| {
|
||||
run.addArg(b.fmt("-j{d}", .{count}));
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@
|
||||
.lazy = true,
|
||||
},
|
||||
.SPIRV_Interpreter = .{
|
||||
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#fe47277468c694b10153282761efd3d6f90d8f6a",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpn2u-AwAPdrXzLzxHPezx3Kkb63hkecdY0oPEJ2ad",
|
||||
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#569d7fda01340f2fc195d868df7d3fc583f900bd",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpn3PFAwD7uWTP4W8ULr8mLWlV5BiqvfOIsLyYjDij",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -29,11 +29,19 @@ device: *SoftDevice,
|
||||
state: *PipelineState,
|
||||
batch_size: usize,
|
||||
|
||||
invocation_index: std.atomic.Value(usize),
|
||||
|
||||
early_dump: ?u32,
|
||||
final_dump: ?u32,
|
||||
|
||||
pub fn init(device: *SoftDevice, state: *PipelineState) Self {
|
||||
return .{
|
||||
.device = device,
|
||||
.state = state,
|
||||
.batch_size = 0,
|
||||
.invocation_index = .init(0),
|
||||
.early_dump = std.process.parseEnvVarInt(lib.DUMP_EARLY_RESULT_TABLE_ENV_NAME, u32, 10) catch null,
|
||||
.final_dump = std.process.parseEnvVarInt(lib.DUMP_FINAL_RESULT_TABLE_ENV_NAME, u32, 10) catch null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,6 +59,8 @@ pub fn dispatch(self: *Self, group_count_x: u32, group_count_y: u32, group_count
|
||||
|
||||
const invocations_per_workgroup = spv_module.local_size_x * spv_module.local_size_y * spv_module.local_size_z;
|
||||
|
||||
self.invocation_index.store(0, .monotonic);
|
||||
|
||||
var wg: std.Thread.WaitGroup = .{};
|
||||
for (0..@min(self.batch_size, group_count)) |batch_id| {
|
||||
if (std.process.hasEnvVarConstant(lib.SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME)) {
|
||||
@@ -128,12 +138,19 @@ inline fn run(data: RunData) !void {
|
||||
});
|
||||
|
||||
for (0..data.invocations_per_workgroup) |i| {
|
||||
const invocation_index = data.self.invocation_index.fetchAdd(1, .monotonic);
|
||||
|
||||
try setupSubgroupBuiltins(data.self, rt, .{
|
||||
@as(u32, @intCast(group_x)),
|
||||
@as(u32, @intCast(group_y)),
|
||||
@as(u32, @intCast(group_z)),
|
||||
}, i);
|
||||
|
||||
if (data.self.early_dump != null and data.self.early_dump.? == invocation_index) {
|
||||
@branchHint(.cold);
|
||||
try dumpResultsTable(allocator, rt, true);
|
||||
}
|
||||
|
||||
rt.callEntryPoint(allocator, entry) catch |err| switch (err) {
|
||||
// Some errors can be ignored
|
||||
SpvRuntimeError.OutOfBounds,
|
||||
@@ -141,11 +158,29 @@ inline fn run(data: RunData) !void {
|
||||
=> {},
|
||||
else => return err,
|
||||
};
|
||||
|
||||
if (data.self.final_dump != null and data.self.final_dump.? == invocation_index) {
|
||||
@branchHint(.cold);
|
||||
try dumpResultsTable(allocator, rt, false);
|
||||
}
|
||||
|
||||
try rt.flushDescriptorSets(allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fn dumpResultsTable(allocator: std.mem.Allocator, rt: *spv.Runtime, is_early: bool) !void {
|
||||
@branchHint(.cold);
|
||||
const file = try std.fs.cwd().createFile(
|
||||
std.fmt.comptimePrint("{s}_compute_result_table_dump.txt", .{if (is_early) "early" else "final"}),
|
||||
.{ .truncate = true },
|
||||
);
|
||||
defer file.close();
|
||||
var buffer = [_]u8{0} ** 1024;
|
||||
var writer = file.writer(buffer[0..]);
|
||||
try rt.dumpResultsTable(allocator, &writer.interface);
|
||||
}
|
||||
|
||||
fn writeDescriptorSets(self: *Self, rt: *spv.Runtime) !void {
|
||||
sets: for (self.state.sets[0..], 0..) |set, set_index| {
|
||||
if (set == null)
|
||||
|
||||
@@ -41,7 +41,9 @@ pub const DRIVER_VERSION = vk.makeApiVersion(0, 0, 0, 1);
|
||||
pub const DEVICE_ID = 0x600DCAFE;
|
||||
|
||||
pub const NO_SHADER_SIMD_ENV_NAME = "STROLL_SOFT_NO_SIMD";
|
||||
pub const SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME = "STROLL_SINGLE_THREAD_COMPUTE_EXECUTION";
|
||||
pub const SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME = "STROLL_SOFT_SINGLE_THREAD_COMPUTE_EXECUTION";
|
||||
pub const DUMP_EARLY_RESULT_TABLE_ENV_NAME = "STROLL_SOFT_DUMP_EARLY_RESULT_TABLE_FOR_INVOCATION";
|
||||
pub const DUMP_FINAL_RESULT_TABLE_ENV_NAME = "STROLL_SOFT_DUMP_FINAL_RESULT_TABLE_FOR_INVOCATION";
|
||||
|
||||
/// Generic system memory.
|
||||
pub const MEMORY_TYPE_GENERIC_BIT = 0;
|
||||
|
||||
Reference in New Issue
Block a user