Re: Playing SIMD

2015-10-28 Thread Marco Leise via Digitalmars-d
Am Mon, 26 Oct 2015 14:04:18 +0100 schrieb Iain Buclaw via Digitalmars-d : > > Yeah but PMOVMSKB not implemented in core.simd. > > > > Don't use core.simd, push for getting std.simd in, then leverage the > generics exposed through that module. Yeah, but PMOVMSKB is

Re: Playing SIMD

2015-10-28 Thread Andrei Alexandrescu via Digitalmars-d
On 10/28/2015 10:27 AM, Marco Leise wrote: Am Mon, 26 Oct 2015 14:04:18 +0100 schrieb Iain Buclaw via Digitalmars-d : Yeah but PMOVMSKB not implemented in core.simd. Don't use core.simd, push for getting std.simd in, then leverage the generics exposed through

Re: Playing SIMD

2015-10-26 Thread John Colvin via Digitalmars-d
On Monday, 26 October 2015 at 11:10:31 UTC, Iakh wrote: On Monday, 26 October 2015 at 09:49:00 UTC, Iakh wrote: On Monday, 26 October 2015 at 00:00:45 UTC, anonymous wrote: runBinary calls naiveIndexOf. You're not testing binaryIndexOf. You are right. This is fixed example:

Re: Playing SIMD

2015-10-26 Thread Andrei Alexandrescu via Digitalmars-d
On 10/26/2015 05:48 AM, Iakh wrote: On Monday, 26 October 2015 at 00:00:45 UTC, anonymous wrote: runBinary calls naiveIndexOf. You're not testing binaryIndexOf. You are right. This is fixed example: http://dpaste.dzfl.pl/f7a54b789a21 and results at dpaste.dzfl.pl: - SIMD:

Re: Playing SIMD

2015-10-26 Thread Iakh via Digitalmars-d
On Monday, 26 October 2015 at 09:49:00 UTC, Iakh wrote: On Monday, 26 October 2015 at 00:00:45 UTC, anonymous wrote: runBinary calls naiveIndexOf. You're not testing binaryIndexOf. You are right. This is fixed example: http://dpaste.dzfl.pl/f7a54b789a21 and results at dpaste.dzfl.pl: -

Re: Playing SIMD

2015-10-26 Thread Iakh via Digitalmars-d
On Monday, 26 October 2015 at 00:00:45 UTC, anonymous wrote: runBinary calls naiveIndexOf. You're not testing binaryIndexOf. You are right. This is fixed example: http://dpaste.dzfl.pl/f7a54b789a21 and results at dpaste.dzfl.pl: - SIMD: TickDuration(151000) Binary: TickDuration(255000)

Re: Playing SIMD

2015-10-26 Thread Iakh via Digitalmars-d
On Monday, 26 October 2015 at 12:35:39 UTC, Don wrote: You need to be very careful with doing benchmarks on tiny test cases, they can be very misleading. Can you advice some reading about benchmark?

Re: Playing SIMD

2015-10-26 Thread Kagamin via Digitalmars-d
On Monday, 26 October 2015 at 12:10:41 UTC, rumbu wrote: Interpolation search is even faster :) http://dpaste.dzfl.pl/4443c5753454 For a funny name it's called Newton search: you can use interpolation of higher order, can be more efficient if the data has a trend.

Re: Playing SIMD

2015-10-26 Thread Iakh via Digitalmars-d
On Monday, 26 October 2015 at 11:47:56 UTC, Andrei Alexandrescu wrote: On 10/26/2015 05:48 AM, Iakh wrote: On Monday, 26 October 2015 at 00:00:45 UTC, anonymous wrote: runBinary calls naiveIndexOf. You're not testing binaryIndexOf. You are right. This is fixed example:

Re: Playing SIMD

2015-10-26 Thread Iain Buclaw via Digitalmars-d
On 26 Oct 2015 1:40 pm, "Don via Digitalmars-d" wrote: > > On Sunday, 25 October 2015 at 19:37:32 UTC, Iakh wrote: >> >> Here is my implementatation of SIMD find. Function returns index of ubyte in static 16 byte array with unique values. > > > [snip] > > You need to

Re: Playing SIMD

2015-10-26 Thread rumbu via Digitalmars-d
On Monday, 26 October 2015 at 11:47:56 UTC, Andrei Alexandrescu wrote: On 10/26/2015 05:48 AM, Iakh wrote: On Monday, 26 October 2015 at 00:00:45 UTC, anonymous wrote: runBinary calls naiveIndexOf. You're not testing binaryIndexOf. You are right. This is fixed example:

Re: Playing SIMD

