summaryrefslogtreecommitdiff
path: root/benchmarks/CUDA/MUM/morton.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/MUM/morton.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/MUM/morton.c')
-rw-r--r--benchmarks/CUDA/MUM/morton.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/benchmarks/CUDA/MUM/morton.c b/benchmarks/CUDA/MUM/morton.c
new file mode 100644
index 0000000..13599c6
--- /dev/null
+++ b/benchmarks/CUDA/MUM/morton.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+
+void morton(int i, int *x, int *y)
+{
+ *x = 0;
+ *y = 0;
+
+ int b;
+ for (b = 0; b < 16; b++)
+ {
+ *x |= (i & (1 << (b*2))) >> b;
+ *y |= (i & (1 << (b*2+1))) >> (b+1);
+ }
+}
+
+int main(int argc, char ** argv)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ int x;
+ int y;
+
+ morton(i,&x,&y);
+
+ printf("%d: %d %d\n", i, x, y);
+ }
+
+ return 0;
+}