Dendro  5.01
Dendro in Greek language means tree. The Dendro library is a large scale (262K cores on ORNL's Titan) distributed memory adaptive octree framework. The main goal of Dendro is to perform large scale multiphysics simulations efficeiently in mordern supercomputers. Dendro consists of efficient parallel data structures and algorithms to perform variational ( finite element) methods and finite difference mthods on 2:1 balanced arbitary adaptive octrees which enables the users to perform simulations raning from black holes (binary black hole mergers) to blood flow in human body, where applications ranging from relativity, astrophysics to biomedical engineering.
radix.h
1 //
2 // Created by milinda on 5/26/16.
3 //
4 
5 #ifndef SFCSORTBENCH_RADIX_H
6 #define SFCSORTBENCH_RADIX_H
7 
8 // A utility function to get maximum value in arr[]
9 template <typename T>
10 inline T getMax(T* arr, int n)
11 {
12  T mx = arr[0];
13  for (unsigned int i = 1; i < n; i++)
14  if (arr[i] > mx)
15  mx = arr[i];
16  return mx;
17 }
18 
19 // A function to do counting sort of arr[] according to
20 // the digit represented by exp.
21 template <typename T>
22 inline void countSort(T* arr, int n, int exp)
23 {
24  unsigned int output[n]; // output array
25  unsigned int i, count[10] = {0};
26 
27  // Store count of occurrences in count[]
28  for (i = 0; i < n; i++)
29  count[ (arr[i]/exp)%10 ]++;
30 
31  // Change count[i] so that count[i] now contains actual
32  // position of this digit in output[]
33  for (i = 1; i < 10; i++)
34  count[i] += count[i - 1];
35 
36  // Build the output array
37  for (i = n - 1; i >= 0; i--)
38  {
39  output[count[ (arr[i]/exp)%10 ] - 1] = arr[i];
40  count[ (arr[i]/exp)%10 ]--;
41  }
42 
43  // Copy the output array to arr[], so that arr[] now
44  // contains sorted numbers according to current digit
45  for (i = 0; i < n; i++)
46  arr[i] = output[i];
47 }
48 
49 // The main function to that sorts arr[] of size n using
50 // Radix Sort
51 template <typename T>
52 void radixsort(T* arr, int n)
53 {
54  // Find the maximum number to know number of digits
55  T m = getMax(arr, n);
56 
57  // Do counting sort for every digit. Note that instead
58  // of passing digit number, exp is passed. exp is 10^i
59  // where i is current digit number
60  for (unsigned int exp = 1; m/exp > 0; exp *= 10)
61  countSort(arr, n, exp);
62 }
63 
64 
65 #endif //SFCSORTBENCH_RADIX_H