diff options
author | Michael Bien <[email protected]> | 2010-04-12 22:03:38 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-04-12 22:03:38 +0200 |
commit | b51f2e1c254cdd74c9e43904c62694f64e6ae7e6 (patch) | |
tree | a1472b77f36c5bcf2e36a78e72c051c8ea91dfe5 /src/com/mbien/opencl | |
parent | a8c194e8d7b15580693e5c6db976290afb488e6b (diff) |
cleaned up benchmark, added queue.finish() and more iterations for better results.
Diffstat (limited to 'src/com/mbien/opencl')
-rw-r--r-- | src/com/mbien/opencl/demos/radixsort/RadixSortDemo.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/com/mbien/opencl/demos/radixsort/RadixSortDemo.java b/src/com/mbien/opencl/demos/radixsort/RadixSortDemo.java index a46eb22..93bc071 100644 --- a/src/com/mbien/opencl/demos/radixsort/RadixSortDemo.java +++ b/src/com/mbien/opencl/demos/radixsort/RadixSortDemo.java @@ -30,11 +30,14 @@ public class RadixSortDemo { context = CLContext.create(CLPlatform.getDefault().getMaxFlopsDevice(GPU)); CLCommandQueue queue = context.getDevices()[0].createCommandQueue(); - int maxValue = 10000000; + int maxValue = Integer.MAX_VALUE; + int samples = 10; int[] workgroupSizes = new int[] {128, 256}; - int[] runs = new int[] { 131072, + int[] runs = new int[] { 32768, + 65536, + 131072, 262144, 524288, 1048576, @@ -50,8 +53,9 @@ public class RadixSortDemo { for(int run = 0; run < runs.length; run++) { - if(workgroupSize==128 && run == runs.length-1) { - break; // we can only sort up to 4MB with wg size of 128 + if( workgroupSize==128 && runs[run] >= 8388608 + || workgroupSize==256 && runs[run] <= 32768) { + continue; // we can only sort up to 4MB with wg size of 128 } int numElements = runs[run]; @@ -63,15 +67,18 @@ public class RadixSortDemo { fillBuffer(array, maxValue); RadixSort radixSort = new RadixSort(queue, numElements, workgroupSize); - queue.finish(); + for(int a = 0; a < samples; a++) { - long time = currentTimeMillis(); + queue.finish(); + + long time = nanoTime(); queue.putWriteBuffer(array, false); radixSort.sort(array, numElements, 32); queue.putReadBuffer(array, true); - out.println("time: " + (currentTimeMillis() - time)+"ms"); + out.println("time: " + (nanoTime() - time)/1000000.0f+"ms"); + } out.print("snapshot: "); printSnapshot(array.getBuffer(), 20); @@ -84,7 +91,7 @@ public class RadixSortDemo { radixSort.release(); } } - + }finally{ if(context != null) { context.release(); |