Skip to content

[runtime] Only enable _Float16 when the compiler supports it#9189

Open
pkubaj wants to merge 1 commit into
halide:mainfrom
pkubaj:patch-1
Open

[runtime] Only enable _Float16 when the compiler supports it#9189
pkubaj wants to merge 1 commit into
halide:mainfrom
pkubaj:patch-1

Conversation

@pkubaj

@pkubaj pkubaj commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The clang branch of the HALIDE_CPP_COMPILER_HAS_FLOAT16 detection enables _Float16 whenever _Float16 is a reserved keyword (detected via __is_identifier). However, clang reserves the keyword on all targets since clang 8 while only actually supporting the type on some. On a target where clang reserves but does not support _Float16 (e.g. PowerPC) the check is a false positive and the build fails with "error: _Float16 is not supported on this target".

clang (and gcc) only predefine the _FLT16* limit macros when the target actually supports _Float16, so additionally require defined(FLT16_MANT_DIG). This is the compiler-independent "better way to detect if the type is supported" the adjacent comment asks for, and it is a no-op on every target where _Float16 already worked.

Checklist

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

The clang branch of the HALIDE_CPP_COMPILER_HAS_FLOAT16 detection enables
_Float16 whenever `_Float16` is a reserved keyword (detected via
__is_identifier). However, clang reserves the keyword on *all* targets
since clang 8 while only actually *supporting* the type on some. On a
target where clang reserves but does not support _Float16 (e.g. PowerPC)
the check is a false positive and the build fails with
"error: _Float16 is not supported on this target".

clang (and gcc) only predefine the __FLT16_* limit macros when the target
actually supports _Float16, so additionally require
defined(__FLT16_MANT_DIG__). This is the compiler-independent "better way
to detect if the type is supported" the adjacent comment asks for, and it
is a no-op on every target where _Float16 already worked.
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@3cf47df). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9189   +/-   ##
=======================================
  Coverage        ?   69.20%           
=======================================
  Files           ?      254           
  Lines           ?    78274           
  Branches        ?    18729           
=======================================
  Hits            ?    54170           
  Misses          ?    18521           
  Partials        ?     5583           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexreinking

Copy link
Copy Markdown
Member

Do you by chance have a Godbolt link you can share to demonstrate the macro issue (perhaps on PPC)?

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.

2 participants