Show HN: Fast(er) Sorting with Sorting Networks

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • SortingNetworks

  • > I can't read C#

    Not much different than C++...

    > Do you generate the sorting network at compile time

    No, except for power of two sizes up to 32. I experimented with run-time code generation (and compilation) for given sizes, but... the generated machine code has too long prologue and epilogue for that to be worth-while (though the sorting code itself is well optimized, as if directly compiled from source). That's also mentioned in "Benchmarks" section.

    > What's your sorting network template?

    See References.

    > And probably related: how is vectorization used?

    See the code. There's no template, the code is fully "dynamic" and adapts itself to array size. As for vectorization... it compares/swaps 8 ints/floats at once, with some swizzles to rearrange the elements. For sizes that are not power of 2, I use masked loads and stores and some extra logic for deciding which comparisons to skip. (I treat non-existing elements "as if" they were set to intmax or float infinity.)

    This file https://github.com/zvrba/SortingNetworks/blob/master/Sorting... has it all.

    > this week-end project

    Sorry, can't read Rust. (Though it reminds me of days spent coding in Perl.) Most networks are not SIMD-friendly and the code as it's now is the 3rd iteration where I figured out how to best leverage SIMD to exploit the recursiveness and regularity in the network. (Not the least, no random memory accesses: only forward and backward loads and stores.)

    Without SIMD, I don't think it'll be worth it, because network will also access the memory randomly (just as "standard" sort), and in addition it has worse algorithmic complexity.

  • static-sort

    compile-time sorting networks in rust

  • I can't read C# so i didn't look too long at your code and here are a couple questions:

    Do you generate the sorting network at compile time or is it on the fly (eg more of branchless sorting vs static network in machine code)? Being able to sort 1M elements hints to the second thing right? (i can't picture the size of the binary that has a sorting network for 1M elements)

    What's your sorting network template? And probably related: how is vectorization used? I guess you have some vector-optimized network template.. By template i mean some kind of function that takes a length and produces a sorting network for length-n-array.

    At some point i was learning about rust macros and came up with this week-end project: https://github.com/Lapin0t/static-sort. It's mainly a macro for transforming an array describing the swaps into code that does the swaps.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Uno: Create Beautiful Cross Platform .NET Apps Faster

    10 projects | news.ycombinator.com | 1 May 2024
  • voxel-engine alternatives - gvox_engine and octo-release

    3 projects | 2 May 2024
  • Oh Frick Go Back: GUI Tool to Removes Ads from Various Places Around Windows 11

    1 project | news.ycombinator.com | 2 May 2024
  • From Dull to Dazzling: 3 Methods to Elevate Your Writing with Visual Content

    3 projects | dev.to | 2 May 2024
  • How to create an Installer for a Winforms application using Wix for Visual Studio 2022

    1 project | dev.to | 2 May 2024