Skip to content

Commit

Permalink
PR #21903: [XLA:CPU] Add __truncsfhf2 and __extendhfsf2 runtime symbols.
Browse files Browse the repository at this point in the history
Imported from GitHub PR #21903

These appear to be used by LLVM on x86 Macs.
Copybara import of the project:

--
f80212d by Peter Hawkins <[email protected]>:

[XLA:CPU] Add __truncsfhf2 and __extendhfsf2 runtime symbols.

These appear to be used by LLVM on x86 Macs.

Merging this change closes #21903

COPYBARA_INTEGRATE_REVIEW=#21903 from hawkinsp:syms f80212d
PiperOrigin-RevId: 720209384
  • Loading branch information
hawkinsp authored and Google-ML-Automation committed Jan 27, 2025
1 parent bd69e17 commit c217561
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions xla/service/cpu/runtime_symbol_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,21 @@ RuntimeSymbolGenerator::ResolveRuntimeSymbol(llvm::StringRef name) {
extern "C" void __chkstk(size_t);
#endif

extern "C" {
// Provided by compiler-rt and MLIR.
// Converts an F32 value to a BF16.
extern "C" uint16_t __truncsfbf2(float);
uint16_t __truncsfbf2(float);
// Converts an F64 value to a BF16.
extern "C" uint16_t __truncdfbf2(double);
uint16_t __truncdfbf2(double);

#ifdef __APPLE__
// Converts an F32 value to a F16.
uint16_t __truncsfhf2(float);

float __extendhfsf2(uint16_t a);
#endif // __APPLE__

} // extern "C"

#define REGISTER_CPU_RUNTIME_SYMBOL(base_name) \
do { \
Expand Down Expand Up @@ -216,6 +226,13 @@ static bool RegisterKnownJITSymbols() {
"Host");
registry->Register("__truncsfbf2", reinterpret_cast<void*>(__truncsfbf2),
"Host");

#ifdef __APPLE__
registry->Register("__truncsfhf2", reinterpret_cast<void*>(__truncsfhf2),
"Host");
registry->Register("__extendhfsf2", reinterpret_cast<void*>(__extendhfsf2),
"Host");
#endif // __APPLE__
registry->Register("__powisf2", reinterpret_cast<void*>(__powisf2), "Host");
registry->Register("__powidf2", reinterpret_cast<void*>(__powidf2), "Host");

Expand Down

0 comments on commit c217561

Please sign in to comment.