Permalink
Browse files

bugfix: [CLWork codepath] local WS must be null if all elements are 0…

…. Using an empty buffer confuses the driver.
  • Loading branch information...
1 parent 4c8220f commit c967d61484154911245d213fe0820e2b2d2af549 Michael Bien committed Aug 30, 2011
Showing with 29 additions and 3 deletions.
  1. +10 −3 src/com/jogamp/opencl/CLCommandQueue.java
  2. +19 −0 test/com/jogamp/opencl/CLProgramTest.java
@@ -1631,23 +1631,30 @@ public CLCommandQueue putNDRangeKernel(CLKernel kernel, int workDimension, Nativ
* Calls {@native clEnqueueNDRangeKernel}.
*/
public CLCommandQueue putWork(CLWork work) {
- this.putNDRangeKernel(work.getKernel(), work.getDimension(), work.getWorkOffset(), work.getWorkSize(), work.getGroupSize(), null, null);
+ this.putWork(work, null, null);
return this;
}
/**
* Calls {@native clEnqueueNDRangeKernel}.
*/
public CLCommandQueue putWork(CLWork work, CLEventList events) {
- this.putNDRangeKernel(work.getKernel(), work.getDimension(), work.getWorkOffset(), work.getWorkSize(), work.getGroupSize(), null, events);
+ this.putWork(work, null, events);
return this;
}
/**
* Calls {@native clEnqueueNDRangeKernel}.
*/
public CLCommandQueue putWork(CLWork work, CLEventList condition, CLEventList events) {
- this.putNDRangeKernel(work.getKernel(), work.getDimension(), work.getWorkOffset(), work.getWorkSize(), work.getGroupSize(), condition, events);
+ NativeSizeBuffer groupSize = null;
+ if( work.getGroupSize().get(0) != 0
+ || work.dimension >= 2 && work.getGroupSize().get(1) != 0
+ || work.dimension == 3 && work.getGroupSize().get(2) != 0) {
+ groupSize = work.getGroupSize();
+ }
+
+ this.putNDRangeKernel(work.getKernel(), work.dimension, work.getWorkOffset(), work.getWorkSize(), groupSize, condition, events);
return this;
}
@@ -436,7 +436,11 @@ public void workTest() throws IOException {
CLWork1D work = CLWork.create1D(program.createCLKernel("add"));
work.getKernel().setArgs(buffer, 5, buffer.getNIOCapacity());
+
+ //optimal values
work.setWorkSize(20, 1).optimizeFor(device);
+ assertEquals(work.workSize.get(0), 20);
+ assertNotSame(work.groupSize.get(0), 0);
queue.putWriteBuffer(buffer, false)
.putWork(work)
@@ -445,6 +449,21 @@ public void workTest() throws IOException {
while(buffer.getBuffer().hasRemaining()) {
assertEquals(5, buffer.getBuffer().get());
}
+ buffer.getBuffer().rewind();
+
+ // driver choice
+ work.setWorkSize(20);
+ assertEquals(work.workSize.get(0), 20);
+ assertEquals(work.groupSize.get(0), 0);
+
+ queue.putWriteBuffer(buffer, false)
+ .putWork(work)
+ .putReadBuffer(buffer, true);
+
+ while(buffer.getBuffer().hasRemaining()) {
+ assertEquals(10, buffer.getBuffer().get());
+ }
+ buffer.getBuffer().rewind();
}finally{
context.release();

0 comments on commit c967d61

Please sign in to comment.