How to enable BFloat16 data type?

When compile source with __bf16 variable, it throw exception, "__bf16 is not supported on this target". The compiler is xcode build-in clang-1400.0.29.202. Is Apple silicon support bf16 type?

I think it supports __fp16 but not __bf16.

At least, I have a comment in my source tree saying that, so it may have been true when I wrote it in 2019. I forget the details. Beware that what the CPU supports and what the GPU supports will differ.

If I recall correctly, __bf16 is just a standard 32-bit float with 16 of its mantissa bits truncated. It's therefore not too slow to operate on __bf16 values by converting too and from float32.

In ARM's docs, 'BF16 is optionally supported from Armv8.2-A, but becomes mandatory in Arm8.6-A and Armv9.1-A'. I cannot find any materials mention what ISA version that Apple Silicon applied. However, Apple's ABI (https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms) doesn't include bf16 type. I write a assembly file contains bf16 instruction.

fmov s0, #0.5
bfcvt h1, s0

And compile the assembly file. It reports error: 'instruction requires: bf16'. It obviously the complier recognized bfcvt instruction, but current platform not support it.

How to enable BFloat16 data type?
 
 
Q