re-adding env vars
Some checks failed
Build / build (push) Failing after 24s
Test / build_and_test (push) Successful in 11m5s

This commit is contained in:
2026-04-18 14:14:22 +02:00
parent 65c51b8213
commit 8f68ce4bf7
6 changed files with 89 additions and 60 deletions

View File

@@ -51,7 +51,6 @@ pub fn build(b: *std.Build) !void {
const lib_mod = b.createModule(.{ const lib_mod = b.createModule(.{
.root_source_file = b.path(impl.root_source_file), .root_source_file = b.path(impl.root_source_file),
.target = target, .target = target,
.link_libc = true,
.optimize = optimize, .optimize = optimize,
.imports = &.{ .imports = &.{
.{ .name = "base", .module = base_mod }, .{ .name = "base", .module = base_mod },
@@ -273,9 +272,9 @@ fn addMultithreadedCTS(b: *std.Build, target: std.Build.ResolvedTarget, impl: *c
run.addArg("run"); run.addArg("run");
run.addArg("--deqp"); run.addArg("--deqp");
run.addArg(b.fmt("{s}{s}", .{ cache_path, cts_exe_path })); run.addArg(cts_exe_path);
run.addArg("--caselist"); run.addArg("--caselist");
run.addArg(b.fmt("{s}{s}", .{ cache_path, mustpass_path })); run.addArg(mustpass_path);
run.addArg("--output"); run.addArg("--output");
run.addArg("./cts"); run.addArg("./cts");
run.addArg("--timeout"); run.addArg("--timeout");

View File

@@ -27,8 +27,8 @@
.lazy = true, .lazy = true,
}, },
.SPIRV_Interpreter = .{ .SPIRV_Interpreter = .{
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#4bd688cf07ea7d71c18a02153bb197e7b1e3cd82", .url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#664ea9b92bf84bc97ec4a062c171562bf6628263",
.hash = "SPIRV_Interpreter-0.0.1-ajmpn1aKBACoxQzshafHCjoUx6OfuFcyt1dumaerdtDo", .hash = "SPIRV_Interpreter-0.0.1-ajmpn1qKBACshq_ncUUF-zXJzpdNLRzIAPcWRQL57W8l",
}, },
}, },

View File

@@ -32,8 +32,7 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
self.* = .{ self.* = .{
.interface = interface, .interface = interface,
.module = spv.Module.init(allocator, code, .{ .module = spv.Module.init(allocator, code, .{
//.use_simd_vectors_specializations = !std.process.hasEnvVarConstant(lib.NO_SHADER_SIMD_ENV_NAME), .use_simd_vectors_specializations = !base.env.hasEnvVar(lib.NO_SHADER_SIMD_ENV_NAME),
.use_simd_vectors_specializations = true,
}) catch |err| switch (err) { }) catch |err| switch (err) {
spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory, spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory,
else => { else => {

View File

@@ -35,15 +35,26 @@ early_dump: ?u32,
final_dump: ?u32, final_dump: ?u32,
pub fn init(device: *SoftDevice, state: *PipelineState) Self { pub fn init(device: *SoftDevice, state: *PipelineState) Self {
const early_dumb_env_var = base.env.getEnvVar(lib.DUMP_EARLY_RESULT_TABLE_ENV_NAME);
const final_dumb_env_var = base.env.getEnvVar(lib.DUMP_FINAL_RESULT_TABLE_ENV_NAME);
return .{ return .{
.device = device, .device = device,
.state = state, .state = state,
.batch_size = 0, .batch_size = 0,
.invocation_index = .init(0), .invocation_index = .init(0),
//.early_dump = std.process.parseEnvVarInt(lib.DUMP_EARLY_RESULT_TABLE_ENV_NAME, u32, 10) catch null, .early_dump = blk: {
//.final_dump = std.process.parseEnvVarInt(lib.DUMP_FINAL_RESULT_TABLE_ENV_NAME, u32, 10) catch null, if (early_dumb_env_var) |val| {
.early_dump = null, break :blk std.fmt.parseInt(u32, std.mem.span(val.ptr), 10) catch null;
.final_dump = null, }
break :blk null;
},
.final_dump = blk: {
if (final_dumb_env_var) |val| {
break :blk std.fmt.parseInt(u32, std.mem.span(val.ptr), 10) catch null;
}
break :blk null;
},
}; };
} }
@@ -65,35 +76,35 @@ pub fn dispatch(self: *Self, group_count_x: u32, group_count_y: u32, group_count
var wg: std.Io.Group = .init; var wg: std.Io.Group = .init;
for (0..@min(self.batch_size, group_count)) |batch_id| { for (0..@min(self.batch_size, group_count)) |batch_id| {
//if (std.process.hasEnvVarConstant(lib.SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME)) { if (base.env.hasEnvVar(lib.SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME)) {
// @branchHint(.cold); // Should only be reached for debugging @branchHint(.cold); // Should only be reached for debugging
// runWrapper( runWrapper(
// RunData{ RunData{
// .self = self, .self = self,
// .batch_id = batch_id, .batch_id = batch_id,
// .group_count = group_count, .group_count = group_count,
// .group_count_x = @as(usize, @intCast(group_count_x)), .group_count_x = @as(usize, @intCast(group_count_x)),
// .group_count_y = @as(usize, @intCast(group_count_y)), .group_count_y = @as(usize, @intCast(group_count_y)),
// .group_count_z = @as(usize, @intCast(group_count_z)), .group_count_z = @as(usize, @intCast(group_count_z)),
// .invocations_per_workgroup = invocations_per_workgroup, .invocations_per_workgroup = invocations_per_workgroup,
// .pipeline = pipeline, .pipeline = pipeline,
// }, },
// ); );
//} else { } else {
wg.async(self.device.interface.io(), runWrapper, .{ wg.async(self.device.interface.io(), runWrapper, .{
RunData{ RunData{
.self = self, .self = self,
.batch_id = batch_id, .batch_id = batch_id,
.group_count = group_count, .group_count = group_count,
.group_count_x = @as(usize, @intCast(group_count_x)), .group_count_x = @as(usize, @intCast(group_count_x)),
.group_count_y = @as(usize, @intCast(group_count_y)), .group_count_y = @as(usize, @intCast(group_count_y)),
.group_count_z = @as(usize, @intCast(group_count_z)), .group_count_z = @as(usize, @intCast(group_count_z)),
.invocations_per_workgroup = invocations_per_workgroup, .invocations_per_workgroup = invocations_per_workgroup,
.pipeline = pipeline, .pipeline = pipeline,
}, },
}); });
//} }
} }
wg.await(self.device.interface.io()) catch return VkError.DeviceLost; wg.await(self.device.interface.io()) catch return VkError.DeviceLost;
} }
@@ -109,6 +120,7 @@ fn runWrapper(data: RunData) void {
inline fn run(data: RunData) !void { inline fn run(data: RunData) !void {
const allocator = data.self.device.device_allocator.allocator(); const allocator = data.self.device.device_allocator.allocator();
const io = data.self.device.interface.io();
const shader = data.pipeline.stages.getPtrAssertContains(.compute); const shader = data.pipeline.stages.getPtrAssertContains(.compute);
const rt = &shader.runtimes[data.batch_id]; const rt = &shader.runtimes[data.batch_id];
@@ -150,7 +162,7 @@ inline fn run(data: RunData) !void {
if (data.self.early_dump != null and data.self.early_dump.? == invocation_index) { if (data.self.early_dump != null and data.self.early_dump.? == invocation_index) {
@branchHint(.cold); @branchHint(.cold);
try dumpResultsTable(allocator, rt, true); try dumpResultsTable(allocator, io, rt, true);
} }
rt.callEntryPoint(allocator, entry) catch |err| switch (err) { rt.callEntryPoint(allocator, entry) catch |err| switch (err) {
@@ -163,7 +175,7 @@ inline fn run(data: RunData) !void {
if (data.self.final_dump != null and data.self.final_dump.? == invocation_index) { if (data.self.final_dump != null and data.self.final_dump.? == invocation_index) {
@branchHint(.cold); @branchHint(.cold);
try dumpResultsTable(allocator, rt, false); try dumpResultsTable(allocator, io, rt, false);
} }
try rt.flushDescriptorSets(allocator); try rt.flushDescriptorSets(allocator);
@@ -171,19 +183,17 @@ inline fn run(data: RunData) !void {
} }
} }
inline fn dumpResultsTable(allocator: std.mem.Allocator, rt: *spv.Runtime, is_early: bool) !void { inline fn dumpResultsTable(allocator: std.mem.Allocator, io: std.Io, rt: *spv.Runtime, is_early: bool) !void {
@branchHint(.cold); @branchHint(.cold);
_ = allocator; const file = try std.Io.Dir.cwd().createFile(
_ = rt; io,
_ = is_early; std.fmt.comptimePrint("{s}_compute_result_table_dump.txt", .{if (is_early) "early" else "final"}),
//const file = try std.fs.cwd().createFile( .{ .truncate = true },
// std.fmt.comptimePrint("{s}_compute_result_table_dump.txt", .{if (is_early) "early" else "final"}), );
// .{ .truncate = true }, defer file.close(io);
//); var buffer = [_]u8{0} ** 1024;
//defer file.close(); var writer = file.writer(io, buffer[0..]);
//var buffer = [_]u8{0} ** 1024; try rt.dumpResultsTable(allocator, &writer.interface);
//var writer = file.writer(buffer[0..]);
//try rt.dumpResultsTable(allocator, &writer.interface);
} }
fn writeDescriptorSets(self: *Self, rt: *spv.Runtime) !void { fn writeDescriptorSets(self: *Self, rt: *spv.Runtime) !void {

View File

@@ -1,6 +1,27 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
pub fn hasEnvVar(name: []const u8) bool { pub fn hasEnvVar(name: []const u8) bool {
_ = name; return getEnvVar(name) != null;
return false; }
pub fn getEnvVar(name: []const u8) ?[:0]const u8 {
if (builtin.os.tag == .windows)
return null;
if (std.mem.indexOfScalar(u8, name, '=') != null)
return null;
var ptr = std.c.environ;
while (ptr[0]) |line| : (ptr += 1) {
var line_i: usize = 0;
while (line[line_i] != 0) : (line_i += 1) {
if (line_i == name.len) break;
if (line[line_i] != name[line_i]) break;
}
if ((line_i != name.len) or (line[line_i] != '=')) continue;
return std.mem.sliceTo(line + line_i + 1, 0);
}
return null;
} }

View File

@@ -62,10 +62,10 @@ pub fn log(comptime level: std.log.Level, comptime scope: @EnumLiteral(), compti
const now = std.Io.Timestamp.now(io, .cpu_process).toMilliseconds(); const now = std.Io.Timestamp.now(io, .cpu_process).toMilliseconds();
const now_ms = @mod(now, std.time.ms_per_s); const now_ms: u16 = @intCast(@mod(now, std.time.ms_per_s));
const now_sec = @mod(@divTrunc(now, std.time.ms_per_s), std.time.s_per_min); const now_sec: u8 = @intCast(@mod(@divTrunc(now, std.time.ms_per_s), std.time.s_per_min));
const now_min = @mod(@divTrunc(now, std.time.ms_per_min), 60); const now_min: u8 = @intCast(@mod(@divTrunc(now, std.time.ms_per_min), 60));
const now_hour = @mod(@divTrunc(now, std.time.ms_per_hour), 24); const now_hour: u8 = @intCast(@mod(@divTrunc(now, std.time.ms_per_hour), 24));
var fmt_buffer = std.mem.zeroes([4096]u8); var fmt_buffer = std.mem.zeroes([4096]u8);
var fmt_writer = std.Io.Writer.fixed(&fmt_buffer); var fmt_writer = std.Io.Writer.fixed(&fmt_buffer);
@@ -93,7 +93,7 @@ pub fn log(comptime level: std.log.Level, comptime scope: @EnumLiteral(), compti
writer.print(root.DRIVER_NAME, .{}) catch continue; writer.print(root.DRIVER_NAME, .{}) catch continue;
} }
term.setColor(.yellow) catch {}; term.setColor(.yellow) catch {};
writer.print(" {d}:{d}:{d}.{d}", .{ now_hour, now_min, now_sec, now_ms }) catch continue; writer.print(" {d}:{d}:{d}.{d:0>3}", .{ now_hour, now_min, now_sec, now_ms }) catch continue;
term.setColor(.magenta) catch {}; term.setColor(.magenta) catch {};
writer.print("]", .{}) catch continue; writer.print("]", .{}) catch continue;