Re: Eh, bit faster sort

2016-09-26 Thread Nordlöw via Digitalmars-d
On Saturday, 24 September 2016 at 21:02:31 UTC, deadalnix wrote: Adding sorting network for small cases ? Feel free to integrate these: https://github.com/nordlow/phobos-next/blob/master/src/sortn.d :) Lengths 7 and 17 are missing. If you think this is a problem I can add them. If Andrei

Re: Eh, bit faster sort

2016-09-25 Thread Era Scarecrow via Digitalmars-d
On Saturday, 24 September 2016 at 22:11:19 UTC, Andrei Alexandrescu wrote: On 9/24/16 5:02 PM, deadalnix wrote: On Saturday, 24 September 2016 at 15:13:47 UTC, Andrei Alexandrescu wrote: https://github.com/dlang/phobos/pull/4816 Destroy! Adding sorting network for small cases ? That's kind

Re: Eh, bit faster sort

2016-09-24 Thread Andrei Alexandrescu via Digitalmars-d
On 9/24/16 5:02 PM, deadalnix wrote: On Saturday, 24 September 2016 at 15:13:47 UTC, Andrei Alexandrescu wrote: https://github.com/dlang/phobos/pull/4816 Destroy! Andrei Adding sorting network for small cases ? That's kind of what's happening. -- Andrei

Re: Eh, bit faster sort

2016-09-24 Thread deadalnix via Digitalmars-d
On Saturday, 24 September 2016 at 15:13:47 UTC, Andrei Alexandrescu wrote: https://github.com/dlang/phobos/pull/4816 Destroy! Andrei Adding sorting network for small cases ?

Re: Eh, bit faster sort

2016-09-24 Thread ZombineDev via Digitalmars-d
On Saturday, 24 September 2016 at 15:45:56 UTC, Andrei Alexandrescu wrote: On 09/24/2016 11:38 AM, Andrei Alexandrescu wrote: [...] https://issues.dlang.org/show_bug.cgi?id=16534 Andrei https://github.com/dlang/phobos/pull/4817

Re: Eh, bit faster sort

2016-09-24 Thread Andrei Alexandrescu via Digitalmars-d
On 09/24/2016 11:38 AM, Andrei Alexandrescu wrote: On 09/24/2016 11:13 AM, Andrei Alexandrescu wrote: https://github.com/dlang/phobos/pull/4816 Autotester fails with: std/algorithm/sorting.d(1314): Error: undefined identifier '__dollar' std/algorithm/sorting.d(1314): Error: undefined identifi

Re: Eh, bit faster sort

2016-09-24 Thread Andrei Alexandrescu via Digitalmars-d
On 09/24/2016 11:13 AM, Andrei Alexandrescu wrote: https://github.com/dlang/phobos/pull/4816 Autotester fails with: std/algorithm/sorting.d(1314): Error: undefined identifier '__dollar' std/algorithm/sorting.d(1314): Error: undefined identifier '__dollar' std/algorithm/sorting.d(1715): Error:

Eh, bit faster sort

2016-09-24 Thread Andrei Alexandrescu via Digitalmars-d
https://github.com/dlang/phobos/pull/4816 Destroy! Andrei

Re: Faster sort?

2016-04-07 Thread John Colvin via Digitalmars-d
On Thursday, 7 April 2016 at 09:25:46 UTC, John Colvin wrote: On Thursday, 7 April 2016 at 08:53:32 UTC, Andrea Fontana wrote: On Thursday, 7 April 2016 at 08:41:51 UTC, John Colvin wrote: *hench my example of compiling one module to an object file and then compiling the other and linking them,

Re: Faster sort?

2016-04-07 Thread John Colvin via Digitalmars-d
On Thursday, 7 April 2016 at 08:53:32 UTC, Andrea Fontana wrote: On Thursday, 7 April 2016 at 08:41:51 UTC, John Colvin wrote: *hench my example of compiling one module to an object file and then compiling the other and linking them, without ever importing one from the other. If i move boolSo

Re: Faster sort?

2016-04-07 Thread John Colvin via Digitalmars-d
On Thursday, 7 April 2016 at 09:01:14 UTC, tsbockman wrote: On Thursday, 7 April 2016 at 08:23:09 UTC, John Colvin wrote: But it definitely can eliminate an unused result. My prediction: you took an array and sorted it, then did nothing with the result, so it rightly concluded that there was no

Re: Faster sort?

2016-04-07 Thread Andrea Fontana via Digitalmars-d
On Thursday, 7 April 2016 at 08:48:41 UTC, tsbockman wrote: LDC 64-bit: boolSort(): 369 ms, 590 μs, and 6 hnsecs std sort(): 13 secs, 798 ms, 107 μs, and 8 hnsecs So, your boolSort() is faster as expected - but not infinitely so. Yes point of my original discussion wasn't the obviusly wr

Re: Faster sort?

