diff options
author | Wade Walker <[email protected]> | 2014-02-22 14:28:40 -0600 |
---|---|---|
committer | Wade Walker <[email protected]> | 2014-02-22 14:28:40 -0600 |
commit | 52a618fa844fa19dce19e18c527991ef422b1c43 (patch) | |
tree | 8041fdb1356b09ec50c16d245f412fc382d2dc2b /test/com/jogamp/opencl/HighLevelBindingTest.java | |
parent | 0874fa955c0401dba9f54816a9654bb4380abed8 (diff) |
Fix memory problems in High/LowLevelBindingTests.
These tests now adaptively reduce the global work size until they
successfully allocate memory for their DirectByteBuffers. This
makes the tests work on JVMs where XX:MaxDirectMemorySize is
smaller than the modern defaults. These tests were failing on
OS X 10.6 for this reason.
Diffstat (limited to 'test/com/jogamp/opencl/HighLevelBindingTest.java')
-rw-r--r-- | test/com/jogamp/opencl/HighLevelBindingTest.java | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/test/com/jogamp/opencl/HighLevelBindingTest.java b/test/com/jogamp/opencl/HighLevelBindingTest.java index 6dd6a73f..a636e440 100644 --- a/test/com/jogamp/opencl/HighLevelBindingTest.java +++ b/test/com/jogamp/opencl/HighLevelBindingTest.java @@ -313,13 +313,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); |