-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@mtlprintf #418
base: main
Are you sure you want to change the base?
@mtlprintf #418
Conversation
@maleadt Any idea how we can implement the version check for the Also can we get rid of the |
Would it be worth benchmarking the performance difference between having logging active vs not? |
@christiangnrd Sure. I don't expect there to be much overhead besides allocation of the log buffer and checking it for logs after running a kernel. But we might want to look into only conditionally adding |
Given that the macro expands way to early, I don't think there's anything we can do but checking in the kernel. Why are you opposed to that? GPUCompiler.jl has infrastructure to optimize those checks away, see e.g. how CUDA.jl exposes the device capability and PTX ISA version to the kernel. |
We could also wrap the macro and accompanying functions in |
I we do that we should have definitions in both cases and give an informative error if |
Actually, looks like I provided the run-time queries already: Metal.jl/src/device/intrinsics/version.jl Lines 64 to 65 in 6c82916
So we can just use that in the generated code, generating an I'd rather not simply check based on the macOS version during macro expansion, since we might want to target older Metal versions than the system supports. |
4ee3467
to
b43bcb1
Compare
Co-authored-by: Christian Guinard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! However do you know what's causing the tests to hang?
|
||
Metal places output from `@mtlprintf` into a log buffer. The system only removes the messages from the log buffer when the command buffer completes. When the log buffer becomes full, the system drops all subsequent messages. | ||
|
||
See also: `@mtlprint`, `@mtlprintln` and `@mtlshow` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add the printing docstrings in the API section of the Docs?
@christiangnrd The hangs are caused by this one line: @print_and_throw "@mtlprintf requires Metal 3.2 (macOS 15) or higher" |
Implement @mtlprintf and friends using os_log
TODO:
depends on: JuliaGPU/GPUCompiler.jl#630