2015-10-26 Thread Iain Buclaw via Digitalmars-d
On 25 Oct 2015 11:50 pm, "Iakh via Digitalmars-d" < digitalmars-d@puremagic.com> wrote: > > On Sunday, 25 October 2015 at 22:17:58 UTC, Matthias Bentrup wrote: >> >> On Sunday, 25 October 2015 at 19:37:32 UTC, Iakh wrote: >>> >>> Is it optimal and how do you implement this stuf? >>> >> >> I think

Re: Playing SIMD

2015-10-26 Thread Don via Digitalmars-d
On Sunday, 25 October 2015 at 19:37:32 UTC, Iakh wrote: Here is my implementatation of SIMD find. Function returns index of ubyte in static 16 byte array with unique values. [snip] You need to be very careful with doing benchmarks on tiny test cases, they can be very misleading. Be aware

Re: Playing SIMD

2015-10-26 Thread Andrei Alexandrescu via Digitalmars-d
On 10/26/2015 08:35 AM, Don wrote: On Sunday, 25 October 2015 at 19:37:32 UTC, Iakh wrote: Here is my implementatation of SIMD find. Function returns index of ubyte in static 16 byte array with unique values. [snip] You need to be very careful with doing benchmarks on tiny test cases, they

Re: Playing SIMD

2015-10-26 Thread Iakh via Digitalmars-d
On Monday, 26 October 2015 at 15:03:12 UTC, Iakh wrote: (Binary)Searching in large sorted continuous array e. g. 1 MB of bytes 1 MB = 2 ^^ 20 bytes Imagine 4 binary levels pass in 4 ticks. So 20 levels in 20 ticks. With SIMD last 4 levels would be done in 2 or 3 ticks. For 20 levels 18 - 19

Re: Playing SIMD

2015-10-25 Thread Matthias Bentrup via Digitalmars-d
On Sunday, 25 October 2015 at 19:37:32 UTC, Iakh wrote: Is it optimal and how do you implement this stuf? I think it's better to use PMOVMSKB to avoid storing the PCMPEQB result in memory and you need only one BSF instruction.

Re: Playing SIMD

2015-10-25 Thread anonymous via Digitalmars-d
On 25.10.2015 20:37, Iakh wrote: Full exaple with comparation of algorithms (SIMD, naive, binary search): http://dpaste.dzfl.pl/f3b8989841e3 From there: void runBinary() { static int i = 0; naiveIndexOf(cast(ubyte)(i++/ArraySize + 1), arr); } runBinary calls naiveIndexOf. You're not

Re: Playing SIMD

2015-10-25 Thread Iakh via Digitalmars-d
On Sunday, 25 October 2015 at 22:17:58 UTC, Matthias Bentrup wrote: On Sunday, 25 October 2015 at 19:37:32 UTC, Iakh wrote: Is it optimal and how do you implement this stuf? I think it's better to use PMOVMSKB to avoid storing the PCMPEQB result in memory and you need only one BSF

Re: Playing SIMD

2015-10-25 Thread Andrei Alexandrescu via Digitalmars-d
On 10/25/15 6:57 PM, Iakh wrote: On Sunday, 25 October 2015 at 21:13:56 UTC, Andrei Alexandrescu wrote: [...] This is compelling but needs a bit of work to integrate. Care to work on a PR that makes std.algorithm use it? Thanks! -- Andrei First of all I need sort of investigation about PRs

Re: Playing SIMD

2015-10-25 Thread Iakh via Digitalmars-d
On Sunday, 25 October 2015 at 21:13:56 UTC, Andrei Alexandrescu wrote: [...] This is compelling but needs a bit of work to integrate. Care to work on a PR that makes std.algorithm use it? Thanks! -- Andrei First of all I need sort of investigation about PRs and std.algorithm. But in general

Re: Playing SIMD

2015-10-25 Thread Andrei Alexandrescu via Digitalmars-d
On 10/25/2015 03:37 PM, Iakh wrote: Here is my implementatation of SIMD find. Function returns index of ubyte in static 16 byte array with unique values. -- immutable size_t ArraySize = 16; int simdIndexOf(ubyte niddle, ref const ubyte[ArraySize] haystack) { ubyte16 arr; arr.array

Playing SIMD

2015-10-25 Thread Iakh via Digitalmars-d
Here is my implementatation of SIMD find. Function returns index of ubyte in static 16 byte array with unique values. -- immutable size_t ArraySize = 16; int simdIndexOf(ubyte niddle, ref const ubyte[ArraySize] haystack) { ubyte16 arr; arr.array = haystack[]; ubyte16 niddles;