-
Notifications
You must be signed in to change notification settings - Fork 41
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 |
If 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
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?
@christiangnrd The hangs are caused by this one line: @print_and_throw "@mtlprintf requires Metal 3.2 (macOS 15) or higher" |
@maleadt Could we have one of the Apple Silicon runners upgraded to Sequoia so the output tests don't get ignored? Edit: All the runners are running 13.3.1. Should we also have one on macOS 14? I would also like to see #420 merged first (with benchmarks run on macOS 15) to see how big the impact of enabling logging is. |
@christiangnrd I recently made changes so that logging (e.g. MTLLogState and friends) is only enabled whenever we actually use the feature. |
Just pushed a whitespace-only formatting commit |
In that case I still think we should be able to test on macOS 15, but I think we should merge this as soon as it's ready. |
@tgymnich Tests now seem to be passing locally with the 2 suggestions I just made. Is this still blocked? I'll take care of the rebase since the conflicts are my fault. |
59d13ef
to
6052888
Compare
This is awesome! Thank you so much @christiangnrd. |
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.
LGTM. Make sure to check out my commit to make sure I didn't make any undesired changes.
Oh and I guess formatting. I personally wouldn't touch the suggestions for the @objc
calls or the test indenting suggestions, but I'll leave it up to you to decide which ones you want to implement (unless @maleadt feels otherwise)
Hopefully #527 will allow us to clean up all the version gates but for now they're necessary.
How is this not blocked by #433 anymore? |
@maleadt #433 is still an issue on some older devices. |
Co-authored-by: Christian Guinard <[email protected]>
Co-authored-by: Christian Guinard <[email protected]>
Co-authored-by: Christian Guinard <[email protected]>
I'm having a hard time understanding that. If switching to a non-yielding |
FWIW I can replicate the hang but not the 100% GPU usage mentioned in #433. |
Implement @mtlprintf and friends using os_log
TODO:
depends on: JuliaGPU/GPUCompiler.jl#630
notify: #226