Skip to content
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

Add exceptions to check_ir_values #630

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tgymnich
Copy link
Member

@tgymnich tgymnich commented Sep 17, 2024

Allow double for C's default argument promotions used in variable-length argument lists by introducing ir_check_ignore metadata and a allow argument for check_ir_values that is used to allow fpext in Metal.

needed for JuliaGPU/Metal.jl#418

@maleadt
Copy link
Member

maleadt commented Sep 17, 2024

Are there any other uses for double that are legal? If not, I'd rather we somehow whitelist the printf handling, because the existing error reporting is much more user friendly than the otherwise completely opaque compilation errors as reported by Metal's back-end compiler.

@tgymnich
Copy link
Member Author

tgymnich commented Sep 17, 2024

Use of double for logging currently consists of fpext and a store. I don't think we can get arround fpext since air.os_log expects doubles.
Maybe we can tag it with some metadata?

@maleadt
Copy link
Member

maleadt commented Sep 17, 2024

Maybe we can tag it with some metadata?

Yeah, if it survives optimization. Or, alternatively, a function attribute (julia.allow_double) set on the @noinline body of the printf code doing the fpext etc? That may be more robust.

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Project coverage is 70.87%. Comparing base (bbd6124) to head (9ed1583).

Files with missing lines Patch % Lines
src/metal.jl 0.00% 14 Missing ⚠️
src/validation.jl 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #630      +/-   ##
==========================================
- Coverage   71.34%   70.87%   -0.47%     
==========================================
  Files          24       24              
  Lines        3186     3207      +21     
==========================================
  Hits         2273     2273              
- Misses        913      934      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tgymnich tgymnich force-pushed the metal-allow-double-for-vararg branch 3 times, most recently from 2d5853a to 4d99de5 Compare September 17, 2024 22:55
@tgymnich tgymnich changed the title [Metal] Allow double for vararg Add exceptions to IR validator Sep 18, 2024
@tgymnich tgymnich changed the title Add exceptions to IR validator Add exceptions to check_ir_values Sep 18, 2024
@tgymnich tgymnich mentioned this pull request Sep 18, 2024
4 tasks
@@ -90,7 +90,7 @@ function validate_ir(job::CompilerJob{MetalCompilerTarget}, mod::LLVM.Module)
errors = IRError[]

# Metal never supports double precision

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer accurate?

Copy link
Member

@maleadt maleadt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some testing, I don't think metadata is going to work. In any case, it's the wrong tool for the job. We could devise more elaborate IR patterns that do survive, but I don't see the value in that.

Let's just not use check_ir_values, which is a simple enough function, and instead roll our own version in metal.jl which ignores the fpext/store. Or, if you feel fancy, maybe a allow_cb callback argument to check_ir_values.

@maleadt
Copy link
Member

maleadt commented Sep 20, 2024

Maybe add a simple test with pre-defined IR modules to check this behavior (double normally disallowed, only when passed to logging)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants