digitalmars.D - Can we have ucent ?
- Basile B. (8/8) Oct 30 2018 For the first time today i had needed the ucent type. Fortunately
- Stanislav Blinov (4/6) Oct 30 2018 Umm, no, thank you very much. It's bad enough that array
- Steven Schveighoffer (8/16) Oct 30 2018 Well, wouldn't it be like a backup implementation if the CPU doesn't
- Stanislav Blinov (6/21) Oct 30 2018 So long as it doesn't compile into shared library calls, I guess
- 12345swordy (5/21) Oct 30 2018 There no reason to put it into the druntime. Just have the
- kinke (4/7) Oct 30 2018 Oh yes, there are very good reasons for it. Dynamic compilation
- 12345swordy (3/10) Oct 30 2018 Dog slow? You compile it once! I don't know that hardware specs
- kinke (3/5) Oct 30 2018 You don't compile it at all if its precompiled in druntime. If
- Neia Neutuladh (9/21) Oct 30 2018 You compile once for every time the executable is run. In many cases, th...
- 12345swordy (4/5) Oct 30 2018 Not quite. It only compiles when the compileDynamicCode()
- Basile B. (8/14) Oct 30 2018 Yes but some operations don't have a matching instruction, for
- Basile B. (6/14) Oct 31 2018 Maybe the D foundation could finance a developer for this ? 300 €
- Stefan Koch (3/18) Oct 31 2018 The hard parts here are Efficient and correct Division,
- kinke (6/8) Oct 31 2018 LDC (and most likely GDC too) wouldn't have to do much, just
- solidstate1991 (19/27) Nov 02 2018 I was toying with using SSE2 for bitwise operations, however it
- Johan Engelen (16/24) Nov 03 2018 LDC has had a PR open for adding `ucent` since a long time [*].
- Walter Bright (3/12) Nov 03 2018 Yes it could be done like the soft float is currently done for 80 bit re...
- Iain Buclaw (6/18) Nov 03 2018 On my todo list. ;-)
For the first time today i had needed the ucent type. Fortunately it was only for bit operations so easy to do as a struct, however this is two hours lost for a type that's in a curious state (rename it shrodinger128 maybe ?). I think that the feature could be implemented as compiler special functions that would be located in druntime (with special case for GDC and LDC since the type exists in their respective backend if i understand correctly).
Oct 30 2018
On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:I think that the feature could be implemented as compiler special functions that would be located in druntime...Umm, no, thank you very much. It's bad enough that array operations have to go through druntime. Arithmetic types have no business being there whatsoever.
Oct 30 2018
On 10/30/18 2:23 PM, Stanislav Blinov wrote:On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:Well, wouldn't it be like a backup implementation if the CPU doesn't have 128-bit registers? This is actually something I would EXPECT to be in druntime, since it's very platform/compiler specific. array operations are just there because of legacy (at least in the form they are in). -SteveI think that the feature could be implemented as compiler special functions that would be located in druntime...Umm, no, thank you very much. It's bad enough that array operations have to go through druntime. Arithmetic types have no business being there whatsoever.
Oct 30 2018
On Tuesday, 30 October 2018 at 18:35:59 UTC, Steven Schveighoffer wrote:On 10/30/18 2:23 PM, Stanislav Blinov wrote:So long as it doesn't compile into shared library calls, I guess it could be fine.On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:Well, wouldn't it be like a backup implementation if the CPU doesn't have 128-bit registers?I think that the feature could be implemented as compiler special functions that would be located in druntime...Umm, no, thank you very much. It's bad enough that array operations have to go through druntime. Arithmetic types have no business being there whatsoever.This is actually something I would EXPECT to be in druntime, since it's very platform/compiler specific.It's very CPU/compiler-specific, not runtime-specific though.array operations are just there because of legacy (at least in the form they are in).Sad story of D's life :(
Oct 30 2018
On Tuesday, 30 October 2018 at 18:35:59 UTC, Steven Schveighoffer wrote:On 10/30/18 2:23 PM, Stanislav Blinov wrote:There no reason to put it into the druntime. Just have the functions themselves be dynamically compiled during runtime. https://wiki.dlang.org/LDC-specific_language_changes#.40.28ldc.attributes.dynamicCompile.29On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:Well, wouldn't it be like a backup implementation if the CPU doesn't have 128-bit registers? This is actually something I would EXPECT to be in druntime, since it's very platform/compiler specific. array operations are just there because of legacy (at least in the form they are in). -SteveI think that the feature could be implemented as compiler special functions that would be located in druntime...Umm, no, thank you very much. It's bad enough that array operations have to go through druntime. Arithmetic types have no business being there whatsoever.
Oct 30 2018
On Tuesday, 30 October 2018 at 19:04:00 UTC, 12345swordy wrote:There no reason to put it into the druntime. Just have the functions themselves be dynamically compiled during runtime. https://wiki.dlang.org/LDC-specific_language_changes#.40.28ldc.attributes.dynamicCompile.29Oh yes, there are very good reasons for it. Dynamic compilation would be dog slow for tiny programs, and depend on a ~20 MB DLL for code generation, besides obviously being LDC specific.
Oct 30 2018
On Tuesday, 30 October 2018 at 19:25:18 UTC, kinke wrote:On Tuesday, 30 October 2018 at 19:04:00 UTC, 12345swordy wrote:Dog slow? You compile it once! I don't know that hardware specs that TC is targeting at.There no reason to put it into the druntime. Just have the functions themselves be dynamically compiled during runtime. https://wiki.dlang.org/LDC-specific_language_changes#.40.28ldc.attributes.dynamicCompile.29Oh yes, there are very good reasons for it. Dynamic compilation would be dog slow for tiny programs, and depend on a ~20 MB DLL for code generation, besides obviously being LDC specific.
Oct 30 2018
On Tuesday, 30 October 2018 at 20:07:59 UTC, 12345swordy wrote:Dog slow? You compile it once! I don't know that hardware specs that TC is targeting at.You don't compile it at all if its precompiled in druntime. If you don't fancy druntime calls, just use LTO.
Oct 30 2018
On Tue, 30 Oct 2018 20:07:59 +0000, 12345swordy wrote:On Tuesday, 30 October 2018 at 19:25:18 UTC, kinke wrote:40.28ldc.attributes.dynamicCompile.29On Tuesday, 30 October 2018 at 19:04:00 UTC, 12345swordy wrote:There no reason to put it into the druntime. Just have the functions themselves be dynamically compiled during runtime. https://wiki.dlang.org/LDC-specific_language_changes#.You compile once for every time the executable is run. In many cases, that doesn't matter. In some cases, it's a large problem. Except with only a small number of JIT-compiled functions, it shouldn't be as large an issue most of the time. This does mean an indirect call that can't be inlined for most 128-bit math operations. Which might be slower on average than a user-defined struct for fixed-length integers with an arbitrary number of bits.Oh yes, there are very good reasons for it. Dynamic compilation would be dog slow for tiny programs, and depend on a ~20 MB DLL for code generation, besides obviously being LDC specific.Dog slow? You compile it once! I don't know that hardware specs that TC is targeting at.
Oct 30 2018
On Tuesday, 30 October 2018 at 22:17:26 UTC, Neia Neutuladh wrote:You compile once for every time the executable is run.Not quite. It only compiles when the compileDynamicCode() function is called. It quite possible that the program may never call the function and never use the dynamic compile functions.
Oct 30 2018
On Tuesday, 30 October 2018 at 18:23:59 UTC, Stanislav Blinov wrote:On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:Yes but some operations don't have a matching instruction, for example even on x86_64, shifting requires recent BMI2 instructions because standard SSE integer shifting is done by step of 8 bits only, hence you have to implement the stuff in a specific functions giving an AST that's maybe a bit too complex to be generated by the compiler.I think that the feature could be implemented as compiler special functions that would be located in druntime...Umm, no, thank you very much. It's bad enough that array operations have to go through druntime. Arithmetic types have no business being there whatsoever.
Oct 30 2018
On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:For the first time today i had needed the ucent type. Fortunately it was only for bit operations so easy to do as a struct, however this is two hours lost for a type that's in a curious state (rename it shrodinger128 maybe ?). I think that the feature could be implemented as compiler special functions that would be located in druntime (with special case for GDC and LDC since the type exists in their respective backend if i understand correctly).Maybe the D foundation could finance a developer for this ? 300 € sounds fine imo, because it's not so hard, the guy has to do it for DMD and communicate with the LDC/GDC devels so that they put the specific backend things. And after it's a long term stuff, meaning that ucent/cent types are there.
Oct 31 2018
On Wednesday, 31 October 2018 at 22:02:34 UTC, Basile B. wrote:On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:The hard parts here are Efficient and correct Division, Multiplication as well as Converting from and to Floating-Point.For the first time today i had needed the ucent type. Fortunately it was only for bit operations so easy to do as a struct, however this is two hours lost for a type that's in a curious state (rename it shrodinger128 maybe ?). I think that the feature could be implemented as compiler special functions that would be located in druntime (with special case for GDC and LDC since the type exists in their respective backend if i understand correctly).Maybe the D foundation could finance a developer for this ? 300 € sounds fine imo, because it's not so hard, the guy has to do it for DMD and communicate with the LDC/GDC devels so that they put the specific backend things. And after it's a long term stuff, meaning that ucent/cent types are there.
Oct 31 2018
On Wednesday, 31 October 2018 at 22:02:34 UTC, Basile B. wrote:the guy has to do it for DMD and communicate with the LDC/GDC devels so that they put the specific backend things.LDC (and most likely GDC too) wouldn't have to do much, just making use of the `i128` type. The arithmetic operations and conversions from/to floating-point are most likely lowered to runtime calls anyway, e.g., __multi3 for multiplication (https://github.com/llvm-mirror/compiler-rt/blob/master/lib/builtins/multi3.c). DMD could even simply use LLVM's compiler-rt builtins library containing those implementations too instead of going through the trouble of porting them to D.
Oct 31 2018
On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:For the first time today i had needed the ucent type. Fortunately it was only for bit operations so easy to do as a struct, however this is two hours lost for a type that's in a curious state (rename it shrodinger128 maybe ?). I think that the feature could be implemented as compiler special functions that would be located in druntime (with special case for GDC and LDC since the type exists in their respective backend if i understand correctly).I was toying with using SSE2 for bitwise operations, however it turned out to be a total waste of time. I was thinking on using it for pixel-precise collision detection, but was very unstable and prone to bugs, so I defaulted to the previous per-pixel detection method but kept the bitarrays for collision shapes. If I ever going to use a multi-pixel approach, I'm going to do it on a per-byte basis: It's way easier on a small scale, especially if I put a very common restriction of that the sprites/tiles must be the multiple of 8. TransformableTileLayer already have the restriction of tile sizes must be the power of two for superfast division (through the bit-shift method) and modulo (through "& (divider-1)" method) operations. I was also thinking on using 128bit approach on my LZHAM port, but the issue there is that it's very clunky to implement, restricted to certain processors and compilers (unless I want to go with a hard-to-debug assembly code), and the algorithm overhead might make it even slower than 32 or 64bit register usage.
Nov 02 2018
On Tuesday, 30 October 2018 at 18:07:23 UTC, Basile B. wrote:For the first time today i had needed the ucent type. Fortunately it was only for bit operations so easy to do as a struct, however this is two hours lost for a type that's in a curious state (rename it shrodinger128 maybe ?). I think that the feature could be implemented as compiler special functions that would be located in druntime (with special case for GDC and LDC since the type exists in their respective backend if i understand correctly).LDC has had a PR open for adding `ucent` since a long time [*]. The biggest implementation hurdle seems to be that we (LDC) don't have our own frontend. In my opinion this effort should be split into two parts: 1 - Add `ucent` support to the frontend (semantic analysis, CTFE) Simply emit an error in the backend when `ucent` codegen is requested, saying that "ucent is not yet supported for the current target". `wideint` library could be used to do 128-bit math at compile-time. 2 - Add `ucent` support to DMD, LDC, GDC backends. (easy for LDC and GDC) - Johan [*] https://github.com/ldc-developers/ldc/pull/1355
Nov 03 2018
On 11/3/2018 5:58 AM, Johan Engelen wrote:LDC has had a PR open for adding `ucent` since a long time [*]. The biggest implementation hurdle seems to be that we (LDC) don't have our own frontend. In my opinion this effort should be split into two parts: 1 - Add `ucent` support to the frontend (semantic analysis, CTFE) Simply emit an error in the backend when `ucent` codegen is requested, saying that "ucent is not yet supported for the current target". `wideint` library could be used to do 128-bit math at compile-time. 2 - Add `ucent` support to DMD, LDC, GDC backends. (easy for LDC and GDC)Yes it could be done like the soft float is currently done for 80 bit reals. https://github.com/dlang/dmd/blob/master/src/dmd/root/longdouble.d
Nov 03 2018
On Sun, 4 Nov 2018 at 01:50, Walter Bright via Digitalmars-d <digitalmars-d puremagic.com> wrote:On 11/3/2018 5:58 AM, Johan Engelen wrote:On my todo list. ;-) https://github.com/dlang/dmd/pull/7699 -- IainLDC has had a PR open for adding `ucent` since a long time [*]. The biggest implementation hurdle seems to be that we (LDC) don't have our own frontend. In my opinion this effort should be split into two parts: 1 - Add `ucent` support to the frontend (semantic analysis, CTFE) Simply emit an error in the backend when `ucent` codegen is requested, saying that "ucent is not yet supported for the current target". `wideint` library could be used to do 128-bit math at compile-time. 2 - Add `ucent` support to DMD, LDC, GDC backends. (easy for LDC and GDC)Yes it could be done like the soft float is currently done for 80 bit reals. https://github.com/dlang/dmd/blob/master/src/dmd/root/longdouble.d
Nov 03 2018