radixSort | A GPU radix sorter using the OpenGL compute shader | GPU library

 by   guozhou C++ Version: Current License: No License

kandi X-RAY | radixSort Summary

kandi X-RAY | radixSort Summary

radixSort is a C++ library typically used in Hardware, GPU applications. radixSort has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

A GPU radix sorter using the OpenGL compute shader.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              radixSort has a low active ecosystem.
              It has 18 star(s) with 0 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              radixSort has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of radixSort is current.

            kandi-Quality Quality

              radixSort has 0 bugs and 0 code smells.

            kandi-Security Security

              radixSort has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              radixSort code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              radixSort does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              radixSort releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of radixSort
            Get all kandi verified functions for this library.

            radixSort Key Features

            No Key Features are available at this moment for radixSort.

            radixSort Examples and Code Snippets

            No Code Snippets are available at this moment for radixSort.

            Community Discussions

            QUESTION

            Radix sort get the right key to sort signed integers
            Asked 2022-Apr-03 at 10:14

            I have a trouble with finding a right value for sorting with radix sorting algorithm. I have implemented it right, but I have an issue with negatives. I tried just to reverse value with a binary. It helped me a little, but negatives are in ascending order instead of being in descending order. Funniest thing is that sorting works fine with floating points and signed integers.

            Here is my function to build a key for sorting:

            ...

            ANSWER

            Answered 2022-Apr-03 at 10:14

            Sort key formula that you need is very simple:

            Source https://stackoverflow.com/questions/71677501

            QUESTION

            Radix sort in descending order in c
            Asked 2022-Mar-10 at 21:06

            I don't know how to make this radix sort in descending order. Please can you help me to do that? Thank you in advance. I tried to calculate cumulative frequencies in reverse order. But I didn't succeed

            ...

            ANSWER

            Answered 2022-Mar-10 at 21:06

            You just need to reverse your offsetting loop in countingSort (where you adjust the 'count' values to calculate the correct spot in the output array to place the values with that digit):

            Source https://stackoverflow.com/questions/71430449

            QUESTION

            Tests fail when concatenating nested array in JavaScript
            Asked 2021-Sep-03 at 07:41

            Implemented a Radix Sort which sorts a list of numbers. Here is my code:

            ...

            ANSWER

            Answered 2021-Sep-03 at 06:49

            For the returned array it doesn't matter which of those alternatives you use, but if the tests expect you to sort the given array, so that after the call the input array has been sorted itself, then indeed, the commented-out alternatives will not work. This is because those alternatives assign to numbers instead of mutating it.

            Just check the difference between the alternatives when ignoring the returned array, but looking at the given array:

            Source https://stackoverflow.com/questions/69035840

            QUESTION

            Threaded radixsort not faster
            Asked 2021-Aug-26 at 12:38

            I´m having trouble understanding why my implementation is not faster than on a single thread.

            I´m trying to implement a bitwise MSB-radixsort(which is working for now) with a certain number (n) of threads. In my approach I create a new thread up until log2(n) within the recursion. But this seems to just increase the time cause of the creation of the thread. I`m guessing that the created threads can not work at the same time on the array, even with the splitted responsibility within it.

            If someone could explain it I would really appreciate it. Thanks!!

            UPDATE ::

            As it turns out I was missing the most obvious Solution as Ulrich commented. I was using a VM where it was locked to one CPU, which I did not know it did. After changing it I got the desired speedup for the radixsort.

            Thank you all for the comments and general info on that topic. ^^

            ...

            ANSWER

            Answered 2021-Aug-22 at 18:48

            The maximum number of threads should be limited to the number of cores on your system, or two times the number of cores if each core has hyper-threading. You've since updated your question to note that you only had one core using a virtual machine, and the multi-threaded version is faster with multiple cores.

            Other potential issues: if the distribution of the data is not uniform, then splitting into bins will result in uneven sized bins. Using a base larger than 2, such as 256, will reduce this effect somewhat. On the initial pass, there can be cache line conflicts, where each write to a cache line on one core will invalidate all instances of that cache line on other cores.

            Example code that uses a single thread to do a MSD first radix sort base 256, to create 256 bins, which are then sorted using LSD first radix sort, using 4 threads. This example uses Windows specific thread API. This relies on having reasonably uniform data so that the 256 bins are somewhat equal in size. I didn't try to use multi-threading for the initial MSD pass used to create the 256 bins, as one potential issue is cache line conflicts on the array of index updates, which would need an atomic increment operation, which may limit the performance benefit.

            Source https://stackoverflow.com/questions/68875534

            QUESTION

            NullPointerException: radixSort
            Asked 2021-Aug-09 at 12:20
            import java.lang.Math;
            
            
            
            
            public class radixSort{
                public static int getFreeSpace(Integer array[]){        //this function gets the first occurence of a null element in the array
                    int i;
                    for (i = 0; i < array.length;i++){
                        if (array[i] == null){
                            break;
                        }
                    }
                    return i;
                }
                public static Integer[] flatten(Integer array[][]){    //this function flattens the multi-dimensional lsdArray to a single dimension array
                    Integer finalArray[] = new Integer[1000];
                    for (int i = 0; i < array.length; i++){
                        Integer[] currentArray = array[i];
                        for (int j = 0; j < currentArray.length; j++){
                            if (array[i][j] != null){
                                int index = getFreeSpace(finalArray); 
                                finalArray[index] = currentArray[j];
                                                    
                            }
                            else;     
                                                     
                        }
            
                        
                        
                    }
                    return finalArray;
                }
                public static Integer getMaxDigits(Integer array[]){    //this function gets the largest number of digits in the array. this is helplful for getting the number of times the array is passed into the sort
                    Integer max = 0;
                    Integer m = 0;
                    for (int i = 0; i < array.length; i++){
                        m = Math.max(max, array[i]);
                    }
                    String s = m.toString();
                    return s.length();
                }
            
                public static Integer[] radixSortFunc(Integer array[],Integer maxDigits, Integer counter){ //the sorting algorithm
                    Integer[][] lsdArray = new Integer[10][15];
                    if (counter <= maxDigits){
                        
                        for (Integer i = 0; i < array.length; i++){
                            double temp = Math.pow(10,counter+1);
                            int powOfTen = (int) temp;
                            int term = (array[i] % powOfTen );
                            temp = Math.pow(10,counter);
                            powOfTen = (int) temp;
                            int digit = Math.floorDiv(term,powOfTen);
                                              
                            Integer[] currentArray = lsdArray[digit];
                            Integer index = getFreeSpace(currentArray);
                            currentArray[index] = array[i];
                            lsdArray[digit] = currentArray;
            
            
                            
                
                            }
                    
                        counter++;           
                        return radixSortFunc(flatten(lsdArray),maxDigits,counter);
                    }
                    else{
                        return array;
                    }
                    
            
                }
            
                public static void main(String[] args){
                    Integer[] array ={12,23,45,23,166};
                    Integer max = getMaxDigits(array);
                    Integer[] sortedArray = radixSortFunc(array,max,0);
                    for (Integer i = 0; i < sortedArray.length; i++){
                        if (sortedArray[i] != null){
                            System.out.println(sortedArray[i]);
                        }
                        else;
                        
                    }
                    
            
                }
            }
            
            ...

            ANSWER

            Answered 2021-Aug-09 at 12:20

            It's because you call

            return radixSortFunc(flatten(lsdArray),maxDigits,counter);

            after the first loop.

            lsdArray is an array almost full of null value (because you didn't initialize them in Integer[][] lsdArray = new Integer[10][15];).

            So, when you pass in int term = (array[i] % powOfTen ); with array[i] = null you get a NPE.

            By the way, you also have an issue with your getMaxDigits, it's not returning the maxlength element of your array.

            Source https://stackoverflow.com/questions/68711805

            QUESTION

            Problem with visualize second iteraration in radix sort
            Asked 2021-Jul-29 at 10:55

            I'm creating a Sorting Visualizer Project. Currently I'm working with a radix sort algorithm. I limited the height of my boxes (sorting items to help visualization) to a three-digit number. It means there are three iterations in radix sort (firstly we sort units place, then tens and hundreds). The problem arises when it comes to the second iteration. I console log the digit of the item in the current sorted array, and it matches its height, but the color may be completely different and have no idea why this is happening. Here is the code:

            ...

            ANSWER

            Answered 2021-Jul-29 at 10:55

            The problem was the color name. Instead of 'turqoise' it should've been 'turquoise'.

            Source https://stackoverflow.com/questions/68564977

            QUESTION

            Radix Sort on an array of BigInteger
            Asked 2021-Jun-08 at 20:27

            I am trying to sort a randomized array of type BigInteger using the radix sort algorithm. The algorithm I am trying to use is written below.

            ...

            ANSWER

            Answered 2021-Jun-08 at 20:27

            I've modified your code and added a driver code also:

            Source https://stackoverflow.com/questions/67892884

            QUESTION

            Parallel version of radix sort is not behaving as expected (Java)
            Asked 2021-Mar-27 at 22:13

            in my project I found that sorting performance is the bottleneck. After some googling I came up with parallel version of radix sort (with base 256). However it is not behaving as I expected.

            First changing the base to 2^16 doesn't cause any speedup and it should theoretically by 2.

            Second in my parallel version I split it to 4 parts (number of cores) and do radix sort on them, then I merge the result. Again it runs merely at the same time as serial version.

            ...

            ANSWER

            Answered 2021-Mar-25 at 22:10

            Using base 2^16 = 65536 ends up a bit slower because L1 cache is typically 32768 bytes per core, and base 2^16 counts|indexes arrays each use 2^20 = 262144 bytes.

            The issue with radix sort is that the reads are sequential, but the writes are as random as the data. Based on the comment, the program is sorting 20 million longs at 8 bytes each, so 80 MB of data, and assuming 8MB L3 cache, most of those writes are going to be cache misses. The parallel operations aren't helping much because most of the writes are competing for the same 80 MB of non-cached main memory.

            To avoid this issue, I used an alternate implementation where the first pass does a most significant digit radix sort to produce 256 bins (each bin contains integers with the same most significant byte). Then each bin is sorted using conventional radix sort least significant digit first. For reasonably uniform psuedo random data, the 256 bins end up nearly equal in size, so the 80MB is split into 256 bins, about 312500 bytes each, and for 4 threads, there are 8 of these bins, 4 for reads, 4 for writes, plus the count|index arrays, and all of this will fit into the 8MB L3 16 way associative L3 cache common to all 4 cores.

            For larger arrays, the initial pass could split up the array into 512 to 4096 or more bins.

            I did some testing with some old C++ code I have for radix sort for sorting pseudo random 64 bit integers, using base 2^8 = 256. I tested 3 implementations, single thread least significant digit, single thread most significant digit first, and quad thread most significant digit first. When the number of integers was a power of 2, it resulted in some cache conflicts, affecting the time in some cases.

            16000000 - 8 bins + index arrays fit in 8MB L3 cache.
            16777216 = 2^24, 8 bins + index arrays fit in 8MB L3 cache.
            30000000 - 8 bins + index arrays fit in 8MB L3 cache.
            33554432 = 2^25, 8 bins + index arrays a bit larger than 8MB
            36000000 - 8 bins + index arrays a bit larger than the 8MB.

            Source https://stackoverflow.com/questions/66789826

            QUESTION

            Radix sort incorrectly sorts an array of strings when they have different lengths
            Asked 2021-Feb-12 at 06:39

            So I'm currently attempting to sort a given array of strings in Java. I'm using radix sort to keep the time complexity at O(N+K). N is the length of the array and k is the length of all the characters. My intention was that the sorting algorithm should sort with numbers coming first in numeric order, and then alphabetically with any letters. So if the input array was {"cd", "12", "ab"}, the result of the sort would look like {"12", "ab", "cd"}. My issue comes in the form of handling strings of different lengths. To compensate for different lengths, I pre-processed the data by adding spaces to the end of each string to make every string the same length. However, in the actual sorting process, this causes the strings to be in the incorrect order. I've been debugging and I know the issue related to the sorting algorithm handling the artificial spaces. I use a hash map to determine the priority of all characters when it comes to the actual sorting. Not sure how to fix this. I tested it on an array of strings of the same length and it sorts correctly. So the issue is definitely with handling spaces. How do I fix it?

            ...

            ANSWER

            Answered 2021-Feb-12 at 06:39
            Issues

            The current code will not work for same length input too.

            Source https://stackoverflow.com/questions/66166266

            QUESTION

            Segmentation Fault While Sorting - Malloc
            Asked 2020-Dec-07 at 08:31

            I am reading a file of floating point numbers and then sorting them. When I use my following sort and swap functions with 1 million numbers, I am successfully able to sort the numbers. However, when I try to sort 100 million numbers, I get a segmentation fault. I am not sure why because I am dynamically allocating memory. How would I be able to handle more than 1 million numbers?

            ...

            ANSWER

            Answered 2020-Dec-07 at 08:31

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install radixSort

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/guozhou/radixSort.git

          • CLI

            gh repo clone guozhou/radixSort

          • sshUrl

            git@github.com:guozhou/radixSort.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link