2016-04-07 Thread tsbockman via Digitalmars-d
On Thursday, 7 April 2016 at 09:00:05 UTC, Andrea Fontana wrote: What about this? Duration total; foreach(_; 0..1) { auto arr = generate!( () => uniform(0,2)).map!(x => cast(bool)x).take(65536).array; StopWatch sw; sw.start; auto t = boolSort(arr); s

Re: Faster sort?

2016-04-07 Thread Andrea Fontana via Digitalmars-d
On Thursday, 7 April 2016 at 09:00:05 UTC, Andrea Fontana wrote: What about this? Duration total; foreach(_; 0..1) { auto arr = generate!( () => uniform(0,2)).map!(x => cast(bool)x).take(65536).array; StopWatch sw; sw.start; auto t = boolSort(arr); Misse

Re: Faster sort?

2016-04-07 Thread tsbockman via Digitalmars-d
On Thursday, 7 April 2016 at 08:23:09 UTC, John Colvin wrote: But it definitely can eliminate an unused result. My prediction: you took an array and sorted it, then did nothing with the result, so it rightly concluded that there was no point doing the sort. In any given case the compiler could

Re: Faster sort?

2016-04-07 Thread Andrea Fontana via Digitalmars-d
On Thursday, 7 April 2016 at 08:53:32 UTC, Andrea Fontana wrote: On Thursday, 7 April 2016 at 08:41:51 UTC, John Colvin wrote: *hench my example of compiling one module to an object file and then compiling the other and linking them, without ever importing one from the other. If i move boolSo

Re: Faster sort?

2016-04-07 Thread Andrea Fontana via Digitalmars-d
On Thursday, 7 April 2016 at 08:41:51 UTC, John Colvin wrote: *hench my example of compiling one module to an object file and then compiling the other and linking them, without ever importing one from the other. If i move boolSort() on another module but I can't use auto as return type. Retu

Re: Faster sort?

2016-04-07 Thread tsbockman via Digitalmars-d
On Thursday, 7 April 2016 at 07:57:11 UTC, Andrea Fontana wrote: I don't think compiler can remove a random generated array... I think times are too small to be measured with a good accuracy, using start() stop() to resume stopwatch seems to add a (fixed) overhead (some microsecs over the 1

Re: Faster sort?

2016-04-07 Thread John Colvin via Digitalmars-d
On Thursday, 7 April 2016 at 08:33:40 UTC, Andrea Fontana wrote: On Thursday, 7 April 2016 at 08:23:09 UTC, John Colvin wrote: But it definitely can eliminate an unused result. My prediction: you took an array and sorted it, then did nothing with the result, so it rightly concluded that there w

Re: Faster sort?

2016-04-07 Thread Andrea Fontana via Digitalmars-d
On Thursday, 7 April 2016 at 08:23:09 UTC, John Colvin wrote: But it definitely can eliminate an unused result. My prediction: you took an array and sorted it, then did nothing with the result, so it rightly concluded that there was no point doing the sort. In any given case the compiler could

Re: Faster sort?

2016-04-07 Thread John Colvin via Digitalmars-d
On Thursday, 7 April 2016 at 07:57:11 UTC, Andrea Fontana wrote: On Wednesday, 6 April 2016 at 18:54:08 UTC, tsbockman wrote: On Wednesday, 6 April 2016 at 08:15:39 UTC, Andrea Fontana wrote: Using ldmd2 -O -release -noboundscheck -inline sort.d && ./sort instead: 2 inputs: Faster: 0 hnsecs

Re: Faster sort?

2016-04-07 Thread Andrea Fontana via Digitalmars-d
On Wednesday, 6 April 2016 at 18:54:08 UTC, tsbockman wrote: On Wednesday, 6 April 2016 at 08:15:39 UTC, Andrea Fontana wrote: Using ldmd2 -O -release -noboundscheck -inline sort.d && ./sort instead: 2 inputs: Faster: 0 hnsecs Phobos: 33 μs and 5 hnsecs ... 65536 inputs: Faster: 0 hnsecs (??

Re: Faster sort?

2016-04-06 Thread tsbockman via Digitalmars-d
On Wednesday, 6 April 2016 at 08:15:39 UTC, Andrea Fontana wrote: Using ldmd2 -O -release -noboundscheck -inline sort.d && ./sort instead: 2 inputs: Faster: 0 hnsecs Phobos: 33 μs and 5 hnsecs ... 65536 inputs: Faster: 0 hnsecs (???) Phobos: 7 secs, 865 ms, 450 μs, and 6 hnsecs Can you shar

Faster sort?

2016-04-06 Thread Andrea Fontana via Digitalmars-d
I did a couple of tries using a "specialized" implementation of sort!less. For example using a counting sort for bool seems a good idea. This code: auto boolSort(alias less = "a return chain(repeat(test,count), repeat(!test, data.length - count)); } Count number of false (or true, it dep