Kernel.WorkSize ws = new Kernel.WorkSize(count);
@Override public Event Run(CommandQueue queue) { Utils.pointerBuffers[0].rewind(); Utils.pointerBuffers[1].rewind(); Utils.pointerBuffers[1].put(globalWorkSize.getSizes()); Utils.pointerBuffers[1].position(0); PointerBuffer p2 = null; if (workGroupSize.getSizes()[0] > 0) { p2 = Utils.pointerBuffers[2].rewind(); p2.put(workGroupSize.getSizes()); p2.position(0); } long q = ((LwjglCommandQueue) queue).getQueue(); int ret = CL10.clEnqueueNDRangeKernel(q, kernel, globalWorkSize.getDimension(), null, Utils.pointerBuffers[1], p2, null, Utils.pointerBuffers[0]); Utils.checkError(ret, "clEnqueueNDRangeKernel"); return new LwjglEvent(Utils.pointerBuffers[0].get(0)); } @Override
@Override public void RunNoEvent(CommandQueue queue) { Utils.pointerBuffers[1].rewind(); Utils.pointerBuffers[1].put(globalWorkSize.getSizes()); Utils.pointerBuffers[1].position(0); PointerBuffer p2 = null; if (workGroupSize.getSizes()[0] > 0) { p2 = Utils.pointerBuffers[2].rewind(); p2.put(workGroupSize.getSizes()); p2.position(0); } long q = ((LwjglCommandQueue) queue).getQueue(); int ret = CL10.clEnqueueNDRangeKernel(q, kernel, globalWorkSize.getDimension(), null, Utils.pointerBuffers[1], p2, null, null); Utils.checkError(ret, "clEnqueueNDRangeKernel"); }
/** * Sets the work group size to be a 1D grid * @param size the size to set */ public void setWorkGroupSize(int size) { workGroupSize.set(1, size); }
/** * Sets the work group size * @param ws the work group size to set */ public void setWorkGroupSize(WorkSize ws) { workGroupSize.set(ws); }
/** * Tells the driver to figure out the work group size on their own. * Use this if you do not rely on specific work group layouts, i.e. * because shared memory is not used. * {@link #Run1(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) } * implicitly calls this method. */ public void setWorkGroupSizeToNull() { workGroupSize.set(1, 0, 0, 0); }
/** * Sets the global work size to be a 3D grid * @param width the width * @param height the height * @param depth the depth */ public void setGlobalWorkSize(int width, int height, int depth) { globalWorkSize.set(3, width, height, depth); }
/** * Sets the global work size to a 1D grid * @param size the size in 1D */ public void setGlobalWorkSize(int size) { globalWorkSize.set(1, size); }
/** * Creates a new work size object * @param dimension the dimension (1,2,3) * @param sizes the sizes in each dimension, the length must match the specified dimension */ public WorkSize(int dimension, long... sizes) { super(); set(dimension, sizes); }
/** * Sets the global work size to be a 2D grid * @param width the width * @param height the height */ public void setGlobalWorkSize(int width, int height) { globalWorkSize.set(2, width, height); }
/** * Sets the work group size to be a 3D grid * @param width the width * @param height the height * @param depth the depth */ public void setWorkGroupSdize(int width, int height, int depth) { workGroupSize.set(3, width, height, depth); }
/** * Sets the work group size to be a 2D grid * @param width the width * @param height the height */ public void setWorkGroupSize(int width, int height) { workGroupSize.set(2, width, height); }
/** * Sets the global work size. * @param ws the work size to set */ public void setGlobalWorkSize(WorkSize ws) { globalWorkSize.set(ws); }
testMatrix4fKernel1.Run1NoEvent(clQueue, new Kernel.WorkSize(1), m1, buffer); ByteBuffer bb = buffer.map(clQueue, MappingAccess.MAP_READ_ONLY); if (bb.get() == 0) { testMatrix4fKernel2.Run1NoEvent(clQueue, new Kernel.WorkSize(1), m1, m1.determinant(), m1.transpose(), m1.adjoint(), buffer); bb = buffer.map(clQueue, MappingAccess.MAP_READ_ONLY); if (bb.get() == 0) {
testMatrix3fKernel1.Run1NoEvent(clQueue, new Kernel.WorkSize(1), buffer); ByteBuffer bb = buffer.map(clQueue, MappingAccess.MAP_READ_ONLY); if (bb.get() == 0) { Matrix3f m2 = new Matrix3f(-5.2f, 0.757f, 2.01f, 12.0f, -6, 2, 0.01f, 9, 2.255f); Matrix3f mRes = new Matrix3f(-31.68f, -165.703f, 1.51f, 12.468f, 62.4f, 86, -83.99f, 2.6f, -13.025f); testMatrix3fKernel2.Run1NoEvent(clQueue, new Kernel.WorkSize(1), m1, -2.0f, m2, mRes, buffer); bb = buffer.map(clQueue, MappingAccess.MAP_READ_ONLY); if (bb.get() == 0) {
Buffer buffer = clContext.createBuffer(size*4); float value = 5; Event event = kernel.Run1(clQueue, new com.jme3.opencl.Kernel.WorkSize(buffer.getSize() / 4), buffer, value); event.waitForFinished();
@Override public Event Run(CommandQueue queue) { Utils.pointerBuffers[0].rewind(); Utils.pointerBuffers[1].rewind(); Utils.pointerBuffers[1].put(globalWorkSize.getSizes()); Utils.pointerBuffers[1].position(0); PointerBuffer p2 = null; if (workGroupSize.getSizes()[0] > 0) { p2 = Utils.pointerBuffers[2].rewind(); p2.put(workGroupSize.getSizes()); p2.position(0); } CLCommandQueue q = ((LwjglCommandQueue) queue).getQueue(); int ret = CL10.clEnqueueNDRangeKernel(q, kernel, globalWorkSize.getDimension(), null, Utils.pointerBuffers[1], p2, null, Utils.pointerBuffers[0]); Utils.checkError(ret, "clEnqueueNDRangeKernel"); return new LwjglEvent(q.getCLEvent(Utils.pointerBuffers[0].get(0))); } @Override
@Override public Event Run(CommandQueue queue) { Utils.pointerBuffers[0].rewind(); Utils.pointerBuffers[1].rewind(); Utils.pointerBuffers[1].put(globalWorkSize.getSizes()); Utils.pointerBuffers[1].position(0); PointerBuffer p2 = null; if (workGroupSize.getSizes()[0] > 0) { p2 = Utils.pointerBuffers[2].rewind(); p2.put(workGroupSize.getSizes()); p2.position(0); } long q = ((LwjglCommandQueue) queue).getQueue(); int ret = CL10.clEnqueueNDRangeKernel(q, kernel, globalWorkSize.getDimension(), null, Utils.pointerBuffers[1], p2, null, Utils.pointerBuffers[0]); Utils.checkError(ret, "clEnqueueNDRangeKernel"); return new LwjglEvent(Utils.pointerBuffers[0].get(0)); } @Override