- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible to use the float16 or bfloat16 data types with icx compiler?
I am getting the error:
<source>:7:6: error: no type named 'float16_t' in namespace 'std'
7 | std::float16_t check_float16_conversion(std::float16_t a, std::float16_t b) {
| ~~~~~^
<source>:7:46: error: no type named 'float16_t' in namespace 'std'
7 | std::float16_t check_float16_conversion(std::float16_t a, std::float16_t b) {
| ~~~~~^
<source>:7:64: error: no type named 'float16_t' in namespace 'std'
7 | std::float16_t check_float16_conversion(std::float16_t a, std::float16_t b) {
| ~~~~~^
3 errors generated.While trying to compile with icx 2025.2.1 -std=c++23
I guess it is not supported yet, but then, how can I use float16 or bfloat16?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use
_Float16
for IEEE binary16 (half precision).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, bfloat16 type is supported in SYCL extension, https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/sycl_ext_oneapi_bfloat16.asciidoc
There's a simple example you can play with. The data type requires hardware support, otherwise it'll be emulated as float operations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use
__bf16
for bfloat16. As noted in the post above, the data type requires hardware support, otherwise it'll be emulated as single-precision float operations. The following generates code which does the addition in single-precision then converts the result to bfloat16:
$ cat test.cpp
__bf16 add(__bf16 x, __bf16 y) {
return x + y;
}
$ icpx -c -mavxneconvert test.cpp
$ nm -C test.o
0000000000000000 T add(std::bfloat16_t, std::bfloat16_t)
Future Intel CPUs will support AVX10.2, which includes bfloat16 arithmetic instructions (add, sub, mul, FMA, div, sqrt, ...).
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page