summaryrefslogtreecommitdiff
path: root/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/METISLib/bucketsort.c
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2010-07-15 18:09:46 -0800
committerTor Aamodt <[email protected]>2010-07-15 18:09:46 -0800
commit69f2911e04ffb1b19eef1fafb8c040af271f656e (patch)
tree231d3b6bdc3a202f7c255bfcf7bf2c36e32cee9e /benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/METISLib/bucketsort.c
creating branch for adding support for CUDA 3.x and Fermi
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6829]
Diffstat (limited to 'benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/METISLib/bucketsort.c')
-rw-r--r--benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/METISLib/bucketsort.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/METISLib/bucketsort.c b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/METISLib/bucketsort.c
new file mode 100644
index 0000000..14aa213
--- /dev/null
+++ b/benchmarks/CUDA/DG/3rdParty/ParMetis-3.1/METISLib/bucketsort.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright 1997, Regents of the University of Minnesota
+ *
+ * bucketsort.c
+ *
+ * This file contains code that implement a variety of counting sorting
+ * algorithms
+ *
+ * Started 7/25/97
+ * George
+ *
+ * $Id: bucketsort.c,v 1.1 2003/07/16 15:55:00 karypis Exp $
+ *
+ */
+
+#include <metis.h>
+
+
+
+/*************************************************************************
+* This function uses simple counting sort to return a permutation array
+* corresponding to the sorted order. The keys are assumed to start from
+* 0 and they are positive. This sorting is used during matching.
+**************************************************************************/
+void BucketSortKeysInc(int n, int max, idxtype *keys, idxtype *tperm, idxtype *perm)
+{
+ int i, ii;
+ idxtype *counts;
+
+ counts = idxsmalloc(max+2, 0, "BucketSortKeysInc: counts");
+
+ for (i=0; i<n; i++)
+ counts[keys[i]]++;
+ MAKECSR(i, max+1, counts);
+
+ for (ii=0; ii<n; ii++) {
+ i = tperm[ii];
+ perm[counts[keys[i]]++] = i;
+ }
+
+ free(counts);
+}
+