diff options
Diffstat (limited to 'src/com')
5 files changed, 21 insertions, 23 deletions
diff --git a/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java b/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java index aec01e2..e68acf3 100644 --- a/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java +++ b/src/com/mbien/opencl/demos/hellojocl/HelloJOCL.java @@ -10,7 +10,6 @@ import java.nio.FloatBuffer; import java.util.Random; import static java.lang.System.*; -import static com.sun.gluegen.runtime.BufferFactory.*; import static com.mbien.opencl.CLBuffer.Mem.*; /** @@ -23,7 +22,7 @@ import static com.mbien.opencl.CLBuffer.Mem.*; public class HelloJOCL { public static void main(String[] args) throws IOException { - + int elementCount = 11444777; // Length of arrays to process int localWorkSize = 256; // Local work size dimensions int globalWorkSize = roundUp(localWorkSize, elementCount); // rounded up to the nearest multiple of the localWorkSize @@ -58,7 +57,7 @@ public class HelloJOCL { long time = nanoTime(); queue.putWriteBuffer(clBufferA, false) .putWriteBuffer(clBufferB, false) - .putNDRangeKernel(kernel, 1, 0, globalWorkSize, localWorkSize) + .put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize) .putReadBuffer(clBufferC, true); time = nanoTime() - time; @@ -69,8 +68,8 @@ public class HelloJOCL { out.println("a+b=c results snapshot: "); for(int i = 0; i < 10; i++) out.print(clBufferC.buffer.get() + ", "); - out.println("...; " + clBufferC.buffer.remaining()/SIZEOF_FLOAT + " more"); - + out.println("...; " + clBufferC.buffer.remaining() + " more"); + out.println("computation took: "+(time/1000000)+"ms"); } @@ -91,4 +90,4 @@ public class HelloJOCL { } } -} +}
\ No newline at end of file diff --git a/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl b/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl index f9b4f32..e8023b1 100644 --- a/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl +++ b/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl @@ -12,4 +12,4 @@ // add the vector elements c[iGID] = a[iGID] + b[iGID]; - } + }
\ No newline at end of file diff --git a/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java b/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java index 769774c..4581643 100644 --- a/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java +++ b/src/com/mbien/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java @@ -34,7 +34,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { private final GLUgl2 glu = new GLUgl2(); private final int MESH_SIZE = 256; - + private int width; private int height; @@ -129,9 +129,9 @@ public class GLCLInteroperabilityDemo implements GLEventListener { gl.setSwapInterval(1); gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE); - + gl.glGenBuffers(glObjects.length, glObjects, 0); - + gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]); gl.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, ib.capacity() * SIZEOF_INT, ib, GL2.GL_STATIC_DRAW); gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0); @@ -141,7 +141,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { gl.glBufferData(GL2.GL_ARRAY_BUFFER, vb.capacity() * SIZEOF_FLOAT, vb, GL2.GL_DYNAMIC_DRAW); gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0); gl.glDisableClientState(GL2.GL_VERTEX_ARRAY); - + // OpenCL CLProgram program; try { @@ -151,7 +151,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { System.out.println(program.getBuildLog()); System.out.println(program.getBuildStatus()); } catch (IOException ex) { - throw new CLException("can not handle exception", ex); + throw new RuntimeException("can not handle exception", ex); } commandQueue = clContext.getMaxFlopsDevice().createCommandQueue(); @@ -172,7 +172,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); - + compute(gl); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); @@ -185,10 +185,10 @@ public class GLCLInteroperabilityDemo implements GLEventListener { gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]); gl.glVertexPointer(4, GL2.GL_FLOAT, 0, 0); -// gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]); -// gl.glDrawElements(GL2.GL_POINTS, ib.capacity(), GL2.GL_UNSIGNED_INT, 0); + gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, glObjects[INDICES]); + gl.glDrawElements(GL2.GL_TRIANGLES, ib.capacity(), GL2.GL_UNSIGNED_INT, 0); - gl.glDrawArrays(GL2.GL_POINTS, 0, vb.capacity()/4); +// gl.glDrawArrays(GL2.GL_POINTS, 0, vb.capacity()/4); gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0); @@ -255,7 +255,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { } public void dispose(GLAutoDrawable drawable) { } - + private void deinit() { clContext.release(); System.exit(0); @@ -265,4 +265,4 @@ public class GLCLInteroperabilityDemo implements GLEventListener { new GLCLInteroperabilityDemo(); } -} +}
\ No newline at end of file diff --git a/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl b/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl index cd92f14..5b42eca 100644 --- a/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl +++ b/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl @@ -21,4 +21,3 @@ __kernel void sineWave(__global float4 * vertex, int size, float time) { // write output vertex vertex[y*size + x] = (float4)(u*10.0f, w*10.0f, v*10.0f, 1.0f); } - diff --git a/src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java b/src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java index ab36f5e..bec2d28 100644 --- a/src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java +++ b/src/com/mbien/opencl/demos/joglinterop/UserSceneInteraction.java @@ -16,8 +16,8 @@ import javax.media.opengl.GL2; public class UserSceneInteraction { private float z = -20; - private float rotx; - private float roty; + private float rotx = 45; + private float roty = 30; private Point dragstart; private enum MOUSE_MODE { DRAG_ROTATE, DRAG_ZOOM } @@ -54,7 +54,7 @@ public class UserSceneInteraction { public void mouseWheelMoved(MouseWheelEvent e) { z += e.getWheelRotation()*5; } - + }); component.addMouseListener(new MouseAdapter() { @@ -100,4 +100,4 @@ public class UserSceneInteraction { } -} +}
\ No newline at end of file |