/** * Sets the work sizes and arguments in one call and launches the kernel. * @param queue the command queue * @param globalWorkSize the global work size * @param workGroupSize the work group size * @param args the kernel arguments * @return an event object indicating when the kernel is finished */ public Event Run2(CommandQueue queue, WorkSize globalWorkSize, WorkSize workGroupSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSize(workGroupSize); setArgs(args); return Run(queue); }
/** * Sets the work sizes and arguments in one call and launches the kernel. * The generated event is directly released. Therefore, the performance * is better, but there is no way to detect when the kernel execution * has finished. For this purpose, use * {@link #Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) }. * @param queue the command queue * @param globalWorkSize the global work size * @param workGroupSize the work group size * @param args the kernel arguments */ public void Run2NoEvent(CommandQueue queue, WorkSize globalWorkSize, WorkSize workGroupSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSize(workGroupSize); setArgs(args); RunNoEvent(queue); }
@Override public String toString() { return "Kernel (" + getName() + ")"; }
/** * Sets the work sizes and arguments in one call and launches the kernel. * The global work size is set to the specified size. The work group * size is automatically determined by the driver. * Each object in the argument array is sent to the kernel by * {@link #setArg(int, java.lang.Object) }. * @param queue the command queue * @param globalWorkSize the global work size * @param args the kernel arguments * @return an event object indicating when the kernel is finished * @see #Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) */ public Event Run1(CommandQueue queue, WorkSize globalWorkSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSizeToNull(); setArgs(args); return Run(queue); }
/** * Sets the work sizes and arguments in one call and launches the kernel. * The global work size is set to the specified size. The work group * size is automatically determined by the driver. * Each object in the argument array is sent to the kernel by * {@link #setArg(int, java.lang.Object) }. * The generated event is directly released. Therefore, the performance * is better, but there is no way to detect when the kernel execution * has finished. For this purpose, use * {@link #Run1(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) }. * @param queue the command queue * @param globalWorkSize the global work size * @param args the kernel arguments * @see #Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) */ public void Run1NoEvent(CommandQueue queue, WorkSize globalWorkSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSizeToNull(); setArgs(args); RunNoEvent(queue); }
private void setArgs(Object... args) { for (int i = 0; i < args.length; ++i) { setArg(i, args[i]); } }
program.build(); Kernel kernel = program.createKernel("Fill"); System.out.println("number of args: "+kernel.getArgCount()); 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(); kernel.release(); program.release();
testMatrix3fKernel1.Run1NoEvent(clQueue, new Kernel.WorkSize(1), buffer); ByteBuffer bb = buffer.map(clQueue, MappingAccess.MAP_READ_ONLY); if (bb.get() == 0) { testMatrix3fKernel1.release(); 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) { testMatrix3fKernel2.release();
/** * Launches the kernel with the current global work size, work group size * and arguments without returning an event object. * The generated event is directly released. Therefore, the performance * is better, but there is no way to detect when the kernel execution * has finished. For this purpose, use {@link #Run(com.jme3.opencl.CommandQueue) }. * @param queue the command queue * @see #setGlobalWorkSize(com.jme3.opencl.Kernel.WorkSize) * @see #setWorkGroupSize(com.jme3.opencl.Kernel.WorkSize) * @see #setArg(int, java.lang.Object) */ public void RunNoEvent(CommandQueue queue) { //Default implementation, overwrite to not allocate the event object Run(queue).release(); }
private void updateOpenCL(float tpf) { //advect time time += tpf; //aquire resource buffer.acquireBufferForSharingNoEvent(clQueue); //no need to wait for the returned event, since the kernel implicitely waits for it (same command queue) //execute kernel float scale = (float) Math.pow(1.1, (1.0 - time%2) / 16.0); kernel.Run1NoEvent(clQueue, ws, buffer, scale); //release resource buffer.releaseBufferForSharingNoEvent(clQueue); }
/** * Sets the work sizes and arguments in one call and launches the kernel. * The global work size is set to the specified size. The work group * size is automatically determined by the driver. * Each object in the argument array is sent to the kernel by * {@link #setArg(int, java.lang.Object) }. * @param queue the command queue * @param globalWorkSize the global work size * @param args the kernel arguments * @return an event object indicating when the kernel is finished * @see #Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) */ public Event Run1(CommandQueue queue, WorkSize globalWorkSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSizeToNull(); setArgs(args); return Run(queue); }
/** * Sets the work sizes and arguments in one call and launches the kernel. * The global work size is set to the specified size. The work group * size is automatically determined by the driver. * Each object in the argument array is sent to the kernel by * {@link #setArg(int, java.lang.Object) }. * The generated event is directly released. Therefore, the performance * is better, but there is no way to detect when the kernel execution * has finished. For this purpose, use * {@link #Run1(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) }. * @param queue the command queue * @param globalWorkSize the global work size * @param args the kernel arguments * @see #Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) */ public void Run1NoEvent(CommandQueue queue, WorkSize globalWorkSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSizeToNull(); setArgs(args); RunNoEvent(queue); }
setArg(index, (byte) arg); } else if (arg instanceof Short) { setArg(index, (short) arg); } else if (arg instanceof Integer) { setArg(index, (int) arg); } else if (arg instanceof Long) { setArg(index, (long) arg); } else if (arg instanceof Float) { setArg(index, (float) arg); } else if (arg instanceof Double) { setArg(index, (double) arg); } else if (arg instanceof Vector2f) { setArg(index, (Vector2f) arg); } else if (arg instanceof Vector4f) { setArg(index, (Vector4f) arg); } else if (arg instanceof Quaternion) { setArg(index, (Quaternion) arg); } else if (arg instanceof Matrix3f) { setArg(index, (Matrix3f) arg); } else if (arg instanceof Matrix4f) { setArg(index, (Matrix4f) arg); } else if (arg instanceof LocalMemPerElement) { setArg(index, (LocalMemPerElement) arg); } else if (arg instanceof LocalMem) { setArg(index, (LocalMem) arg); } else if (arg instanceof Buffer) { setArg(index, (Buffer) arg); } else if (arg instanceof Image) { setArg(index, (Image) arg);
testBoolKernel.Run1NoEvent(clQueue, ws, seedsBuffer, resultBuffer); resultByteBuffer.rewind(); resultBuffer.read(clQueue, resultByteBuffer); testBoolKernel.release(); testIntKernel.Run1NoEvent(clQueue, ws, seedsBuffer, resultBuffer); resultByteBuffer.rewind(); resultBuffer.read(clQueue, resultByteBuffer); testIntKernel.release(); testIntNKernel.Run1NoEvent(clQueue, ws, seedsBuffer, 186, resultBuffer); resultByteBuffer.rewind(); resultBuffer.read(clQueue, resultByteBuffer); testIntNKernel.Run1NoEvent(clQueue, ws, seedsBuffer, 97357, resultBuffer); resultByteBuffer.rewind(); resultBuffer.read(clQueue, resultByteBuffer); testIntNKernel.release(); testLongKernel.Run1NoEvent(clQueue, ws, seedsBuffer, resultBuffer); resultByteBuffer.rewind(); resultBuffer.read(clQueue, resultByteBuffer); testLongKernel.release(); testFloatKernel.Run1NoEvent(clQueue, ws, seedsBuffer, resultBuffer);
/** * Launches the kernel with the current global work size, work group size * and arguments without returning an event object. * The generated event is directly released. Therefore, the performance * is better, but there is no way to detect when the kernel execution * has finished. For this purpose, use {@link #Run(com.jme3.opencl.CommandQueue) }. * @param queue the command queue * @see #setGlobalWorkSize(com.jme3.opencl.Kernel.WorkSize) * @see #setWorkGroupSize(com.jme3.opencl.Kernel.WorkSize) * @see #setArg(int, java.lang.Object) */ public void RunNoEvent(CommandQueue queue) { //Default implementation, overwrite to not allocate the event object Run(queue).release(); }
@Override public void simpleUpdate(float tpf) { //call kernel to test if it is still working if (!failed) { try { kernel.Run1NoEvent(clQueue, new Kernel.WorkSize(1), buffer, 1.0f); } catch (OpenCLException ex) { LOG.log(Level.SEVERE, "Kernel call not working anymore", ex); failed = true; statusText.setText("Failed"); } } } }
/** * Sets the work sizes and arguments in one call and launches the kernel. * @param queue the command queue * @param globalWorkSize the global work size * @param workGroupSize the work group size * @param args the kernel arguments * @return an event object indicating when the kernel is finished */ public Event Run2(CommandQueue queue, WorkSize globalWorkSize, WorkSize workGroupSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSize(workGroupSize); setArgs(args); return Run(queue); }
/** * Sets the work sizes and arguments in one call and launches the kernel. * The generated event is directly released. Therefore, the performance * is better, but there is no way to detect when the kernel execution * has finished. For this purpose, use * {@link #Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...) }. * @param queue the command queue * @param globalWorkSize the global work size * @param workGroupSize the work group size * @param args the kernel arguments */ public void Run2NoEvent(CommandQueue queue, WorkSize globalWorkSize, WorkSize workGroupSize, Object... args) { setGlobalWorkSize(globalWorkSize); setWorkGroupSize(workGroupSize); setArgs(args); RunNoEvent(queue); }
public void setArg(int index, Matrix3f mat) { TempVars vars = TempVars.get(); try { Matrix4f m = vars.tempMat4; m.zero(); for (int i=0; i<3; ++i) { for (int j=0; j<3; ++j) { m.set(i, j, mat.get(i, j)); } } setArg(index, m); } finally { vars.release(); } }
testMatrix4fKernel1.Run1NoEvent(clQueue, new Kernel.WorkSize(1), m1, buffer); ByteBuffer bb = buffer.map(clQueue, MappingAccess.MAP_READ_ONLY); if (bb.get() == 0) { testMatrix4fKernel1.release(); 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) { testMatrix4fKernel2.release();