Re: Is sorted using SIMD instructions

2018-04-12 Thread David Bennett via Digitalmars-d
On Thursday, 12 April 2018 at 10:14:55 UTC, rikki cattermole wrote: Just checked, change int to float and it uses ucomiss (SIMD, ldc -O3). There may not be an instruction for int's. Yep logic is much easier with floats and is available on SSE. It's hard to do logic on ints until SSE4.1 as

Re: Is sorted using SIMD instructions

2018-04-12 Thread rikki cattermole via Digitalmars-d
On 12/04/2018 7:25 PM, Per Nordlöw wrote: Neither GCC, LLVM nor ICC can auto-vectorize (and use SIMD) the seemly simple function bool is_sorted(const int32_t* input, size_t n) {     if (n < 2) {     return true;     }     for (size_t i=0; i < n - 1; i++) {     if (input[i] >

Re: Is sorted using SIMD instructions

2018-04-12 Thread Marco Leise via Digitalmars-d
Am Thu, 12 Apr 2018 09:37:58 + schrieb Stefan Koch : > On Thursday, 12 April 2018 at 07:25:27 UTC, Per Nordlöw wrote: > > Neither GCC, LLVM nor ICC can auto-vectorize (and use SIMD) the > > seemly simple function > > > > bool is_sorted(const int32_t* input,

Re: Is sorted using SIMD instructions

2018-04-12 Thread Stefan Koch via Digitalmars-d
On Thursday, 12 April 2018 at 07:25:27 UTC, Per Nordlöw wrote: Neither GCC, LLVM nor ICC can auto-vectorize (and use SIMD) the seemly simple function bool is_sorted(const int32_t* input, size_t n) { if (n < 2) { return true; } for (size_t i=0; i < n - 1; i++) { if

Is sorted using SIMD instructions

2018-04-12 Thread Per Nordlöw via Digitalmars-d
Neither GCC, LLVM nor ICC can auto-vectorize (and use SIMD) the seemly simple function bool is_sorted(const int32_t* input, size_t n) { if (n < 2) { return true; } for (size_t i=0; i < n - 1; i++) { if (input[i] > input[i + 1]) return false; }