digitalmars.D - Implementing C23 _Float16 in ImportC
- Walter Bright (8/8) Jan 13 _Float16 is new in C23 Appendix H.11-6
- Sergey (3/11) Jan 13 Amazing. Is it extendable to Float8?
- Walter Bright (3/5) Jan 14 That I don't know. But it could be modified to be.
- Tim (5/22) Jan 14 Phobos also contains CustomFloat:
- ryuukk_ (9/17) Jan 14 Why should it be a "runtime" module?
- Walter Bright (4/14) Jan 14 The interesting thing is not the existence of the types. It's how they a...
- Sergey (9/12) Jan 14 It had some limited support starting from 2018 had AVX512-FP16.
- Bruce Carneal (7/20) Jan 15 ARM architecture is also evolving (8.2A, 9) to better support
- Walter Bright (1/1) Jan 15 I didn't know that. Thanks for the info.
- Walter Bright (3/4) Jan 14 I implemented halffloat a decade ago. It didn't go into the library then...
- Richard (Rikki) Andrew Cattermole (8/8) Jan 14 I forgot to introduce this for a decision at the last meeting (lucky
- Bruce Carneal (5/10) Jan 14 Is this a good path to full integration with the back ends? I'd
- Richard (Rikki) Andrew Cattermole (4/16) Jan 14 Yes.
- Walter Bright (2/3) Jan 14 No. What was the subject title?
- Richard (Rikki) Andrew Cattermole (3/7) Jan 14 "DFA - a potential strategy?"
- Walter Bright (2/6) Jan 14 Ok, I found it.
_Float16 is new in C23 Appendix H.11-6 https://github.com/dlang/dmd/issues/20516 For the moment, I submitted a PR with a workaround: https://github.com/dlang/dmd/pull/20699 Amazingly, some years ago I implemented 16 bit floats in D: https://github.com/DigitalMars/sargon/blob/master/src/sargon/halffloat.d Would anyone like to put halffloat.d into Druntime and make it our implementation of _Float16?
Jan 13
On Tuesday, 14 January 2025 at 06:13:04 UTC, Walter Bright wrote:_Float16 is new in C23 Appendix H.11-6 https://github.com/dlang/dmd/issues/20516 For the moment, I submitted a PR with a workaround: https://github.com/dlang/dmd/pull/20699 Amazingly, some years ago I implemented 16 bit floats in D: https://github.com/DigitalMars/sargon/blob/master/src/sargon/halffloat.d Would anyone like to put halffloat.d into Druntime and make it our implementation of _Float16?Amazing. Is it extendable to Float8? Is it compatible with LLVM/GCC and other implementations?
Jan 13
On 1/13/2025 11:43 PM, Sergey wrote:Amazing. Is it extendable to Float8?The idea is sound, so probably.Is it compatible with LLVM/GCC and other implementations?That I don't know. But it could be modified to be.
Jan 14
On Tuesday, 14 January 2025 at 07:43:42 UTC, Sergey wrote:On Tuesday, 14 January 2025 at 06:13:04 UTC, Walter Bright wrote:Phobos also contains CustomFloat: https://dlang.org/library/std/numeric/custom_float.html This allows to have floats with a custom number of bits, including 8 bits._Float16 is new in C23 Appendix H.11-6 https://github.com/dlang/dmd/issues/20516 For the moment, I submitted a PR with a workaround: https://github.com/dlang/dmd/pull/20699 Amazingly, some years ago I implemented 16 bit floats in D: https://github.com/DigitalMars/sargon/blob/master/src/sargon/halffloat.d Would anyone like to put halffloat.d into Druntime and make it our implementation of _Float16?Amazing. Is it extendable to Float8?
Jan 14
On Tuesday, 14 January 2025 at 06:13:04 UTC, Walter Bright wrote:_Float16 is new in C23 Appendix H.11-6 https://github.com/dlang/dmd/issues/20516 For the moment, I submitted a PR with a workaround: https://github.com/dlang/dmd/pull/20699 Amazingly, some years ago I implemented 16 bit floats in D: https://github.com/DigitalMars/sargon/blob/master/src/sargon/halffloat.d Would anyone like to put halffloat.d into Druntime and make it our implementation of _Float16?Why should it be a "runtime" module? Obviously you know better than most of us, but does it feel good to have to import a module for such thing, is it compelling for people looking for an alternative to C? What the young competition doing? https://ziglang.org/documentation/master/#Primitive-Types https://odin-lang.org/docs/overview/#basic-types https://c3-lang.org/language-overview/types/
Jan 14
On 1/14/2025 12:33 AM, ryuukk_ wrote:Why should it be a "runtime" module?If it is to be part of the core language, that's where it goes.Obviously you know better than most of us, but does it feel good to have to import a module for such thing, is it compelling for people looking for an alternative to C? What the young competition doing? https://ziglang.org/documentation/master/#Primitive-Types https://odin-lang.org/docs/overview/#basic-types https://c3-lang.org/language-overview/types/The interesting thing is not the existence of the types. It's how they are implemented. The X86_64 architecture does not support a 16 bit floating point type.
Jan 14
On Tuesday, 14 January 2025 at 22:14:01 UTC, Walter Bright wrote:The interesting thing is not the existence of the types. It's how they are implemented. The X86_64 architecture does not support a 16 bit floating point type.It had some limited support starting from 2018 had AVX512-FP16. And some newer models of x86 support both FP16 and BF16. * https://networkbuilders.intel.com/docs/networkbuilders/intel-avx-512-fp16-instruction-set-for-intel-xeon-processor-based-products-technology-guide-1651874188.pdf * https://stackoverflow.com/questions/49995594/half-precision-floating-point-arithmetic-on-intel-chips Also it is important for AI/ML models, which can run on ARM CPUs, GPUs and TPUs
Jan 14
On Wednesday, 15 January 2025 at 06:42:45 UTC, Sergey wrote:On Tuesday, 14 January 2025 at 22:14:01 UTC, Walter Bright wrote:ARM architecture is also evolving (8.2A, 9) to better support data parallelism with both FP16 and BF16 as well as SVE2 but the uptake by manufacturers is uneven. Some may be betting that CPU data parallelism is a dead end, that NEON is more than enough. In the GPU world (dcompute) mini/micro floats are very important for a variety of workloads, AI/ML chief among them.The interesting thing is not the existence of the types. It's how they are implemented. The X86_64 architecture does not support a 16 bit floating point type.It had some limited support starting from 2018 had AVX512-FP16. And some newer models of x86 support both FP16 and BF16. * https://networkbuilders.intel.com/docs/networkbuilders/intel-avx-512-fp16-instruction-set-for-intel-xeon-processor-based-products-technology-guide-1651874188.pdf * https://stackoverflow.com/questions/49995594/half-precision-floating-point-arithmetic-on-intel-chips Also it is important for AI/ML models, which can run on ARM CPUs, GPUs and TPUs
Jan 15
On 1/14/2025 12:33 AM, ryuukk_ wrote:What the young competition doing?I implemented halffloat a decade ago. It didn't go into the library then because there was zero interest in it.
Jan 14
I forgot to introduce this for a decision at the last meeting (lucky given how many items we had). A new policy, that anyone could implement a C numeric type as long as it bound to a druntime module, and not exposed to D. D would need a DIP due to the identifier needing confirmation. Note: this would also mean anyone could implement (u)cent and it would be pre-approved work. Also did you see my email from the day after the meeting?
Jan 14
On Tuesday, 14 January 2025 at 14:34:13 UTC, Richard (Rikki) Andrew Cattermole wrote:... A new policy, that anyone could implement a C numeric type as long as it bound to a druntime module, and not exposed to D. D would need a DIP due to the identifier needing confirmation.Is this a good path to full integration with the back ends? I'd love to see auto vectorization and other optimizations when using the new types.
Jan 14
On 15/01/2025 4:06 AM, Bruce Carneal wrote:On Tuesday, 14 January 2025 at 14:34:13 UTC, Richard (Rikki) Andrew Cattermole wrote:Yes. The functions involved can be recognized as intrinsics, and swapped out for the IR version of it.... A new policy, that anyone could implement a C numeric type as long as it bound to a druntime module, and not exposed to D. D would need a DIP due to the identifier needing confirmation.Is this a good path to full integration with the back ends? I'd love to see auto vectorization and other optimizations when using the new types.
Jan 14
On 1/14/2025 6:34 AM, Richard (Rikki) Andrew Cattermole wrote:Also did you see my email from the day after the meeting?No. What was the subject title?
Jan 14
On 15/01/2025 11:16 AM, Walter Bright wrote:On 1/14/2025 6:34 AM, Richard (Rikki) Andrew Cattermole wrote:"DFA - a potential strategy?" Oh and expect Bruce to want to talk about it next local meetup!Also did you see my email from the day after the meeting?No. What was the subject title?
Jan 14
On 1/14/2025 2:19 PM, Richard (Rikki) Andrew Cattermole wrote:"DFA - a potential strategy?" Oh and expect Bruce to want to talk about it next local meetup!Ok, I found it.
Jan 14