String switch is odd using betterC

2020-02-26 Thread Abby via Digitalmars-d-learn
I have a simple enum of strings like so: enum Alphabet : string { a = "A", b = "B", c = "C", d = "D", e = "E", f = "F", g = "G" } and then simple final switch like so: extern(C) void main() { auto s = Alphabet.f; final switch(s) { case Alphabet.a:

Re: String switch is odd using betterC

2020-02-26 Thread Abby via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote: /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(2999): Error: TypeInfo cannot be used with -betterC Odd think is that wehen I remove g from my enum it compiles just fine, so it seems that this compilation error occurs only

Re: String switch is odd using betterC

2020-02-26 Thread Abby via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote: Any idea why? Ok so this is enough to produce the same result, it seems that there is a problem in string switch when there is more the 6 cases. extern(C) void main() { auto s = "F"; final switch(s) { case "A":

Re: String switch is odd using betterC

2020-02-26 Thread Petar via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 08:32:50 UTC, Abby wrote: On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote: Any idea why? Ok so this is enough to produce the same result, it seems that there is a problem in string switch when there is more the 6 cases. extern(C) void main() {

Re: String switch is odd using betterC

2020-02-26 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 08:32:50 UTC, Abby wrote: On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote: Any idea why? Ok so this is enough to produce the same result, it seems that there is a problem in string switch when there is more the 6 cases. extern(C) void main() {

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: So after reading the translation of RYU I was interested too see if the decimalLength() function can be written to be faster, as it cascades up to 8 CMP. [...] It can be made faster using binary search. Not by much though. You

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: How is that possible ? It turns out that there's a problem with the benchmarking method. With command line argument the different optimization passes of LLVM don't fuck up with the literal constants. It appears that none of th

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Bruce Carneal via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 13:50:11 UTC, Basile B. wrote: On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: ... foreach (i; 0 .. count) sum += funcs[func](i); The input stream is highly predictable and strongly skewed towards higher digits. The winning funct

SQLite 3 support?

2020-02-26 Thread mark via Digitalmars-d-learn
There seems to be some support for SQLite 3 in std. lib. etc when looking at the stable docs: https://dlang.org/phobos/etc_c_sqlite3.html But this isn't visible when looking at stable (ddox). Is this the best SQLite 3 library to use or is a third-party library best? For example https://github

Re: SQLite 3 support?

2020-02-26 Thread tchaloupka via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 20:06:20 UTC, mark wrote: There seems to be some support for SQLite 3 in std. lib. etc when looking at the stable docs: https://dlang.org/phobos/etc_c_sqlite3.html But this isn't visible when looking at stable (ddox). Is this the best SQLite 3 library to use o

Re: SQLite 3 support?

2020-02-26 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 20:06:20 UTC, mark wrote: There seems to be some support for SQLite 3 in std. lib. etc when looking at the stable docs: https://dlang.org/phobos/etc_c_sqlite3.html But this isn't visible when looking at stable (ddox). Is this the best SQLite 3 library to use o

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Bruce Carneal via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 19:44:05 UTC, Bruce Carneal wrote: On Wednesday, 26 February 2020 at 13:50:11 UTC, Basile B. wrote: On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: ... foreach (i; 0 .. count) sum += funcs[func](i); The input stream is highly pred

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Johan via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: So after reading the translation of RYU I was interested too see if the decimalLength() function can be written to be faster, as it cascades up to 8 CMP. ... Then bad surprise. Even with ldmd (so ldc2 basically) feeded with the

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 22:07:30 UTC, Johan wrote: On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: [...] Hi Basile, I recently saw this presentation: https://www.youtube.com/watch?v=Czr5dBfs72U It has some ideas that may help you make sure your measurements are g

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 20:44:31 UTC, Bruce Carneal wrote: The winning function implementation lines up with that distribution. It would not fare as well with higher entropy input. Using sorted equi-probable inputs (N 1 digit numbers, N 2 digit numbers, ...) decimalLength9_0 beats

DMD 2.090.1: SIGILL, Illegal instruction on (ahem) intel Pentium III

2020-02-26 Thread kdevel via Digitalmars-d-learn
```test.d void main () { int [] v = new int [10]; } ``` $ [...]linux/bin32/dmd test $ gdb test [...] (gdb) r [...] Program received signal SIGILL, Illegal instruction. 0x0809ad14 in _D2gc4impl12conservativeQw3Gcx10smallAllocMFNbkKkkxC8TypeInfoZPv () [...] (gdb) disass [...] 0x0809ad14 <_D2

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Bruce Carneal via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 23:09:34 UTC, Basile B. wrote: On Wednesday, 26 February 2020 at 20:44:31 UTC, Bruce Carneal wrote: After shuffling the input, branchless wins by 2.4X (240%). I've replaced the input by the front of a rndGen (that pops for count times and starting with a cus

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Bruce Carneal via Digitalmars-d-learn
On Thursday, 27 February 2020 at 03:58:15 UTC, Bruce Carneal wrote: On Wednesday, 26 February 2020 at 23:09:34 UTC, Basile B. wrote: On Wednesday, 26 February 2020 at 20:44:31 UTC, Bruce Carneal wrote: After shuffling the input, branchless wins by 2.4X (240%). snip Let me know if the abov

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 27 February 2020 at 03:58:15 UTC, Bruce Carneal wrote: Maybe you talked about another implementation of decimalLength9 ? Yes. It's one I wrote after I saw your post. Psuedo-code here: auto d9_branchless(uint v) { return 1 + (v >= 10) + (v >= 100) ... } Using ldc to target

Re: DMD 2.090.1: SIGILL, Illegal instruction on (ahem) intel Pentium III

2020-02-26 Thread Seb via Digitalmars-d-learn
On Thursday, 27 February 2020 at 00:36:49 UTC, kdevel wrote: ```test.d void main () { int [] v = new int [10]; } ``` $ [...]linux/bin32/dmd test $ gdb test [...] (gdb) r [...] Program received signal SIGILL, Illegal instruction. 0x0809ad14 in _D2gc4impl12conservativeQw3Gcx10smallAllocMFNbkKk