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 BFloat16 runtime intrinsics. #51790

Merged
merged 1 commit into from
Oct 25, 2023
Merged

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Oct 20, 2023

After switching to LLVM for BFloat16 in #51470 (i.e., relying on Intrinsics.sub_float etc instead of hand-rolling bit-twiddling implementations), we also need to provide fallback runtime implementations for these intrinsics. This is too bad; I had hoped to put as much BFloat16-related things as possible in BFloat16s.jl.
It required modifying the unary operator preprocessor macros in order to differentiate between Float16 and BFloat16; I didn't generalize that to all intrinsics as the code is hairy enough already (and it's currently only useful for fptrunc/fpext).

@vtjnash @Keno Any suggestions for an alternative approach that keeps more of BFloat16 out of base? Ideally we'd implement these runtime fallbacks in Julia, as part of BFloat16s.jl (in fact, most of them already have an implementation over there), but that seems hard. Alternatively, we could require codegen.

@maleadt maleadt requested a review from vtjnash October 20, 2023 10:47
@maleadt
Copy link
Member Author

maleadt commented Oct 25, 2023

Well, if anybody has post-merge thoughts on how to move these definitions to BFloat16s.jl, let me know, but I'll go ahead and merge this so that we can get BFloat16 codegen to work.

@maleadt maleadt merged commit a1ccf53 into master Oct 25, 2023
2 checks passed
@maleadt maleadt deleted the tb/bfloat_runtime_intrinsics branch October 25, 2023 08:53
@Keno
Copy link
Member

Keno commented Oct 25, 2023

I don't think we need to bother really. To me these aren't really BFloat16 concerns as much as they are LLVM concerns and our LLVM support just happens to be in this repo.

maleadt added a commit that referenced this pull request Nov 1, 2023
Extends #51790; I forgot the conversion intrinsics defined in `APInt-C`.
To differentiate between Float16/BFloat16, I converted a couple of intrinsics
to take a `jl_datatype_t` argument instead an unsigned number of bits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants