Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sorting networks for (already) partly sorted data #8

Closed
henkjan-sneller opened this issue Feb 21, 2023 · 4 comments
Closed

sorting networks for (already) partly sorted data #8

henkjan-sneller opened this issue Feb 21, 2023 · 4 comments

Comments

@henkjan-sneller
Copy link

I'm investigating the following: what is the impact on the number of layers when e.g. the first 32 elements of a total 48 elements are already sorted. I'm generating AVX512 assembly to sort floats in HPC context, and I'm considering to adopt this project to find such networks. But only if the number of layers is somewhat smaller.

Q: Have you ever seen such results? And would the method in SorterHunter be suitable to change to find such networks?

@henkjan-sneller
Copy link
Author

henkjan-sneller commented Feb 21, 2023

Never mind, I see that the FixedPrefix is used for precisely what I need!

@bertdobbelaere
Copy link
Owner

I tried your example using the config file attached. I found that with 48 inputs of which 32 are already sorted, 16 layers can be achieved (maybe with longer search time, 15 layers is feasible ? Best known for a full 48-sorter is 18 layers). Example solution pasted in the config file.
In the example the centered 32 inputs had to be sorted (so two outermost groups of 8 inputs are unrestricted), but these can be relocated if needed by a transformation.
48_henkjan.txt

@henkjan-sneller
Copy link
Author

Thank you, that helps a lot! I also tried something by plugging in an existing network (but used inputs 0..31), and I was analyzing the results. I'll look at your results next.

Small question: what tool do you use to print the end results. In your repo is (AFAICT) no code to separate the swaps into layers. Another project I tried has issues to do this (brianpursley/sorting-network#2)

@bertdobbelaere
Copy link
Owner

Indeed I did not commit auxiliary routines, I use a simple Python function for the layer separation (see attached). Should be easy to port to other languages. In essence, the network is scanned linearly. The layer number assigned to (both inputs of) an element is just one more than the highest layer number previously assigned to either input.
LinearToLayers.py.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants