digitalmars.D - newCTFE Status November 2018
- Stefan Koch (14/14) Dec 07 2018 Hi All,
- H. S. Teoh (8/25) Dec 07 2018 [...]
- sarn (2/7) Dec 07 2018 Nice :) Glad to hear you have a solution.
- Joakim (11/20) Dec 07 2018 What do you mean by "cross-platform floating-point," using the
- Stefan Koch (13/31) Dec 07 2018 Yes that is what I mean. It has always been the plan, but until
- kinke (7/12) Dec 08 2018 Nope, these FP type properties represent the target type's.
- Nathan S. (32/45) Dec 09 2018 This infallibly determines the precision used for calculations
- Joakim (21/67) Dec 08 2018 OK, got that from the first question, but I was referring to what
- H. S. Teoh (22/49) Dec 09 2018 Ahhh, so *that's* the reason for the failure.
- Patrick Schluter (3/9) Dec 09 2018 size_t theoretically also but here practically there are only two
- H. S. Teoh (10/21) Dec 09 2018 [...]
- Joakim (26/79) Dec 09 2018 Specifically, real.max overflows when it tries to evaluate that
- kinke (10/20) Dec 10 2018 My point being that it's not just the CTFE engine that needs to
- Stefan Koch (7/29) Dec 10 2018 ctfloat depends on the C runtime, and therefore it's
- Iain Buclaw (6/36) Dec 10 2018 Then fix the wheel - you've already gone as far as taking one
- Stefan Koch (9/16) Dec 10 2018 Yes that is what I am going to do as soon as it works for newCTFE.
- kinke (14/26) Dec 10 2018 For DMD, yes; GDC obviously doesn't use the C runtime, and LDC
- Joakim (7/33) Dec 10 2018 I think they're implying he already got newCTFE working with a
- H. S. Teoh (7/13) Dec 08 2018 Doesn't real.dig give the (approximate) precision of real? Or is that
- Nicholas Wilson (2/16) Dec 07 2018 Its December, but awesome nonetheless!
- rikki cattermole (3/6) Dec 08 2018 D..Does that mean that root/ctfloat.d is being replaced?
- kinke (10/16) Dec 08 2018 That would be a bad idea. As I said somewhere a year ago or so,
Hi All, I have short but good news, non-default class-constructors work now. (this was tricky because of my unorthodox vtbl layout). And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2. That'll result in a compile-time testable floating point implementation ;) Pretty cool, huh. I'll give an update as soon as the compiler tests pass again. newCTFE is currently developed against 2.074.1 on the newCTFE_reboot_20741 branch. Cheers, Stefan
Dec 07 2018
On Sat, Dec 08, 2018 at 12:32:58AM +0000, Stefan Koch via Digitalmars-d wrote:Hi All, I have short but good news, non-default class-constructors work now. (this was tricky because of my unorthodox vtbl layout). And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2. That'll result in a compile-time testable floating point implementation ;) Pretty cool, huh. I'll give an update as soon as the compiler tests pass again. newCTFE is currently developed against 2.074.1 on the newCTFE_reboot_20741 branch.[...] Very happy to see progress on newCTFE. For a while I feared whether it was abandoned... Still can't wait for it to land in master, even if that's years away. T -- Being able to learn is a great learning; being able to unlearn is a greater learning.
Dec 07 2018
On Saturday, 8 December 2018 at 00:32:58 UTC, Stefan Koch wrote:And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2. That'll result in a compile-time testable floating point implementation ;) Pretty cool, huh.Nice :) Glad to hear you have a solution.
Dec 07 2018
On Saturday, 8 December 2018 at 00:32:58 UTC, Stefan Koch wrote:Hi All, I have short but good news, non-default class-constructors work now. (this was tricky because of my unorthodox vtbl layout). And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2.What do you mean by "cross-platform floating-point," using the same implementation everywhere without calling _any_ libc/arch intrinsics?That'll result in a compile-time testable floating point implementation ;) Pretty cool, huh.How does that differ from the current implementation? Btw, do you know some way to get the current compile-time real's precision in D code? It would be useful to avoid static asserts from overflowing when the runtime real's precision exceeds the compile-time real's precision, which doesn't happen with dmd but can with ldc: https://github.com/dlang/phobos/pull/6790#discussion_r238633160
Dec 07 2018
On Saturday, 8 December 2018 at 04:06:11 UTC, Joakim wrote:On Saturday, 8 December 2018 at 00:32:58 UTC, Stefan Koch wrote:Yes that is what I mean. It has always been the plan, but until recently, I saw no way to actually realize it.Hi All, I have short but good news, non-default class-constructors work now. (this was tricky because of my unorthodox vtbl layout). And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2.What do you mean by "cross-platform floating-point," using the same implementation everywhere without calling _any_ libc/arch intrinsics?Currently it relies on the host fpu. or rather the hosts float implementation. Which I intent to replace with a pure software solution, which operates independently from the host float math. And can therefore be made to behave like the targets (more or less, it's emulation).That'll result in a compile-time testable floating point implementation ;) Pretty cool, huh.How does that differ from the current implementation?Btw, do you know some way to get the current compile-time real's precision in D code?this _may_ work: static immutable ctRealPerc = () { return real.mant_dig; } ();
Dec 07 2018
On Saturday, 8 December 2018 at 07:08:54 UTC, Stefan Koch wrote:On Saturday, 8 December 2018 at 04:06:11 UTC, Joakim wrote:Nope, these FP type properties represent the target type's. There's just no way of knowing the compile-time precision at the moment, at least for LDC (DMD is x86 only and currently always uses a x87 `real_t`). For LDC, it's the host `real` precision, except for MSVC hosts, where it uses x87 (Rainer's custom implementation in dmd.root.longdouble).Btw, do you know some way to get the current compile-time real's precision in D code?this _may_ work: static immutable ctRealPerc = () { return real.mant_dig; } ();
Dec 08 2018
On Saturday, 8 December 2018 at 15:56:46 UTC, kinke wrote:On Saturday, 8 December 2018 at 07:08:54 UTC, Stefan Koch wrote:This infallibly determines the precision used for calculations involving `real` in CTFE: ---- enum ctfeRealExponentBits = () { real f = 2; foreach (i; 1 .. 2000) { real g = f * f; if (g == f) return i; f = g; } assert(0, "algorithm failure"); }(); enum ctfeMantissaBits = () { real a = 1; real b = 0.5; int bits = 0; while (a + b != a) { bits = bits + 1; b = b / 2; } // Result matches what would be reported by mant_dig // (1 greater than the actual number of mantissa bits // except for 80-bit extended precision). return bits + 1; }(); ----On Saturday, 8 December 2018 at 04:06:11 UTC, Joakim wrote:Nope, these FP type properties represent the target type's. There's just no way of knowing the compile-time precision at the moment, at least for LDC (DMD is x86 only and currently always uses a x87 `real_t`). For LDC, it's the host `real` precision, except for MSVC hosts, where it uses x87 (Rainer's custom implementation in dmd.root.longdouble).Btw, do you know some way to get the current compile-time real's precision in D code?this _may_ work: static immutable ctRealPerc = () { return real.mant_dig; } ();
Dec 09 2018
On Sunday, 9 December 2018 at 16:32:49 UTC, Nathan S. wrote:On Saturday, 8 December 2018 at 15:56:46 UTC, kinke wrote:Heh, yes, checking the precision manually with a compile-time while loop works: he meant there's no "FP type properties" that will easily give it to you.[...]This infallibly determines the precision used for calculations involving `real` in CTFE: ---- enum ctfeRealExponentBits = () { real f = 2; foreach (i; 1 .. 2000) { real g = f * f; if (g == f) return i; f = g; } assert(0, "algorithm failure"); }(); enum ctfeMantissaBits = () { real a = 1; real b = 0.5; int bits = 0; while (a + b != a) { bits = bits + 1; b = b / 2; } // Result matches what would be reported by mant_dig // (1 greater than the actual number of mantissa bits // except for 80-bit extended precision). return bits + 1; }(); ----
Dec 09 2018
On Sunday, 9 December 2018 at 16:32:49 UTC, Nathan S. wrote:This infallibly determines the precision used for calculations involving `real` in CTFE:Compiled code shouldn't have to know, it just needs to be sufficiently high. - I'm not so sure about 'infallibly', there's a theoretical chance for the super-duper IBM doubledouble format being used too.
Dec 09 2018
On Saturday, 8 December 2018 at 07:08:54 UTC, Stefan Koch wrote:On Saturday, 8 December 2018 at 04:06:11 UTC, Joakim wrote:OK, got that from the first question, but I was referring to what you called "compile-time testable?" I didn't understand what using a fully soft-float implementation added in that regard.On Saturday, 8 December 2018 at 00:32:58 UTC, Stefan Koch wrote:Yes that is what I mean. It has always been the plan, but until recently, I saw no way to actually realize it.Hi All, I have short but good news, non-default class-constructors work now. (this was tricky because of my unorthodox vtbl layout). And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2.What do you mean by "cross-platform floating-point," using the same implementation everywhere without calling _any_ libc/arch intrinsics?Currently it relies on the host fpu. or rather the hosts float implementation. Which I intent to replace with a pure software solution, which operates independently from the host float math. And can therefore be made to behave like the targets (more or less, it's emulation).That'll result in a compile-time testable floating point implementation ;) Pretty cool, huh.How does that differ from the current implementation?No, as kinke says, it doesn't work with ldc. On Saturday, 8 December 2018 at 15:42:43 UTC, H. S. Teoh wrote:Btw, do you know some way to get the current compile-time real's precision in D code?this _may_ work: static immutable ctRealPerc = () { return real.mant_dig; } ();On Sat, Dec 08, 2018 at 04:06:11AM +0000, Joakim via Digitalmars-d wrote: [...]Just so we're clear, the issue is what the precision of reals are when running CTFE code to initialize a constant, as opposed to the precision of the real at runtime. For dmd, this doesn't really matter since it only supports x86/x64 chips, but ldc uses the host's real at compile-time, which can obviously vary from the target. That's why I mentioned to you in another thread that some stdlib math tests assert when cross-compiling from x64 to Android/AArch64, because of that mismatch in host->target precision for reals. real.dig has the same problem as real.mant_dig above, it only gives the target's precision. Compiling this snippet with ldc, `void main() { pragma(msg, "precision is ", real.dig);}`, I get 18 when compiling natively on linux/x64, but 33 when cross-compiling to Android/AArch64, ie it always gives the target real's precision.Btw, do you know some way to get the current compile-time real's precision in D code? It would be useful to avoid static asserts from overflowing when the runtime real's precision exceeds the compile-time real's precision, which doesn't happen with dmd but can with ldc: https://github.com/dlang/phobos/pull/6790#discussion_r238633160Doesn't real.dig give the (approximate) precision of real? Or is that hard-coded in the frontend?
Dec 08 2018
On Sat, Dec 08, 2018 at 05:19:59PM +0000, Joakim via Digitalmars-d wrote: [...]On Saturday, 8 December 2018 at 15:42:43 UTC, H. S. Teoh wrote:Ahhh, so *that's* the reason for the failure. But I'd think that's more than just a floating-point issue; wouldn't CTFE in general be problematic if there's a mismatch between host built-in types vs. target built-in types when cross-compiling? I suppose D's fixed-sized types help a lot in this regard (imagine the mess if `int` varies in size across host/target archs -- the kind of mess C/C++ have to deal with). But `real` is a fly in the ointment. I'd imagine difference in endianness would be another cause of problems in cross-compilation, though for the most part typical D code wouldn't be affected by this at least as far as CTFE is concerned (since casting / reinterpretation of unions is not currently allowed).On Sat, Dec 08, 2018 at 04:06:11AM +0000, Joakim via Digitalmars-d wrote: [...]Just so we're clear, the issue is what the precision of reals are when running CTFE code to initialize a constant, as opposed to the precision of the real at runtime. For dmd, this doesn't really matter since it only supports x86/x64 chips, but ldc uses the host's real at compile-time, which can obviously vary from the target. That's why I mentioned to you in another thread that some stdlib math tests assert when cross-compiling from x64 to Android/AArch64, because of that mismatch in host->target precision for reals.Btw, do you know some way to get the current compile-time real's precision in D code? It would be useful to avoid static asserts from overflowing when the runtime real's precision exceeds the compile-time real's precision, which doesn't happen with dmd but can with ldc: https://github.com/dlang/phobos/pull/6790#discussion_r238633160Doesn't real.dig give the (approximate) precision of real? Or is that hard-coded in the frontend?real.dig has the same problem as real.mant_dig above, it only gives the target's precision. Compiling this snippet with ldc, `void main() { pragma(msg, "precision is ", real.dig);}`, I get 18 when compiling natively on linux/x64, but 33 when cross-compiling to Android/AArch64, ie it always gives the target real's precision.Which it should, since any code that depends on real.dig is ostensibly expecting the target arch's precision, not the host's which may change depending on which host you use to compile it. Looks like we'll somehow need a way to tell the CTFE engine what the target arch should be, and when something doesn't match the host type, it should run a software emulation instead of using the host's `real`. T -- Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- Carl B. Constantine
Dec 09 2018
On Sunday, 9 December 2018 at 14:48:31 UTC, H. S. Teoh wrote:On Sat, Dec 08, 2018 at 05:19:59PM +0000, Joakim via Digitalmars-d wrote: [...]size_t theoretically also but here practically there are only two sizes to take care of 4 and 8.[...]Ahhh, so *that's* the reason for the failure. [...][...]
Dec 09 2018
On Sun, Dec 09, 2018 at 03:16:16PM +0000, Patrick Schluter via Digitalmars-d wrote:On Sunday, 9 December 2018 at 14:48:31 UTC, H. S. Teoh wrote:[...] Since size_t is an alias to a concrete fixed-sized int type, I don't think it would actually be a problem. The alias AFAIK depends only on the version identifiers, which are always set for the target arch, so size_t will always alias to the correct target type even when run in CTFE on a host with a different size_t. T -- Latin's a dead language, as dead as can be; it killed off all the Romans, and now it's killing me! -- SchoolboyOn Sat, Dec 08, 2018 at 05:19:59PM +0000, Joakim via Digitalmars-d wrote: [...]size_t theoretically also but here practically there are only two sizes to take care of 4 and 8.[...]Ahhh, so *that's* the reason for the failure. [...]
Dec 09 2018
On Sunday, 9 December 2018 at 14:48:31 UTC, H. S. Teoh wrote:On Sat, Dec 08, 2018 at 05:19:59PM +0000, Joakim via Digitalmars-d wrote: [...]Specifically, real.max overflows when it tries to evaluate that expression, as it tries to stick the 128-bit real.max in the 80-bit x87 real and overflows to Inf, tripping the static assert.On Saturday, 8 December 2018 at 15:42:43 UTC, H. S. Teoh wrote:Ahhh, so *that's* the reason for the failure.On Sat, Dec 08, 2018 at 04:06:11AM +0000, Joakim via Digitalmars-d wrote: [...]Just so we're clear, the issue is what the precision of reals are when running CTFE code to initialize a constant, as opposed to the precision of the real at runtime. For dmd, this doesn't really matter since it only supports x86/x64 chips, but ldc uses the host's real at compile-time, which can obviously vary from the target. That's why I mentioned to you in another thread that some stdlib math tests assert when cross-compiling from x64 to Android/AArch64, because of that mismatch in host->target precision for reals.Btw, do you know some way to get the current compile-time real's precision in D code? It would be useful to avoid static asserts from overflowing when the runtime real's precision exceeds the compile-time real's precision, which doesn't happen with dmd but can with ldc: https://github.com/dlang/phobos/pull/6790#discussion_r238633160Doesn't real.dig give the (approximate) precision of real? Or is that hard-coded in the frontend?But I'd think that's more than just a floating-point issue; wouldn't CTFE in general be problematic if there's a mismatch between host built-in types vs. target built-in types when cross-compiling? I suppose D's fixed-sized types help a lot in this regard (imagine the mess if `int` varies in size across host/target archs -- the kind of mess C/C++ have to deal with). But `real` is a fly in the ointment.Yes, this is called out in the spec: "Functions executed via CTFE can give different results from run time in the following scenarios: - floating point computations may be done at a higher precision than run time" https://dlang.org/spec/function.html#interpretation Of course, that was likely written before we started supporting 64-bit and 128-bit reals, so it was probably assumed that 80-bit x87 reals would always be used at compile-time and at worst would be _more_ precise. That's not the case with ldc anymore, since ldc running on an ARM host will do CTFE at 64-bit precision and 80-bit on an x64 host isn't enough when cross-compiling to 128-bit AArch64 reals.I'd imagine difference in endianness would be another cause of problems in cross-compilation, though for the most part typical D code wouldn't be affected by this at least as far as CTFE is concerned (since casting / reinterpretation of unions is not currently allowed).Unsure.I tried various other ways before, like checking an enum's precision or inside a __ctfe block, but they all give the target's precision, as kinke says, even though they're running at compile-time.real.dig has the same problem as real.mant_dig above, it only gives the target's precision. Compiling this snippet with ldc, `void main() { pragma(msg, "precision is ", real.dig);}`, I get 18 when compiling natively on linux/x64, but 33 when cross-compiling to Android/AArch64, ie it always gives the target real's precision.Which it should, since any code that depends on real.dig is ostensibly expecting the target arch's precision, not the host's which may change depending on which host you use to compile it.Looks like we'll somehow need a way to tell the CTFE engine what the target arch should be, and when something doesn't match the host type, it should run a software emulation instead of using the host's `real`.Yes, Iain says gdc already uses such multi-precision soft-float, and kinke mentioned earlier in this thread that he'd like to do the same with ldc. The reason I brought this issue up is that Stefan initially mentioned doing something similar for dmd.
Dec 09 2018
On Sunday, 9 December 2018 at 15:23:30 UTC, Joakim wrote:On Sunday, 9 December 2018 at 14:48:31 UTC, H. S. Teoh wrote:My point being that it's not just the CTFE engine that needs to support compile-time reals (real_t) of at least target `real` precision. FP literals have to be parsed by the front-end, need to be printable to string (template instantiations, header generation etc.) and stored, and this is currently taken care of by the `real_t` type and the dmd.root.ctfloat module. So ideally, newCTFE would just keep on relying on that infrastructure, just like the current interpreter (+ dmd.builtin module) does, instead of trying to reinvent the wheel.Looks like we'll somehow need a way to tell the CTFE engine what the target arch should be, and when something doesn't match the host type, it should run a software emulation instead of using the host's `real`.Yes, Iain says gdc already uses such multi-precision soft-float, and kinke mentioned earlier in this thread that he'd like to do the same with ldc. The reason I brought this issue up is that Stefan initially mentioned doing something similar for dmd.
Dec 10 2018
On Monday, 10 December 2018 at 11:04:47 UTC, kinke wrote:On Sunday, 9 December 2018 at 15:23:30 UTC, Joakim wrote:ctfloat depends on the C runtime, and therefore it's implementation dependent. I'd rather go with an implementation which I have verified myself. And where I can give meaningful statements about what it can, and can't support. I'd love to not re-invent the weel; But we don't have a wheel.On Sunday, 9 December 2018 at 14:48:31 UTC, H. S. Teoh wrote:My point being that it's not just the CTFE engine that needs to support compile-time reals (real_t) of at least target `real` precision. FP literals have to be parsed by the front-end, need to be printable to string (template instantiations, header generation etc.) and stored, and this is currently taken care of by the `real_t` type and the dmd.root.ctfloat module. So ideally, newCTFE would just keep on relying on that infrastructure, just like the current interpreter (+ dmd.builtin module) does, instead of trying to reinvent the wheel.Looks like we'll somehow need a way to tell the CTFE engine what the target arch should be, and when something doesn't match the host type, it should run a software emulation instead of using the host's `real`.Yes, Iain says gdc already uses such multi-precision soft-float, and kinke mentioned earlier in this thread that he'd like to do the same with ldc. The reason I brought this issue up is that Stefan initially mentioned doing something similar for dmd.
Dec 10 2018
On Mon, 10 Dec 2018 at 14:00, Stefan Koch via Digitalmars-d <digitalmars-d puremagic.com> wrote:On Monday, 10 December 2018 at 11:04:47 UTC, kinke wrote:Then fix the wheel - you've already gone as far as taking one soft-float implementation, use it for the alias to real_t! -- IainOn Sunday, 9 December 2018 at 15:23:30 UTC, Joakim wrote:ctfloat depends on the C runtime, and therefore it's implementation dependent. I'd rather go with an implementation which I have verified myself. And where I can give meaningful statements about what it can, and can't support. I'd love to not re-invent the weel; But we don't have a wheel.On Sunday, 9 December 2018 at 14:48:31 UTC, H. S. Teoh wrote:My point being that it's not just the CTFE engine that needs to support compile-time reals (real_t) of at least target `real` precision. FP literals have to be parsed by the front-end, need to be printable to string (template instantiations, header generation etc.) and stored, and this is currently taken care of by the `real_t` type and the dmd.root.ctfloat module. So ideally, newCTFE would just keep on relying on that infrastructure, just like the current interpreter (+ dmd.builtin module) does, instead of trying to reinvent the wheel.Looks like we'll somehow need a way to tell the CTFE engine what the target arch should be, and when something doesn't match the host type, it should run a software emulation instead of using the host's `real`.Yes, Iain says gdc already uses such multi-precision soft-float, and kinke mentioned earlier in this thread that he'd like to do the same with ldc. The reason I brought this issue up is that Stefan initially mentioned doing something similar for dmd.
Dec 10 2018
On Monday, 10 December 2018 at 13:20:32 UTC, Iain Buclaw wrote:On Mon, 10 Dec 2018 at 14:00, Stefan Koch via Digitalmars-d <digitalmars-d puremagic.com> wrote:Yes that is what I am going to do as soon as it works for newCTFE. The library will take a while to reverse-engineer and rewrite in D though. It is under the BSD licence, and I don't know if that'll be accepted for ldc/gdc or even dmd. When I have gone though that of course it should be used in the whole frontend. But as I said, it'll take a while.I'd love to not re-invent the weel; But we don't have a wheel.Then fix the wheel - you've already gone as far as taking one soft-float implementation, use it for the alias to real_t!
Dec 10 2018
On Monday, 10 December 2018 at 13:20:32 UTC, Iain Buclaw wrote:On Mon, 10 Dec 2018 at 14:00, Stefan Koch via Digitalmars-dFor DMD, yes; GDC obviously doesn't use the C runtime, and LDC does partially (which should be fixed at some point).ctfloat depends on the C runtime, and therefore it's implementation dependent.Again, that's the case for DMD. Considering DMD only supports x86 targets with x87 reals and isn't really usable/used for cross-compilation, one could argue that using a software real_t for DMD is overkill, reducing CTFE speed for host-C-runtime-independent results (which might lead to new runtime/compile-time divergences).I'd rather go with an implementation which I have verified myself. And where I can give meaningful statements about what it can, and can't support. I'd love to not re-invent the weel; But we don't have a wheel.Then fix the wheel - you've already gone as far as taking one soft-float implementation, use it for the alias to real_t!My impression was that Stefan was about to port some implementation, that's why I interfered, in the hopes of accelerating newCTFE deployment. ;) - So if it's already implemented and fully in D, then perfect, I'll be more than happy to incorporate it as LDC's real_t. :)
Dec 10 2018
On Monday, 10 December 2018 at 14:36:36 UTC, kinke wrote:On Monday, 10 December 2018 at 13:20:32 UTC, Iain Buclaw wrote:I think they're implying he already got newCTFE working with a BSD-licensed softfloat-2 written in C, and he plans to rewrite its functionality in D and Boost-license it. Might be a good idea for ldc to use that C softfloat-2 library too, since ldc's BSD-licensed anyway, as opposed to the LGPL-licensed MPFR.On Mon, 10 Dec 2018 at 14:00, Stefan Koch via Digitalmars-dFor DMD, yes; GDC obviously doesn't use the C runtime, and LDC does partially (which should be fixed at some point).ctfloat depends on the C runtime, and therefore it's implementation dependent.Again, that's the case for DMD. Considering DMD only supports x86 targets with x87 reals and isn't really usable/used for cross-compilation, one could argue that using a software real_t for DMD is overkill, reducing CTFE speed for host-C-runtime-independent results (which might lead to new runtime/compile-time divergences).I'd rather go with an implementation which I have verified myself. And where I can give meaningful statements about what it can, and can't support. I'd love to not re-invent the weel; But we don't have a wheel.Then fix the wheel - you've already gone as far as taking one soft-float implementation, use it for the alias to real_t!My impression was that Stefan was about to port some implementation, that's why I interfered, in the hopes of accelerating newCTFE deployment. ;) - So if it's already implemented and fully in D, then perfect, I'll be more than happy to incorporate it as LDC's real_t. :)
Dec 10 2018
On Sat, Dec 08, 2018 at 04:06:11AM +0000, Joakim via Digitalmars-d wrote: [...]Btw, do you know some way to get the current compile-time real's precision in D code? It would be useful to avoid static asserts from overflowing when the runtime real's precision exceeds the compile-time real's precision, which doesn't happen with dmd but can with ldc: https://github.com/dlang/phobos/pull/6790#discussion_r238633160Doesn't real.dig give the (approximate) precision of real? Or is that hard-coded in the frontend? T -- Genius may have its limitations, but stupidity is not thus handicapped. -- Elbert Hubbard
Dec 08 2018
On Saturday, 8 December 2018 at 00:32:58 UTC, Stefan Koch wrote:Hi All, I have short but good news, non-default class-constructors work now. (this was tricky because of my unorthodox vtbl layout). And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2. That'll result in a compile-time testable floating point implementation ;) Pretty cool, huh. I'll give an update as soon as the compiler tests pass again. newCTFE is currently developed against 2.074.1 on the newCTFE_reboot_20741 branch. Cheers, StefanIts December, but awesome nonetheless!
Dec 07 2018
On 08/12/2018 1:32 PM, Stefan Koch wrote:And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2.D..Does that mean that root/ctfloat.d is being replaced? https://issues.dlang.org/show_bug.cgi?id=18810
Dec 08 2018
On Saturday, 8 December 2018 at 10:04:19 UTC, rikki cattermole wrote:On 08/12/2018 1:32 PM, Stefan Koch wrote:That would be a bad idea. As I said somewhere a year ago or so, newCTFE should probably just rely on `real_t` providing the required operations (custom operators etc.). The host needs to store compile-time FP values in a format suited for the target, and that's where a `real_t` (for the full front-end, not just CTFE) comes in. GDC already uses a software `real_t` AFAIK; LDC will eventually too, probably based on https://www.mpfr.org/.And another exciting news item, newCTFE is going to support cross-platform floating-point as soon as I got around to re-implementing, the qemu fork of softfloat-2.D..Does that mean that root/ctfloat.d is being replaced? https://issues.dlang.org/show_bug.cgi?id=18810
Dec 08 2018