Skip to content

Commit

Permalink
Merge branch 'error-description'
Browse files Browse the repository at this point in the history
  • Loading branch information
akhildevelops committed Jan 24, 2024
2 parents 10f5adf + 63072a3 commit 48ecf66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/increment/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.dependencies = .{
.cudaz = .{
.url = "https://github.com/akhildevelops/cudaz/tarball/master",
.hash = "1220cc1c51c2544239dda0899d17c5866560595e3e5008d31b6d33cdfb80c519a9ef",
.hash = "122042f55e5b492702d91ac0c09f0d74c7a1842a19ef2e75c1a833d64df51a0be9eb",
},
},
.paths = .{
Expand Down
15 changes: 14 additions & 1 deletion src/compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,20 @@ pub fn cudaProgram(prg: nvrtc.nvrtcProgram, options: ?Options, allocator: std.me
for (params_own, cparams) |p, *cp| {
cp.* = p.ptr;
}
try Error.fromNvrtcErrorCode(nvrtc.nvrtcCompileProgram(prg, std.math.cast(c_int, cparams.len).?, cparams.ptr));
Error.fromNvrtcErrorCode(nvrtc.nvrtcCompileProgram(prg, std.math.cast(c_int, cparams.len).?, cparams.ptr)) catch |e| {
switch (e) {
error.NVRTC_ERROR_COMPILATION => {
var log_size: usize = undefined;
try Error.fromNvrtcErrorCode(nvrtc.nvrtcGetProgramLogSize(prg, &log_size));
const log_msg = try allocator.allocSentinel(u8, log_size, '0');
try Error.fromNvrtcErrorCode(nvrtc.nvrtcGetProgramLog(prg, log_msg.ptr));
std.debug.print("{s}\n", .{log_msg});
allocator.free(log_msg);
},
else => return e,
}
};
return {};
}

pub fn getPtx(prg: nvrtc.nvrtcProgram, allocator: std.mem.Allocator) CompileError![:0]const u8 {
Expand Down

0 comments on commit 48ecf66

Please sign in to comment.