summaryrefslogtreecommitdiffstats
path: root/test/com/jogamp/opencl/HighLevelBindingTest.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-02-22 23:57:48 +0100
committerSven Gothel <[email protected]>2014-02-22 23:57:48 +0100
commitaf62da5b7ee3d99da7dc9364f1240fa7a8f5968e (patch)
tree7c52004f56c42ab03ab3f6e96e27933f482cb5cc /test/com/jogamp/opencl/HighLevelBindingTest.java
parente1af55978481d03561843c4a82c4995a4f3c858f (diff)
parent52a618fa844fa19dce19e18c527991ef422b1c43 (diff)
Merge remote-tracking branch 'wwalker/fix_jocl_bug_981_out_of_direct_buffer_memory'
Diffstat (limited to 'test/com/jogamp/opencl/HighLevelBindingTest.java')
-rw-r--r--test/com/jogamp/opencl/HighLevelBindingTest.java30
1 files changed, 23 insertions, 7 deletions
diff --git a/test/com/jogamp/opencl/HighLevelBindingTest.java b/test/com/jogamp/opencl/HighLevelBindingTest.java
index 40d2b9ed..7e056bed 100644
--- a/test/com/jogamp/opencl/HighLevelBindingTest.java
+++ b/test/com/jogamp/opencl/HighLevelBindingTest.java
@@ -314,13 +314,29 @@ public class HighLevelBindingTest extends UITestCase {
int elementCount = 11444777; // Length of float arrays to process (odd # for illustration)
int localWorkSize = device.getMaxWorkItemSizes()[0]; // set and log Global and Local work size dimensions
- int globalWorkSize = roundUp(localWorkSize, elementCount); // rounded up to the nearest multiple of the LocalWorkSize
-
- out.println("allocateing buffers of size: "+globalWorkSize);
-
- ByteBuffer srcA = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
- ByteBuffer srcB = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
- ByteBuffer dest = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
+ int globalWorkSize = 0;
+
+ ByteBuffer srcA = null;
+ ByteBuffer srcB = null;
+ ByteBuffer dest = null;
+ boolean allocated = false;
+ int divisor = 1;
+ while( !allocated ) {
+ try {
+ // round up to the nearest multiple of the LocalWorkSize
+ globalWorkSize = roundUp(localWorkSize, elementCount);
+ out.println("allocating three buffers of size: "+globalWorkSize);
+ srcA = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
+ srcB = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
+ dest = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
+ allocated = true;
+ }
+ catch( OutOfMemoryError oome ) {
+ ++divisor;
+ elementCount /= divisor;
+ out.println("not enough direct buffer memory; retrying with smaller buffers");
+ }
+ }
fillBuffer(srcA, 23456);
fillBuffer(srcB, 46987);