re-adding env vars
This commit is contained in:
@@ -51,7 +51,6 @@ pub fn build(b: *std.Build) !void {
|
||||
const lib_mod = b.createModule(.{
|
||||
.root_source_file = b.path(impl.root_source_file),
|
||||
.target = target,
|
||||
.link_libc = true,
|
||||
.optimize = optimize,
|
||||
.imports = &.{
|
||||
.{ .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("--deqp");
|
||||
run.addArg(b.fmt("{s}{s}", .{ cache_path, cts_exe_path }));
|
||||
run.addArg(cts_exe_path);
|
||||
run.addArg("--caselist");
|
||||
run.addArg(b.fmt("{s}{s}", .{ cache_path, mustpass_path }));
|
||||
run.addArg(mustpass_path);
|
||||
run.addArg("--output");
|
||||
run.addArg("./cts");
|
||||
run.addArg("--timeout");
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
.lazy = true,
|
||||
},
|
||||
.SPIRV_Interpreter = .{
|
||||
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#4bd688cf07ea7d71c18a02153bb197e7b1e3cd82",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpn1aKBACoxQzshafHCjoUx6OfuFcyt1dumaerdtDo",
|
||||
.url = "git+https://git.kbz8.me/kbz_8/SPIRV-Interpreter#664ea9b92bf84bc97ec4a062c171562bf6628263",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpn1qKBACshq_ncUUF-zXJzpdNLRzIAPcWRQL57W8l",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
|
||||
self.* = .{
|
||||
.interface = interface,
|
||||
.module = spv.Module.init(allocator, code, .{
|
||||
//.use_simd_vectors_specializations = !std.process.hasEnvVarConstant(lib.NO_SHADER_SIMD_ENV_NAME),
|
||||
.use_simd_vectors_specializations = true,
|
||||
.use_simd_vectors_specializations = !base.env.hasEnvVar(lib.NO_SHADER_SIMD_ENV_NAME),
|
||||
}) catch |err| switch (err) {
|
||||
spv.Module.ModuleError.OutOfMemory => return VkError.OutOfHostMemory,
|
||||
else => {
|
||||
|
||||
@@ -35,15 +35,26 @@ early_dump: ?u32,
|
||||
final_dump: ?u32,
|
||||
|
||||
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 .{
|
||||
.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,
|
||||
.early_dump = null,
|
||||
.final_dump = null,
|
||||
.early_dump = blk: {
|
||||
if (early_dumb_env_var) |val| {
|
||||
break :blk std.fmt.parseInt(u32, std.mem.span(val.ptr), 10) catch 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;
|
||||
for (0..@min(self.batch_size, group_count)) |batch_id| {
|
||||
//if (std.process.hasEnvVarConstant(lib.SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME)) {
|
||||
// @branchHint(.cold); // Should only be reached for debugging
|
||||
if (base.env.hasEnvVar(lib.SINGLE_THREAD_COMPUTE_EXECUTION_ENV_NAME)) {
|
||||
@branchHint(.cold); // Should only be reached for debugging
|
||||
|
||||
// runWrapper(
|
||||
// RunData{
|
||||
// .self = self,
|
||||
// .batch_id = batch_id,
|
||||
// .group_count = group_count,
|
||||
// .group_count_x = @as(usize, @intCast(group_count_x)),
|
||||
// .group_count_y = @as(usize, @intCast(group_count_y)),
|
||||
// .group_count_z = @as(usize, @intCast(group_count_z)),
|
||||
// .invocations_per_workgroup = invocations_per_workgroup,
|
||||
// .pipeline = pipeline,
|
||||
// },
|
||||
// );
|
||||
//} else {
|
||||
wg.async(self.device.interface.io(), runWrapper, .{
|
||||
RunData{
|
||||
.self = self,
|
||||
.batch_id = batch_id,
|
||||
.group_count = group_count,
|
||||
.group_count_x = @as(usize, @intCast(group_count_x)),
|
||||
.group_count_y = @as(usize, @intCast(group_count_y)),
|
||||
.group_count_z = @as(usize, @intCast(group_count_z)),
|
||||
.invocations_per_workgroup = invocations_per_workgroup,
|
||||
.pipeline = pipeline,
|
||||
},
|
||||
});
|
||||
//}
|
||||
runWrapper(
|
||||
RunData{
|
||||
.self = self,
|
||||
.batch_id = batch_id,
|
||||
.group_count = group_count,
|
||||
.group_count_x = @as(usize, @intCast(group_count_x)),
|
||||
.group_count_y = @as(usize, @intCast(group_count_y)),
|
||||
.group_count_z = @as(usize, @intCast(group_count_z)),
|
||||
.invocations_per_workgroup = invocations_per_workgroup,
|
||||
.pipeline = pipeline,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
wg.async(self.device.interface.io(), runWrapper, .{
|
||||
RunData{
|
||||
.self = self,
|
||||
.batch_id = batch_id,
|
||||
.group_count = group_count,
|
||||
.group_count_x = @as(usize, @intCast(group_count_x)),
|
||||
.group_count_y = @as(usize, @intCast(group_count_y)),
|
||||
.group_count_z = @as(usize, @intCast(group_count_z)),
|
||||
.invocations_per_workgroup = invocations_per_workgroup,
|
||||
.pipeline = pipeline,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
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 {
|
||||
const allocator = data.self.device.device_allocator.allocator();
|
||||
const io = data.self.device.interface.io();
|
||||
|
||||
const shader = data.pipeline.stages.getPtrAssertContains(.compute);
|
||||
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) {
|
||||
@branchHint(.cold);
|
||||
try dumpResultsTable(allocator, rt, true);
|
||||
try dumpResultsTable(allocator, io, rt, true);
|
||||
}
|
||||
|
||||
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) {
|
||||
@branchHint(.cold);
|
||||
try dumpResultsTable(allocator, rt, false);
|
||||
try dumpResultsTable(allocator, io, rt, false);
|
||||
}
|
||||
|
||||
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);
|
||||
_ = allocator;
|
||||
_ = rt;
|
||||
_ = is_early;
|
||||
//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);
|
||||
const file = try std.Io.Dir.cwd().createFile(
|
||||
io,
|
||||
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;
|
||||
var writer = file.writer(io, buffer[0..]);
|
||||
try rt.dumpResultsTable(allocator, &writer.interface);
|
||||
}
|
||||
|
||||
fn writeDescriptorSets(self: *Self, rt: *spv.Runtime) !void {
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn hasEnvVar(name: []const u8) bool {
|
||||
_ = name;
|
||||
return false;
|
||||
return getEnvVar(name) != null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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_ms = @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_min = @mod(@divTrunc(now, std.time.ms_per_min), 60);
|
||||
const now_hour = @mod(@divTrunc(now, std.time.ms_per_hour), 24);
|
||||
const now_ms: u16 = @intCast(@mod(now, std.time.ms_per_s));
|
||||
const now_sec: u8 = @intCast(@mod(@divTrunc(now, std.time.ms_per_s), std.time.s_per_min));
|
||||
const now_min: u8 = @intCast(@mod(@divTrunc(now, std.time.ms_per_min), 60));
|
||||
const now_hour: u8 = @intCast(@mod(@divTrunc(now, std.time.ms_per_hour), 24));
|
||||
|
||||
var fmt_buffer = std.mem.zeroes([4096]u8);
|
||||
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;
|
||||
}
|
||||
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 {};
|
||||
writer.print("]", .{}) catch continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user