Skip to content

Commit 4179f1f

Browse files
vovwmaleadt
authored andcommitted
Add error checking to command buffer completion handler
1 parent e85bf52 commit 4179f1f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/compiler/execution.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,18 @@ end
300300
empty!(roots)
301301
foreach(free, argument_buffers)
302302

303-
# TODO: access logs here to check for errors
304-
# https://developer.apple.com/videos/play/wwdc2020/10616/
303+
# Check for errors
304+
if buf.status == MTL.MTLCommandBufferStatusError
305+
err = buf.error
306+
if err !== nothing
307+
# Get error details
308+
code = err.code # MTLCommandBufferError enum value
309+
description = err.localizedDescription
310+
311+
# Log the error
312+
@error "GPU kernel execution failed" exception=(err, catch_backtrace()) kernel=nameof(kernel.f) error_code=code description=description
313+
end
314+
end
305315
end
306316

307317
commit!(cmdbuf)

0 commit comments

Comments
 (0)