diff --git a/.gitignore b/.gitignore index b509eebe..8e0d5325 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ target project/boot project/target *~ -Tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d8bf3b6c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: java - -jdk: -- oraclejdk8 -- openjdk6 - -cache: - directories: - - $HOME/.m2 - -env: -- MAVEN_OPTS=-Xmx512m CL_LOG_ERRORS=stdout - -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq fglrx=2:8.960-0ubuntu1 opencl-headers diff --git a/Blas/.classpath b/Blas/.classpath deleted file mode 100644 index 3abb79c1..00000000 --- a/Blas/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/Blas/.project b/Blas/.project deleted file mode 100644 index 85ec62de..00000000 --- a/Blas/.project +++ /dev/null @@ -1,29 +0,0 @@ - - - Blas - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - org.eclipse.iam.jdt.core.mavenIncrementalBuilder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.iam.jdt.core.mavenNature - org.eclipse.jdt.core.javanature - - diff --git a/Blas/.settings/org.eclipse.jdt.core.prefs b/Blas/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0a83a729..00000000 --- a/Blas/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Thu Jan 28 23:48:19 CET 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Blas/.settings/org.maven.ide.eclipse.prefs b/Blas/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index a03b0328..00000000 --- a/Blas/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Thu Jan 28 23:46:13 CET 2010 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -includeModules=false -resolveWorkspaceProjects=true -resourceFilterGoals=process-resources resources\:testResources -skipCompilerPlugin=true -version=1 diff --git a/Blas/javacl-blas-bridj.iml b/Blas/javacl-blas-bridj.iml deleted file mode 100644 index 1a89a315..00000000 --- a/Blas/javacl-blas-bridj.iml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/Blas/javacl-blas.iml b/Blas/javacl-blas.iml deleted file mode 100644 index 2b7d843d..00000000 --- a/Blas/javacl-blas.iml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Blas/pom.xml b/Blas/pom.xml deleted file mode 100644 index 40eef44e..00000000 --- a/Blas/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - com.nativelibs4java - javacl-blas - JavaCL BLAS / BridJ - http://code.google.com/p/javacl/ - jar - - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - .. - - - - - - com.nativelibs4java - javacl - - - - org.ujmp - ujmp-core - 0.2.4 - - - - - - - - com.nativelibs4java - maven-javacl-plugin - - - - - - - nativelibs4java-legacy - NativeLibs4Java Legacy Repository - http://nativelibs4java.sourceforge.net/maven/ - - - - - - diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLDefaultMatrix2D.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLDefaultMatrix2D.java deleted file mode 100644 index 1f90ce31..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLDefaultMatrix2D.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.blas; - -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.util.Primitive; - -import org.bridj.Pointer; - -/** - * - * @author ochafik - */ -public class CLDefaultMatrix2D implements CLMatrix2D { - protected final Primitive primitive; - protected final Class primitiveClass; - protected final long rows, columns, stride, length; - protected final int blockSize; - - protected final CLKernels kernels; - protected final CLBuffer buffer; - protected final CLQueue queue; - protected final CLContext context; - protected CLEvents _events = new CLEvents(); - - public static final int DEFAULT_BLOCK_SIZE = 16; - - public CLDefaultMatrix2D(Primitive primitive, CLBuffer buffer, long rows, long columns, CLKernels kernels) { - this(primitive, buffer, rows, columns, DEFAULT_BLOCK_SIZE, kernels); - } - public CLDefaultMatrix2D(Primitive primitive, CLBuffer buffer, long rows, long columns, int blockSize, CLKernels kernels) { - this.primitive = primitive; - this.primitiveClass = (Class)primitive.primitiveType; - this.stride = CLMatrixUtils.roundUp(columns, blockSize); - this.length = this.stride * CLMatrixUtils.roundUp(rows, blockSize); - if (buffer != null) { - if (buffer.getElementCount() < this.length) { - throw new IllegalArgumentException("Buffer size too small; buffer of size " + this.length + " expected, size " + buffer.getByteCount() + " was given"); - } - this.buffer = buffer; - } else { - this.buffer = (CLBuffer)kernels.getContext().createBuffer(Usage.InputOutput, primitive.primitiveType, length); - } - this.kernels = kernels; - this.rows = rows; - this.columns = columns; - this.queue = kernels.getQueue(); - this.context = kernels.getContext(); - this.blockSize = blockSize; - - assert getBuffer().getElementCount() >= stride * rows && - getBuffer().getElementCount() <= stride * CLMatrixUtils.roundUp(rows, getBlockSize()); - } - - public CLMatrix2D blankClone() { - return blankMatrix(getRowCount(), getColumnCount()); - } - public CLMatrix2D blankMatrix(long rows, long columns) { - return new CLDefaultMatrix2D(primitive, null, rows, columns, blockSize, kernels); - } - - public long getRowCount() { - return rows; - } - - public long getColumnCount() { - return columns; - } - - public long getStride() { - return stride; - } - - public int getBlockSize() { - return blockSize; - } - - public CLEvents getEvents() { - return _events; - } - - public void write(final Pointer b) { - getEvents().performWrite(new CLEvents.Action() { - public CLEvent perform(CLEvent[] events) { - return buffer.write(queue, b, false, events); - } - }); - } - - public void read(final Pointer b) { - getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(CLEvent[] events) { - return buffer.read(queue, b, true, events); - } - }); - } - public Pointer read() { - Pointer out = Pointer.allocateArray(primitiveClass, length); - read(out); - return out; - } - - - public CLBuffer getBuffer() { - return buffer; - } - - public CLContext getContext() { - return context; - } - - public synchronized CLQueue getQueue() { - return queue; - } - - /* - public synchronized void setQueue(CLQueue queue) { - if (this.queue != null && queue != null) { - if (this.queue.equals(queue)) - return; - } - getEvents().waitFor(); - this.queue = queue; - } - * */ - - public Primitive getPrimitive() { - return primitive; - } - - public Class getPrimitiveClass() { - return primitiveClass; - } - - public CLKernels getKernels() { - return kernels; - } - -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLEvents.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLEvents.java deleted file mode 100644 index f78a714f..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLEvents.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.blas; - -import com.nativelibs4java.opencl.CLEvent; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author ochafik - */ -public class CLEvents { - CLEvent lastWriteEvent; - List readEvents = new ArrayList(); - - List listeners = new ArrayList(); - - public interface Listener { - void writing(CLEvents evts); - void reading(CLEvents evts); - } - public interface Action { - CLEvent perform(CLEvent[] events); - } - - public synchronized void addListener(Listener l) { - listeners.add(l); - } - public synchronized void removeListener(Listener l) { - listeners.remove(l); - } - static final CLEvent[] EMPTY_EVENTS = new CLEvent[0]; - protected synchronized CLEvent clearEvents(Action action) { - int nReads = readEvents.size(); - boolean hasWrite = lastWriteEvent != null; - int n = nReads + (hasWrite ? 1 : 0); - CLEvent[] evts = n == 0 ? EMPTY_EVENTS : readEvents.toArray(new CLEvent[n]); - if (hasWrite) - evts[nReads] = lastWriteEvent; - CLEvent evt = action.perform(evts); - lastWriteEvent = null; - readEvents.clear(); - return evt; - } - public synchronized CLEvent performRead(Action action) { - for (Listener listener : listeners) - listener.writing(this); - CLEvent evt = action.perform(lastWriteEvent == null ? EMPTY_EVENTS : new CLEvent[] { lastWriteEvent }); - if (evt != null) { - readEvents.add(evt); - lastWriteEvent = null; // read completed only if the optional write also completed - } - return evt; - } - - public synchronized void performRead(Runnable action) { - for (Listener listener : listeners) - listener.reading(this); - waitForRead(); - action.run(); - } - - public synchronized CLEvent performWrite(Action action) { - return lastWriteEvent = clearEvents(action); - } - - /** - * Wait until all write operations are completed so that the data is readable. - */ - public synchronized void waitForRead() { - CLEvent.waitFor(lastWriteEvent); - lastWriteEvent = null; - } - /** - * Wait for all associated operations to complete (read or write). - */ - public synchronized void waitFor() { - clearEvents(new Action() { - public CLEvent perform(CLEvent[] evts) { - CLEvent.waitFor(evts); - return null; - } - }); - } -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLKernels.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLKernels.java deleted file mode 100644 index 140f021f..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLKernels.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLBuildException; -import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLKernel; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; -import com.nativelibs4java.opencl.CLProgram; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.JavaCL; -import com.nativelibs4java.opencl.LocalSize; -import com.nativelibs4java.opencl.util.Fun1; -import com.nativelibs4java.opencl.util.Fun2; -import com.nativelibs4java.opencl.util.LinearAlgebraUtils; -import com.nativelibs4java.opencl.util.ParallelMath; -import com.nativelibs4java.opencl.util.Primitive; - -import static com.nativelibs4java.opencl.blas.CLMatrixUtils.roundUp; -import static org.bridj.Pointer.pointerToInt; - -/** - * - * @author ochafik - */ -public class CLKernels { - protected final LinearAlgebraUtils kernels; - protected final ParallelMath math; - protected final CLContext context; - protected final CLQueue queue; - - private static volatile CLKernels instance; - - public static synchronized void setInstance(CLKernels kernels) { - instance = kernels; - } - public static synchronized CLKernels getInstance() { - if (instance == null) { - try { - instance = new CLKernels(); - } catch (Throwable ex) { - throw new RuntimeException(ex); - } - } - return instance; - } - - public CLKernels() throws IOException, CLBuildException { - this( - JavaCL.createBestContext( - DeviceFeature.DoubleSupport, - DeviceFeature.MaxComputeUnits - ).createDefaultQueue() - ); - } - public CLKernels(CLQueue queue) throws IOException, CLBuildException { - kernels = new LinearAlgebraUtils(queue); - math = new ParallelMath(queue); - context = queue.getContext(); - this.queue = queue; - } - - public CLEvent op1(Primitive prim, Fun1 fun, CLBuffer a, long rows, long columns, long stride, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - long length = rows * stride; - if (out == null || out.getElementCount() < length) - throw new IllegalArgumentException("Expected buffer of length >= " + length + ", got " + out); - //if (out != null) - // out = (CLBuffer)context.createBuffer(Usage.Output, prim.primitiveType, length); - - CLKernel kernel = math.getKernel(fun, prim); - synchronized (kernel) { - kernel.setArgs(a, out, length); - CLEvent evt = kernel.enqueueNDRange(queue, new int [] { (int)length }, eventsToWaitFor); - return evt; - } - } - - public CLEvent op2(Primitive prim, Fun2 fun, CLBuffer a, CLBuffer b, long rows, long columns, long stride, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - long length = rows * stride; - if (out == null || out.getElementCount() < length) - throw new IllegalArgumentException("Expected buffer of length >= " + length + ", got " + out.getElementCount()); - //if (out != null) - // out = (CLBuffer)context.createBuffer(Usage.Output, prim.primitiveType, length); - - CLKernel kernel = math.getKernel(fun, prim, false); - synchronized (kernel) { - kernel.setArgs(a, b, out, length); - CLEvent evt = kernel.enqueueNDRange(queue, new int [] { (int)length }, eventsToWaitFor); - return evt; - } - } - - public CLEvent op2(Primitive prim, Fun2 fun, CLBuffer a, T b, long rows, long columns, long stride, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - long length = rows * stride; - if (out == null || out.getElementCount() < length) - throw new IllegalArgumentException("Expected buffer of length >= " + length + ", got " + out.getElementCount()); - //if (out != null) - // out = (CLBuffer)context.createBuffer(Usage.Output, prim.primitiveType, length); - - CLKernel kernel = math.getKernel(fun, prim, true); - synchronized (kernel) { - kernel.setArgs(a, b, out, length); - CLEvent evt = kernel.enqueueNDRange(queue, new int [] { (int)length }, eventsToWaitFor); - return evt; - } - } - - Map containsValueKernels = new HashMap(); - public boolean containsValue(Primitive primitive, CLBuffer buffer, long length, V value, CLEvent... eventsToWaitFor) throws CLBuildException { - CLKernel kernel; - synchronized (containsValueKernels) { - kernel = containsValueKernels.get(primitive); - if (kernel == null) { - kernel = context.createProgram(( - primitive.getRequiredPragmas() + - "__kernel void containsValue( \n" + - " __global const double* a, \n" + - " int length, \n" + - " double value, \n" + - " __global int* pOut \n" + - ") { \n" + - " int i = get_global_id(0);\n" + - " if (i >= length) \n" + - " return; \n" + - " \n" + - " if (a[i] == value) \n" + - " *pOut = 1; \n" + - "} \n" - ).replaceAll("double", primitive.clTypeName())).createKernel("containsValue"); - containsValueKernels.put(primitive, kernel); - } - } - synchronized(kernel) { - CLBuffer pOut = context.createBuffer(Usage.Output, pointerToInt(0)); - kernel.setArgs(buffer, (int)length, value, pOut); - kernel.enqueueNDRange(queue, new int[] { (int)length }, eventsToWaitFor).waitFor(); - return pOut.read(queue).getInt() != 0; - } - } - - Map clearKernels = new HashMap(); - public CLEvent clear(Primitive primitive, CLBuffer buffer, long length, CLEvent... eventsToWaitFor) throws CLBuildException { - CLKernel kernel; - synchronized (clearKernels) { - kernel = clearKernels.get(primitive); - if (kernel == null) { - kernel = context.createProgram(( - primitive.getRequiredPragmas() + - "__kernel void clear_buffer( \n" + - " __global double* a, \n" + - " int length \n" + - ") { \n" + - " int i = get_global_id(0); \n" + - " if (i >= length) \n" + - " return; \n" + - " \n" + - " a[i] = (double)0; \n" + - "} \n" - ).replaceAll("double", primitive.clTypeName())).createKernel("clear_buffer"); - clearKernels.put(primitive, kernel); - } - } - synchronized(kernel) { - kernel.setArgs(buffer, (int)length); - CLEvent evt = kernel.enqueueNDRange(queue, new int[] { (int)length }, eventsToWaitFor); - //Object array = buffer.read(queue, evt).getArray(); - return evt; - } - } - - Map matrixMultiplyKernels = new HashMap(); - public CLEvent matrixMultiply(Primitive prim, - CLBuffer a, long aRows, long aColumns, long aStride, int aBlockSize, - CLBuffer b, long bRows, long bColumns, long bStride, int bBlockSize, - CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - boolean useBlocks = false; - int blockSize = aBlockSize; - if (blockSize > 1 && blockSize == bBlockSize) { - long[] maxWorkItemSizes = queue.getDevice().getMaxWorkItemSizes(); - useBlocks = maxWorkItemSizes.length >= 2 && - maxWorkItemSizes[0] >= blockSize && - maxWorkItemSizes[1] >= blockSize; - } - if (useBlocks) { - return blockMatrixMultiply( - blockSize, prim, - a, roundUp(aRows, blockSize), roundUp(aColumns, blockSize), - b, roundUp(bRows, blockSize), roundUp(bColumns, blockSize), - out, eventsToWaitFor); - } else { - return naiveMatrixMultiply(prim, a, aRows, aColumns, aStride, b, bRows, bColumns, bStride, out, eventsToWaitFor); - } - } - public CLEvent blockMatrixMultiply(int blockSize, Primitive prim, CLBuffer a, long aRows, long aColumns, CLBuffer b, long bRows, long bColumns, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - if (out == null) - throw new IllegalArgumentException("Null output matrix !"); - //if (out != null) - // out = (CLBuffer)context.createBuffer(Usage.Output, prim.primitiveType, aRows * bColumns); - - CLKernel kernel; - String key = "block_" + blockSize + "_" + prim; - synchronized (matrixMultiplyKernels) { - kernel = matrixMultiplyKernels.get(key); - if (kernel == null) { - String src = prim.getRequiredPragmas() + - "#define BLOCK_SIZE " + blockSize + "\n" + - "#define AS(i, j) As[j + i * BLOCK_SIZE]\n" + - "#define BS(i, j) Bs[j + i * BLOCK_SIZE]\n" + - "\n" + - "__kernel void mulMat( " + - " __global const double* A, int aColumns, " + - " __global const double* B, int bColumns, " + - " __global double* C, " + - " __local double* As, " + - " __local double* Bs " + - ") { " + - " // Block index\n" + - " int bx = get_group_id(0);\n" + - " int by = get_group_id(1);\n" + - "\n" + - " // Thread index\n" + - " int tx = get_local_id(0);\n" + - " int ty = get_local_id(1);\n" + - "\n" + - " // Index of the first sub-matrix of A processed by the block\n" + - " int aBegin = aColumns * BLOCK_SIZE * by + aColumns * ty + tx;\n" + - "\n" + - " // Index of the last sub-matrix of A processed by the block\n" + - " int aEnd = aBegin + aColumns;\n" + - "\n" + - " // Step size used to iterate through the sub-matrices of A\n" + - " int aStep = BLOCK_SIZE;\n" + - "\n" + - " // Index of the first sub-matrix of B processed by the block\n" + - " int bBegin = BLOCK_SIZE * bx + bColumns * ty + tx;\n" + - "\n" + - " // Step size used to iterate through the sub-matrices of B\n" + - " int bStep = BLOCK_SIZE * bColumns;\n" + - "\n" + - " // total is used to store the element of the block sub-matrix\n" + - " // that is computed by the thread\n" + - " float total = 0.0f;\n" + - "\n" + - " // Loop over all the sub-matrices of A and B\n" + - " // required to compute the block sub-matrix\n" + - " for (int a = aBegin, b = bBegin;\n" + - " a < aEnd;\n" + - " a += aStep, b += bStep) {\n" + - "\n" + - " // Load the matrices from device memory\n" + - " // to shared memory; each thread loads\n" + - " // one element of each matrix\n" + - " AS(ty, tx) = A[a];\n" + - " BS(ty, tx) = B[b];\n" + - "\t\n" + - " // Synchronize to make sure the matrices are loaded\n" + - " barrier(CLK_LOCAL_MEM_FENCE);\n" + - "\n" + - " // Multiply the two matrices together;\n" + - " // each thread computes one element\n" + - " // of the block sub-matrix \n" + - " #pragma unroll\n" + - " for (int k = 0; k < BLOCK_SIZE; ++k)\n" + - " total += AS(ty, k) * BS(k, tx);\n" + - "\n" + - " // Synchronize to make sure that the preceding\n" + - " // computation is done before loading two new\n" + - " // sub-matrices of A and B in the next iteration\n" + - " barrier(CLK_LOCAL_MEM_FENCE);\n" + - " }\n" + - "\n" + - " C[get_global_id(1) * get_global_size(0) + get_global_id(0)] = total;\n" + - "} " - ; - String clTypeName = prim.clTypeName(); - src = src.replaceAll("double", clTypeName); - kernel = context.createProgram(src).createKernel("mulMat"); - matrixMultiplyKernels.put(key, kernel); - } - } - synchronized (kernel) { - kernel.setArgs(a, (int) aColumns, b, (int) bColumns, out, - LocalSize.ofFloatArray(blockSize * blockSize), - LocalSize.ofFloatArray(blockSize * blockSize)); - CLEvent evt = kernel.enqueueNDRange(queue, - new int[]{(int) aRows, (int) bColumns}, - new int[]{blockSize, blockSize}, - eventsToWaitFor); - return evt; - } - } - - public CLEvent naiveMatrixMultiply(Primitive prim, - CLBuffer a, long aRows, long aColumns, long aStride, - CLBuffer b, long bRows, long bColumns, long bStride, - CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - if (out == null) - throw new IllegalArgumentException("Null output matrix !"); - //if (out != null) - // out = (CLBuffer)context.createBuffer(Usage.Output, prim.primitiveType, aRows * bColumns); - - CLKernel kernel; - String key = "naive_" + prim; - synchronized (matrixMultiplyKernels) { - kernel = matrixMultiplyKernels.get(key); - if (kernel == null) { - String src = prim.getRequiredPragmas() + - "__kernel void mulMat( " + - " __global const double* a, int aRows, int aColumns, int aStride, " + - " __global const double* b, int bColumns, int bStride, " + - " __global double* c " + - ") { " + - " int i = get_global_id(0); " + - " int j = get_global_id(1); " + - " " + - " if (i >= aRows || j >= bColumns) return; " + - " double total = 0; " + - " size_t iOff = i * (size_t)aStride; " + - " for (long k = 0; k < aColumns; k++) { " + - " total += a[iOff + k] * b[k * (size_t)bStride + j]; " + - " } " + - " c[i * (size_t)bStride + j] = total; " + - "} " - ; - String clTypeName = prim.clTypeName(); - src = src.replaceAll("double", clTypeName); - kernel = context.createProgram(src).createKernel("mulMat"); - matrixMultiplyKernels.put(key, kernel); - } - } - synchronized (kernel) { - // assert aStride == aColumns: ("Weird a stride: aStride = " + aStride + ", aColumns = " + aColumns); - // assert bStride == bColumns: ("Weird b stride: bStride = " + bStride + ", bColumns = " + bColumns); - kernel.setArgs(a, (int)aRows, (int)aColumns, (int)aStride, b, (int)bColumns, (int)bStride, out); - CLEvent evt = kernel.enqueueNDRange(queue, new int [] { (int)aRows, (int)bColumns }, eventsToWaitFor); - return evt; - } - } - - Map matrixTransposeKernels = new HashMap(); - public CLEvent matrixTranspose(Primitive prim, CLBuffer a, long aRows, long aColumns, long aStride, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - if (out == null) - throw new IllegalArgumentException("Null output matrix !"); - //if (out != null) - // out = (CLBuffer)context.createBuffer(Usage.Output, prim.primitiveType, aRows * aColumns); - - CLKernel[] kernels; - synchronized (matrixTransposeKernels) { - kernels = matrixTransposeKernels.get(prim); - if (kernels == null) { - String src = - prim.getRequiredPragmas() + - "__kernel void transposeSelf( \n" + - " __global double* a, int aRows, int aColumns, int aStride \n" + - ") { \n" + - " int i = get_global_id(0); \n" + - " int j = get_global_id(1); \n" + - " \n" + - " if (i >= aRows || j >= aColumns || j >= i) return; \n" + - " \n" + - " size_t aIndex = i * aStride + j; \n" + - " size_t outIndex = j * aRows + i; \n" + - " double temp = a[outIndex]; \n" + - " a[outIndex] = a[aIndex]; \n" + - " a[aIndex] = temp; \n" + - "} \n" + - "__kernel void transposeOther( \n" + - " __global const double* a, int aRows, int aColumns, int aStride, \n" + - " __global double* out \n" + - ") { \n" + - " int i = get_global_id(0); \n" + - " int j = get_global_id(1); \n" + - " \n" + - " if (i >= aRows || j >= aColumns) return; \n" + - " \n" + - " size_t aIndex = i * aStride + j; \n" + - " size_t outIndex = j * aRows + i; \n" + - " out[outIndex] = a[aIndex]; \n" + - "} \n" - ; - String clTypeName = prim.clTypeName(); - src = src.replaceAll("double", clTypeName); - CLProgram program = context.createProgram(src); - kernels = new CLKernel[] { program.createKernel("transposeSelf"), program.createKernel("transposeOther") }; - matrixTransposeKernels.put(prim, kernels); - } - } - boolean self = a.equals(out); - CLKernel kernel = kernels[self ? 0 : 1]; - synchronized (kernel) { - if (self) - kernel.setArgs(a, (int)aRows, (int)aColumns, (int)aStride); - else - kernel.setArgs(a, (int)aRows, (int)aColumns, (int)aStride, out); - - CLEvent evt = kernel.enqueueNDRange(queue, new int [] { (int)aRows, (int)aColumns }, eventsToWaitFor); - return evt; - } - } - - public CLContext getContext() { - return context; - } - - public CLQueue getQueue() { - return queue; - } - -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLMatrix2D.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLMatrix2D.java deleted file mode 100644 index e1ae8ec6..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLMatrix2D.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.blas; - -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.util.Primitive; -import org.bridj.Pointer; - -/** - * - * @author ochafik - */ -public interface CLMatrix2D { - - Primitive getPrimitive(); - Class getPrimitiveClass(); - CLEvents getEvents(); - CLBuffer getBuffer(); - CLContext getContext(); - CLQueue getQueue(); - long getRowCount(); - long getColumnCount(); - long getStride(); - int getBlockSize(); - CLMatrix2D blankClone(); - CLMatrix2D blankMatrix(long rows, long columns); - CLKernels getKernels(); - - void write(Pointer b); - void read(Pointer b); - Pointer read(); -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLMatrixUtils.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLMatrixUtils.java deleted file mode 100644 index 1a4d79b5..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/CLMatrixUtils.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.blas; - -import com.nativelibs4java.opencl.CLBuildException; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.util.Fun1; -import com.nativelibs4java.opencl.util.Fun2; -import com.nativelibs4java.opencl.util.Primitive; -import com.nativelibs4java.opencl.util.ReductionUtils.Reductor; - -/** - * - * @author ochafik - */ -public class CLMatrixUtils { - - static CLEvent[] join(CLEvent[]... evts) { - int n = 0; - for (CLEvent[] e : evts) - n += e.length; - CLEvent[] out = new CLEvent[n]; - n = 0; - for (CLEvent[] e : evts) - System.arraycopy(e, 0, out, n, e.length); - - return out; - } - - public static long roundUp(long size, int blockSize) { - return ((size + blockSize - 1) / blockSize) * blockSize; - } - - public static void matrixMultiply( - final CLMatrix2D a, - final CLMatrix2D b, - final CLMatrix2D out) - throws CLBuildException - { - final CLKernels kernels = a.getKernels(); - final Primitive primitive = a.getPrimitive(); - a.getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] aevents) { - return b.getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] bevents) { - return out.getEvents().performWrite(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] cevents) { - CLEvent evt = kernels.matrixMultiply( - primitive, - a.getBuffer(), a.getRowCount(), a.getColumnCount(), a.getStride(), a.getBlockSize(), - b.getBuffer(), b.getRowCount(), b.getColumnCount(), b.getStride(), b.getBlockSize(), - out.getBuffer(), - join(aevents, bevents, cevents) - ); - return evt; - } - }); - } - }); - } - }); - } - - static final int MAX_REDUCTION_SIZE = 32; - - public static void reduce( - final CLMatrix2D in, - final CLMatrix2D out, - final Reductor reductor - ) { - in.getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] ievents) { - return out.getEvents().performWrite(new CLEvents.Action() { - public CLEvent perform(CLEvent[] oevents) { - return reductor.reduce(in.getQueue(), in.getBuffer(), in.getBuffer().getElementCount(), out.getBuffer(), MAX_REDUCTION_SIZE, join(ievents, oevents)); - } - }); - } - }); - } - public static void matrixTranspose( - final CLMatrix2D a, - final CLMatrix2D out) - throws CLBuildException - { - final Primitive primitive = a.getPrimitive(); - final CLKernels kernels = a.getKernels(); - a.getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] aevents) { - return out.getEvents().performWrite(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] cevents) { - CLEvent evt = kernels.matrixTranspose( - primitive, - a.getBuffer(), - a.getRowCount(), a.getColumnCount(), a.getStride(), - out.getBuffer(), - join(aevents, cevents) - ); - return evt; - } - }); - } - }); - } - - public static CLMatrix2D clone(final CLMatrix2D matrix) { - final CLMatrix2D out = matrix.blankClone(); - matrix.getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] aevents) { - return out.getEvents().performWrite(new CLEvents.Action() { - public CLEvent perform(CLEvent[] bevents) { - return matrix.getBuffer().copyTo(matrix.getQueue(), out.getBuffer(), CLMatrixUtils.join(aevents, bevents)); - } - }); - } - }); - return out; - } - - - public static CLMatrix2D createMatrix(long rows, long columns, Class elementClass, CLKernels kernels) { - if (elementClass == Double.class) - return (CLMatrix2D)new CLDefaultMatrix2D(Primitive.Double, null, rows, columns, kernels); - - throw new UnsupportedOperationException("Cannot build buffers of " + elementClass.getName() + " yet"); - } - - - public static CLMatrix2D op1(final CLMatrix2D in, final Fun1 fun, final CLMatrix2D out) throws CLBuildException { - in.getEvents().performRead(new CLEvents.Action() { - - public CLEvent perform(final CLEvent[] ievents) { - return out.getEvents().performWrite(new CLEvents.Action() { - - public CLEvent perform(CLEvent[] oevents) { - return in.getKernels().op1(in.getPrimitive(), fun, in.getBuffer(), - in.getRowCount(), in.getColumnCount(), in.getStride(), - out.getBuffer(), join(ievents, oevents)); - } - }); - } - }); - return out; - } - - - public static CLMatrix2D op2(final CLMatrix2D in1, final Fun2 fun, final CLMatrix2D in2, final CLMatrix2D out) throws CLBuildException { - in1.getEvents().performRead(new CLEvents.Action() { - - public CLEvent perform(final CLEvent[] i1events) { - return in2.getEvents().performRead(new CLEvents.Action() { - - public CLEvent perform(final CLEvent[] i2events) { - return out.getEvents().performWrite(new CLEvents.Action() { - - public CLEvent perform(CLEvent[] oevents) { - return in1.getKernels().op2(in1.getPrimitive(), fun, - in1.getBuffer(), in2.getBuffer(), - in1.getRowCount(), in1.getColumnCount(), in1.getStride(), - out.getBuffer(), join(i1events, i2events, oevents)); - } - }); - } - }); - } - }); - return out; - } - - public static CLMatrix2D op2(final CLMatrix2D in, final Fun2 fun, final V s2, final CLMatrix2D out) throws CLBuildException { - in.getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(final CLEvent[] ievents) { - return out.getEvents().performWrite(new CLEvents.Action() { - - public CLEvent perform(CLEvent[] oevents) { - return in.getKernels().op2( - in.getPrimitive(), fun, in.getBuffer(), s2, - in.getRowCount(), in.getColumnCount(), in.getStride(), - out.getBuffer(), - join(ievents, oevents)); - } - }); - } - }); - return out; - } - -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseDoubleMatrix2D.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseDoubleMatrix2D.java deleted file mode 100644 index 04d41160..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseDoubleMatrix2D.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.blas.CLMatrix2D; -import com.nativelibs4java.opencl.blas.CLMatrixUtils; -import com.nativelibs4java.opencl.blas.CLDefaultMatrix2D; -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.blas.CLEvents.Action; -import java.nio.DoubleBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.ujmp.core.Matrix; -import org.ujmp.core.calculation.Calculation.Ret; -import org.ujmp.core.doublematrix.DoubleMatrix2D; -import org.ujmp.core.exceptions.MatrixException; - -import com.nativelibs4java.opencl.CLBuildException; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLMem.MapFlags; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.util.LinearAlgebraUtils; -import com.nativelibs4java.opencl.util.Primitive; -import com.nativelibs4java.util.NIOUtils; -import java.nio.Buffer; -import org.bridj.Pointer; -import org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix2D; -import org.ujmp.core.matrix.Matrix2D; - -/** - * - * @author ochafik - */ -public class CLDenseDoubleMatrix2D extends AbstractDenseDoubleMatrix2D { - - protected final CLDenseMatrix2DImpl impl; - - public CLDenseMatrix2DImpl getImpl() { - return impl; - } - public CLDenseDoubleMatrix2D(CLDenseMatrix2DImpl impl) { - this.impl = impl; - } - public CLDenseDoubleMatrix2D(CLMatrix2D matrix) { - this(new CLDenseMatrix2DImpl(matrix)); - } - public CLDenseDoubleMatrix2D(long rows, long columns, CLKernels kernels) { - this(new CLDefaultMatrix2D(Primitive.Double, null, rows, columns, kernels)); - } - public CLDenseDoubleMatrix2D(long rows, long columns, CLKernels clUJMP, int blockSize) { - this(new CLDefaultMatrix2D(Primitive.Double, null, rows, columns, blockSize, clUJMP)); - } - public CLDenseDoubleMatrix2D(long rows, long columns) { - this(rows, columns, CLKernels.getInstance()); - } - public CLDenseDoubleMatrix2D(long size) { - this(size, size); - } - public CLDenseDoubleMatrix2D(long... size) { - this(size[0], size[1], CLKernels.getInstance()); - } - - public long getStride() { - return getImpl().getStride(); - } - - public void write(Pointer p) { - getImpl().write(p); - } - - public void read(Pointer p) { - getImpl().read(p); - } - - public Pointer read() { - return getImpl().read(); - } - - static CLDenseDoubleMatrix2D inst(CLMatrix2D matrix) { - return new CLDenseDoubleMatrix2D(matrix); - } - - static CLDenseDoubleMatrix2D inst(CLDenseMatrix2DImpl matrix) { - return new CLDenseDoubleMatrix2D(matrix); - } - - @Override - public Matrix mtimes(Ret returnType, boolean ignoreNaN, Matrix matrix) throws MatrixException { - if (matrix instanceof Matrix2D) { - return inst(getImpl().multiply(returnType, ignoreNaN, (Matrix2D)matrix)); - } else { - return super.mtimes(returnType, ignoreNaN, matrix); - } - } - - @Override - public Matrix mtimes(Matrix matrix) throws MatrixException { - return mtimes(Ret.NEW, true, matrix); - } - - - - @Override - public Iterable allValues() { - return (Pointer)impl.read(); - } - - - - - @Override - public Matrix min(Ret returnType, int dimension) throws MatrixException { - switch (dimension) { - case ROW: - case COLUMN: - // TODO - return super.min(returnType, dimension); - case ALL: - try { - return inst(impl.min()); - } catch (CLBuildException ex) { - throw new MatrixException("Failed to compute min", ex); - } - default: - throw new IllegalArgumentException("Invalid dimension : " + dimension); - } - } - - @Override - public Matrix max(Ret returnType, int dimension) throws MatrixException { - switch (dimension) { - case ROW: - case COLUMN: - // TODO - return super.max(returnType, dimension); - case ALL: - try { - return inst(impl.max()); - } catch (CLBuildException ex) { - throw new MatrixException("Failed to compute max", ex); - } - default: - throw new IllegalArgumentException("Invalid dimension : " + dimension); - } - } - - @Override - public Matrix mean(Ret returnType, int dimension, boolean ignoreNaN) throws MatrixException { - // TODO - return super.mean(returnType, dimension, ignoreNaN); - } - - @Override - public Matrix center(Ret returnType, int dimension, boolean ignoreNaN) throws MatrixException { - switch (dimension) { - case ROW: - case COLUMN: - // TODO - return super.center(returnType, dimension, ignoreNaN); - case ALL: - return minus(returnType, ignoreNaN, mean(Ret.NEW, dimension, ignoreNaN).getAsDouble(0, 0)); - default: - throw new IllegalArgumentException("Invalid dimension : " + dimension); - } - } - - @Override - public synchronized Matrix copy() throws MatrixException { - return inst(impl.clone()); - } - - @Override - public Matrix transpose(Ret returnType) throws MatrixException { - return inst(impl.transpose(returnType)); - } - - @Override - public synchronized Matrix transpose() throws MatrixException { - return transpose(Ret.NEW); - } - - public long[] getSize() { - return impl.getSize(); - } - - public double getDouble(long row, long column) { - return impl.get(row, column); - } - public void setDouble(double value, long row, long column) { - impl.set(value, row, column); - } - - public double getDouble(int row, int column) { - return getDouble((long)row, (long)column); - } - - public void setDouble(double value, int row, int column) { - setDouble(value, (long)row, (long)column); - } - - - - @Override - public Matrix sin(Ret returnType) throws MatrixException { - return inst(impl.sin(returnType)); - } - - @Override - public Matrix cos(Ret returnType) throws MatrixException { - return inst(impl.cos(returnType)); - } - - @Override - public Matrix sinh(Ret returnType) throws MatrixException { - return inst(impl.sinh(returnType)); - } - - @Override - public Matrix cosh(Ret returnType) throws MatrixException { - return inst(impl.cosh(returnType)); - } - - @Override - public Matrix tan(Ret returnType) throws MatrixException { - return inst(impl.tan(returnType)); - } - - @Override - public Matrix tanh(Ret returnType) throws MatrixException { - return inst(impl.tanh(returnType)); - } - - //@Override - public Matrix asin(Ret returnType) throws MatrixException { - return inst(impl.asin(returnType)); - } - - //@Override - public Matrix acos(Ret returnType) throws MatrixException { - return inst(impl.acos(returnType)); - } - - //@Override - public Matrix asinh(Ret returnType) throws MatrixException { - return inst(impl.asinh(returnType)); - } - - //@Override - public Matrix acosh(Ret returnType) throws MatrixException { - return inst(impl.acosh(returnType)); - } - - //@Override - public Matrix atan(Ret returnType) throws MatrixException { - return inst(impl.atan(returnType)); - } - - //@Override - public Matrix atanh(Ret returnType) throws MatrixException { - return inst(impl.atanh(returnType)); - } - - @Override - public Matrix minus(Matrix m) throws MatrixException { - return minus(Ret.NEW, true, m); - } - - @Override - public Matrix minus(double m) throws MatrixException { - return minus(Ret.NEW, true, m); - } - - @Override - public Matrix minus(Ret returnType, boolean ignoreNaN, Matrix m) throws MatrixException { - return inst(impl.minus(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)m).getImpl())); - } - @Override - public Matrix minus(Ret returnType, boolean ignoreNaN, double v) throws MatrixException { - return inst(impl.minus(returnType, ignoreNaN, v)); - } - - @Override - public Matrix plus(Matrix m) throws MatrixException { - return plus(Ret.NEW, true, m); - } - - @Override - public Matrix plus(double m) throws MatrixException { - return plus(Ret.NEW, true, m); - } - - @Override - public Matrix plus(Ret returnType, boolean ignoreNaN, Matrix m) throws MatrixException { - return inst(impl.plus(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)m).getImpl())); - } - - @Override - public Matrix plus(Ret returnType, boolean ignoreNaN, double v) throws MatrixException { - return inst(impl.plus(returnType, ignoreNaN, v)); - } - - @Override - public Matrix times(Matrix m) throws MatrixException { - return times(Ret.NEW, true, m); - } - - @Override - public Matrix times(double m) throws MatrixException { - return times(Ret.NEW, true, m); - } - - @Override - public Matrix times(Ret returnType, boolean ignoreNaN, Matrix factor) throws MatrixException { - return inst(impl.times(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)factor).getImpl())); - } - - @Override - public Matrix times(Ret returnType, boolean ignoreNaN, double factor) throws MatrixException { - return inst(impl.times(returnType, ignoreNaN, factor)); - } - - @Override - public Matrix divide(Matrix m) throws MatrixException { - return divide(Ret.NEW, true, m); - } - - @Override - public Matrix divide(double m) throws MatrixException { - return divide(Ret.NEW, true, m); - } - - @Override - public Matrix divide(Ret returnType, boolean ignoreNaN, Matrix factor) throws MatrixException { - return inst(impl.divide(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)factor).getImpl())); - } - - @Override - public Matrix divide(Ret returnType, boolean ignoreNaN, double factor) throws MatrixException { - return inst(impl.divide(returnType, ignoreNaN, factor)); - } - - @Override - public double[][] toDoubleArray() throws MatrixException { - Pointer b = impl.read(); - int rows = (int)impl.rows, columns = (int)impl.columns; - double[][] ret = new double[rows][]; - for (int i = 0; i < rows; i++) { - ret[i] = b.getDoublesAtOffset(i * columns, columns); - } - return ret; - } - - - @Override - public boolean containsDouble(double v) { - try { - return impl.containsValue(v); - } catch (CLBuildException ex) { - throw new RuntimeException("Failed to test value presence", ex); - } - } - - @Override - public void clear() { - try { - impl.clear(); - } catch (CLBuildException ex) { - throw new RuntimeException("Failed to clear matrix", ex); - } - } - - public void waitFor() { - impl.waitFor(); - } -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseDoubleMatrix2DFactory.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseDoubleMatrix2DFactory.java deleted file mode 100644 index b27255ec..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseDoubleMatrix2DFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.CLPlatform; -import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; -import com.nativelibs4java.opencl.JavaCL; -import com.nativelibs4java.opencl.blas.CLDefaultMatrix2D; -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.util.LinearAlgebraUtils; -import com.nativelibs4java.opencl.util.Primitive; -import org.ujmp.core.doublematrix.DenseDoubleMatrix2D; -import org.ujmp.core.doublematrix.factory.AbstractDoubleMatrix2DFactory; -import org.ujmp.core.exceptions.MatrixException; - -/** - * - * @author ochafik - */ -public class CLDenseDoubleMatrix2DFactory extends AbstractDoubleMatrix2DFactory { - final int blockSize; - public CLDenseDoubleMatrix2DFactory(int blockSize) { - this.blockSize = blockSize; - } - public CLDenseDoubleMatrix2DFactory() { - this(CLDefaultMatrix2D.DEFAULT_BLOCK_SIZE); - } - public CLDenseDoubleMatrix2D dense(long rows, long columns) - throws MatrixException { - return new CLDenseDoubleMatrix2D(rows, columns, CLKernels.getInstance(), blockSize); - } -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseFloatMatrix2D.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseFloatMatrix2D.java deleted file mode 100644 index 65817af3..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseFloatMatrix2D.java +++ /dev/null @@ -1,400 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.blas.CLMatrix2D; -import com.nativelibs4java.opencl.blas.CLMatrixUtils; -import com.nativelibs4java.opencl.blas.CLDefaultMatrix2D; -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.blas.CLEvents.Action; -import java.nio.DoubleBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.ujmp.core.Matrix; -import org.ujmp.core.calculation.Calculation.Ret; -import org.ujmp.core.doublematrix.DoubleMatrix2D; -import org.ujmp.core.exceptions.MatrixException; - -import com.nativelibs4java.opencl.CLBuildException; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLMem.MapFlags; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.util.LinearAlgebraUtils; -import com.nativelibs4java.opencl.util.Primitive; -import com.nativelibs4java.util.NIOUtils; -import java.nio.Buffer; -import org.bridj.Pointer; -import org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix2D; -import org.ujmp.core.floatmatrix.FloatMatrix2D; -import org.ujmp.core.floatmatrix.stub.AbstractDenseFloatMatrix2D; -import org.ujmp.core.matrix.Matrix2D; - -/** - * - * @author ochafik - */ -public class CLDenseFloatMatrix2D extends AbstractDenseFloatMatrix2D { - - protected final CLDenseMatrix2DImpl impl; - - public CLDenseMatrix2DImpl getImpl() { - return impl; - } - public CLDenseFloatMatrix2D(CLDenseMatrix2DImpl impl) { - this.impl = impl; - } - public CLDenseFloatMatrix2D(CLMatrix2D matrix) { - this(new CLDenseMatrix2DImpl(matrix)); - } - public CLDenseFloatMatrix2D(long rows, long columns, CLKernels clUJMP) { - this(new CLDefaultMatrix2D(Primitive.Float, null, rows, columns, clUJMP)); - } - public CLDenseFloatMatrix2D(long rows, long columns, CLKernels clUJMP, int blockSize) { - this(new CLDefaultMatrix2D(Primitive.Float, null, rows, columns, blockSize, clUJMP)); - } - public CLDenseFloatMatrix2D(long rows, long columns) { - this(rows, columns, CLKernels.getInstance()); - } - public CLDenseFloatMatrix2D(long size) { - this(size, size); - } - public CLDenseFloatMatrix2D(long... size) { - this(size[0], size[1], CLKernels.getInstance()); - } - - public void write(Pointer p) { - getImpl().write(p); - } - - public void read(Pointer p) { - getImpl().read(p); - } - - public long getStride() { - return getImpl().getStride(); - } - - public Pointer read() { - return getImpl().read(); - } - - static CLDenseFloatMatrix2D inst(CLMatrix2D matrix) { - return new CLDenseFloatMatrix2D(matrix); - } - - static CLDenseFloatMatrix2D inst(CLDenseMatrix2DImpl matrix) { - return new CLDenseFloatMatrix2D(matrix); - } - - @Override - public Matrix mtimes(Ret returnType, boolean ignoreNaN, Matrix matrix) throws MatrixException { - if (matrix instanceof Matrix2D) { - return inst(getImpl().multiply(returnType, ignoreNaN, (Matrix2D)matrix)); - } else { - return super.mtimes(returnType, ignoreNaN, matrix); - } - } - - @Override - public Matrix mtimes(Matrix matrix) throws MatrixException { - return mtimes(Ret.NEW, true, matrix); - } - - - @Override - public Iterable allValues() { - return (Pointer)impl.read(); - } - - - @Override - public Matrix min(Ret returnType, int dimension) throws MatrixException { - switch (dimension) { - case ROW: - case COLUMN: - // TODO - return super.min(returnType, dimension); - case ALL: - try { - return inst(impl.min()); - } catch (CLBuildException ex) { - throw new MatrixException("Failed to compute min", ex); - } - default: - throw new IllegalArgumentException("Invalid dimension : " + dimension); - } - } - - @Override - public Matrix max(Ret returnType, int dimension) throws MatrixException { - switch (dimension) { - case ROW: - case COLUMN: - // TODO - return super.max(returnType, dimension); - case ALL: - try { - return inst(impl.max()); - } catch (CLBuildException ex) { - throw new MatrixException("Failed to compute max", ex); - } - default: - throw new IllegalArgumentException("Invalid dimension : " + dimension); - } - } - - @Override - public Matrix mean(Ret returnType, int dimension, boolean ignoreNaN) throws MatrixException { - // TODO - return super.mean(returnType, dimension, ignoreNaN); - } - - @Override - public Matrix center(Ret returnType, int dimension, boolean ignoreNaN) throws MatrixException { - switch (dimension) { - case ROW: - case COLUMN: - // TODO - return super.center(returnType, dimension, ignoreNaN); - case ALL: - return minus(returnType, ignoreNaN, mean(Ret.NEW, dimension, ignoreNaN).getAsFloat(0, 0)); - default: - throw new IllegalArgumentException("Invalid dimension : " + dimension); - } - } - - @Override - public synchronized Matrix copy() throws MatrixException { - return inst(impl.clone()); - } - - @Override - public Matrix transpose(Ret returnType) throws MatrixException { - return inst(impl.transpose(returnType)); - } - - @Override - public synchronized Matrix transpose() throws MatrixException { - return transpose(Ret.NEW); - } - - public long[] getSize() { - return impl.getSize(); - } - - public float getFloat(long row, long column) { - return impl.get(row, column); - } - public void setFloat(float value, long row, long column) { - impl.set(value, row, column); - } - - public float getFloat(int row, int column) { - return getFloat((long)row, (long)column); - } - - public void setFloat(float value, int row, int column) { - setFloat(value, (long)row, (long)column); - } - - - - @Override - public Matrix sin(Ret returnType) throws MatrixException { - return inst(impl.sin(returnType)); - } - - @Override - public Matrix cos(Ret returnType) throws MatrixException { - return inst(impl.cos(returnType)); - } - - @Override - public Matrix sinh(Ret returnType) throws MatrixException { - return inst(impl.sinh(returnType)); - } - - @Override - public Matrix cosh(Ret returnType) throws MatrixException { - return inst(impl.cosh(returnType)); - } - - @Override - public Matrix tan(Ret returnType) throws MatrixException { - return inst(impl.tan(returnType)); - } - - @Override - public Matrix tanh(Ret returnType) throws MatrixException { - return inst(impl.tanh(returnType)); - } - - //@Override - public Matrix asin(Ret returnType) throws MatrixException { - return inst(impl.asin(returnType)); - } - - //@Override - public Matrix acos(Ret returnType) throws MatrixException { - return inst(impl.acos(returnType)); - } - - //@Override - public Matrix asinh(Ret returnType) throws MatrixException { - return inst(impl.asinh(returnType)); - } - - //@Override - public Matrix acosh(Ret returnType) throws MatrixException { - return inst(impl.acosh(returnType)); - } - - //@Override - public Matrix atan(Ret returnType) throws MatrixException { - return inst(impl.atan(returnType)); - } - - //@Override - public Matrix atanh(Ret returnType) throws MatrixException { - return inst(impl.atanh(returnType)); - } - - @Override - public Matrix minus(Matrix m) throws MatrixException { - return minus(Ret.NEW, true, m); - } - - @Override - public Matrix minus(double m) throws MatrixException { - return minus(Ret.NEW, true, m); - } - - @Override - public Matrix minus(Ret returnType, boolean ignoreNaN, Matrix m) throws MatrixException { - return inst(impl.minus(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)m).getImpl())); - } - @Override - public Matrix minus(Ret returnType, boolean ignoreNaN, double v) throws MatrixException { - return inst(impl.minus(returnType, ignoreNaN, (float)v)); - } - - @Override - public Matrix plus(Matrix m) throws MatrixException { - return plus(Ret.NEW, true, m); - } - - @Override - public Matrix plus(double m) throws MatrixException { - return plus(Ret.NEW, true, m); - } - - @Override - public Matrix plus(Ret returnType, boolean ignoreNaN, Matrix m) throws MatrixException { - return inst(impl.plus(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)m).getImpl())); - } - - @Override - public Matrix plus(Ret returnType, boolean ignoreNaN, double v) throws MatrixException { - return inst(impl.plus(returnType, ignoreNaN, (float)v)); - } - - @Override - public Matrix times(Matrix m) throws MatrixException { - return times(Ret.NEW, true, m); - } - - @Override - public Matrix times(double m) throws MatrixException { - return times(Ret.NEW, true, m); - } - - @Override - public Matrix times(Ret returnType, boolean ignoreNaN, Matrix factor) throws MatrixException { - return inst(impl.times(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)factor).getImpl())); - } - - @Override - public Matrix times(Ret returnType, boolean ignoreNaN, double factor) throws MatrixException { - return inst(impl.times(returnType, ignoreNaN, (float)factor)); - } - - @Override - public Matrix divide(Matrix m) throws MatrixException { - return divide(Ret.NEW, true, m); - } - - @Override - public Matrix divide(double m) throws MatrixException { - return divide(Ret.NEW, true, m); - } - - @Override - public Matrix divide(Ret returnType, boolean ignoreNaN, Matrix factor) throws MatrixException { - return inst(impl.divide(returnType, ignoreNaN, ((CLDenseFloatMatrix2D)factor).getImpl())); - } - - @Override - public Matrix divide(Ret returnType, boolean ignoreNaN, double factor) throws MatrixException { - return inst(impl.divide(returnType, ignoreNaN, (float)factor)); - } - - @Override - public boolean containsDouble(double v) { - return containsFloat((float)v); - } - - - @Override - public boolean containsFloat(float v) { - try { - return impl.containsValue((float)v); - } catch (CLBuildException ex) { - throw new RuntimeException("Failed to test value presence", ex); - } - } - - @Override - public void clear() { - try { - impl.clear(); - } catch (CLBuildException ex) { - throw new RuntimeException("Failed to clear matrix", ex); - } - } - - public void waitFor() { - impl.waitFor(); - } - - - @Override - public float[][] toFloatArray() throws MatrixException { - Pointer b = impl.read(); - float[][] ret = new float[(int)impl.rows][]; - for (int i = 0; i < impl.rows; i++) { - ret[i] = b.getFloatsAtOffset(i * impl.columns, (int)impl.columns); - } - return ret; - } - - @Override - public double[][] toDoubleArray() throws MatrixException { - Pointer b = impl.read(); - double[][] ret = new double[(int)impl.rows][(int)impl.columns]; - for (int i = 0; i < impl.rows; i++) { - float[] floats = b.getFloatsAtOffset(i * impl.columns, (int) impl.columns); - double[] doubles = ret[i]; - for (int j = 0; j < floats.length; j++) - doubles[j] = floats[j]; - } - return ret; - } -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseFloatMatrix2DFactory.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseFloatMatrix2DFactory.java deleted file mode 100644 index cf3e2a5d..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseFloatMatrix2DFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.blas.CLDefaultMatrix2D; -import com.nativelibs4java.opencl.blas.CLKernels; -import org.ujmp.core.floatmatrix.DenseFloatMatrix2D; -import org.ujmp.core.floatmatrix.factory.AbstractFloatMatrix2DFactory; -import org.ujmp.core.exceptions.MatrixException; - -/** - * - * @author ochafik - */ -public class CLDenseFloatMatrix2DFactory extends AbstractFloatMatrix2DFactory { - final int blockSize; - public CLDenseFloatMatrix2DFactory(int blockSize) { - this.blockSize = blockSize; - } - public CLDenseFloatMatrix2DFactory() { - this(CLDefaultMatrix2D.DEFAULT_BLOCK_SIZE); - } - public CLDenseFloatMatrix2D dense(long rows, long columns) - throws MatrixException { - return new CLDenseFloatMatrix2D(rows, columns, CLKernels.getInstance(), blockSize); - } -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseMatrix2DImpl.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseMatrix2DImpl.java deleted file mode 100644 index 5d73b280..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLDenseMatrix2DImpl.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.CLBuildException; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.blas.CLEvents; -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.blas.CLMatrix2D; -import com.nativelibs4java.opencl.blas.CLMatrixUtils; -import com.nativelibs4java.opencl.util.Fun1; -import com.nativelibs4java.opencl.util.Fun2; -import com.nativelibs4java.opencl.util.ReductionUtils; -import com.nativelibs4java.opencl.util.ReductionUtils.Reductor; - -import org.bridj.Pointer; -import org.ujmp.core.calculation.Calculation.Ret; -import org.ujmp.core.exceptions.MatrixException; -import org.ujmp.core.matrix.Matrix2D; - -import static org.bridj.Pointer.allocate; - -/** - * - * @author ochafik - */ -public class CLDenseMatrix2DImpl { - protected final CLMatrix2D _matrix; - protected final long rows, columns, stride, size[]; - protected Pointer cache; - protected int uncachedGetCount; - protected static final int GET_COUNT_BEFORE_CACHING = 3; - - public CLDenseMatrix2DImpl(CLMatrix2D _matrix) { - this._matrix = _matrix; - this.rows = _matrix.getRowCount(); - this.columns = _matrix.getColumnCount(); - this.stride = _matrix.getStride(); - this.size = new long[] { rows, columns }; - _matrix.getEvents().addListener(new CLEvents.Listener() { - public void writing(CLEvents evts) { - synchronized (CLDenseMatrix2DImpl.this) { - cache = null; - uncachedGetCount = 0; - } - } - - public void reading(CLEvents evts) {} - }); - } - - protected CLMatrix2D getMatrix() { - return _matrix; - } - - public long getStride() { - return stride; - } - - protected long getStorageIndex(long row, long column) { - return stride * row + column; - } - - protected synchronized void cache() { - if (cache != null) - return; - - cache = read(); - uncachedGetCount = 0; - } - public V get(long row, long column) { - final long offset = getStorageIndex(row, column); - synchronized (this) { - if (uncachedGetCount >= GET_COUNT_BEFORE_CACHING) - cache(); - - if (cache != null) - return cache.get(offset); - else - uncachedGetCount++; - } - final Pointer out = allocate(getMatrix().getPrimitiveClass()).order(getMatrix().getContext().getByteOrder()); - getMatrix().getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(CLEvent[] events) { - return getMatrix().getBuffer().read(getMatrix().getQueue(), offset, 1, out, true, events); - } - }); - return out.get(); - } - public CLDenseMatrix2DImpl clone() { - return new CLDenseMatrix2DImpl(CLMatrixUtils.clone(getMatrix())); - } - public void waitFor() { - getMatrix().getEvents().waitFor(); - } - public void write(Pointer p) { - getMatrix().write(p); - } - public void read(Pointer p) { - synchronized (this) { - if (cache != null) { - cache.copyTo(p); - return; - } - } - getMatrix().read(p); - } - public Pointer read() { - synchronized (this) { - if (cache != null) - return cache.clone(); - } - Pointer b = (Pointer)Pointer.allocateArray(getMatrix().getPrimitiveClass(), rows * stride); - getMatrix().read(b); - return b; - } - - public void set(V value, long row, long column) { - final long offset = getStorageIndex(row, column); - final Pointer in = allocate(getMatrix().getPrimitiveClass()).order(getMatrix().getContext().getByteOrder()); - in.set(value); - getMatrix().getEvents().performWrite(new CLEvents.Action() { - public CLEvent perform(CLEvent[] events) { - return getMatrix().getBuffer().write(getMatrix().getQueue(), offset, 1, in, false, events); - } - }); - } - - /* - public Matrix mtimes(Matrix matrix) throws MatrixException { - if (matrix instanceof DoubleMatrix2D) { - CLMatrix2D - b = CLMatrixUtils.asInputMatrix((DoubleMatrix2D)matrix, queue, context), - out = blankMatrix(getRowCount(), matrix.getColumnCount()); - - CLMatrixUtils.mtimes(this, b, out, primitive, clUJMP); - return (Matrix)out; - } else { - return super.mtimes(matrix); - } - } - */ - - - public CLDenseMatrix2DImpl copy() throws MatrixException { - return new CLDenseMatrix2DImpl(CLMatrixUtils.clone(getMatrix())); - } - - public CLDenseMatrix2DImpl multiply(Ret returnType, boolean ignoreNaN, Matrix2D matrix) throws MatrixException { - CLKernels clUJMP = getMatrix().getKernels(); - CLMatrix2D - in1 = getMatrix(), - in2 = CLWrappedMatrix2D.wrap(matrix, clUJMP), - out = returnType == Ret.ORIG ? in1 : in1.blankMatrix(in1.getRowCount(), in2.getColumnCount()); - - CLMatrixUtils.matrixMultiply(in1, in2, out); - return new CLDenseMatrix2DImpl(out); - } - public CLDenseMatrix2DImpl transpose(Ret returnType) throws MatrixException { - CLMatrix2D - in = getMatrix(), - out = returnType == Ret.ORIG ? in : in.blankMatrix(columns, rows); - CLMatrixUtils.matrixTranspose(in, out); - return new CLDenseMatrix2DImpl(out); - } - - public long[] getSize() { - return size; - } - - public static CLDenseMatrix2DImpl op1(final CLMatrix2D in, final Fun1 fun, Ret returnType) throws MatrixException { - final CLMatrix2D out = returnType == Ret.ORIG ? in : in.blankClone(); - return new CLDenseMatrix2DImpl(CLMatrixUtils.op1(in, fun, out)); - } - public CLDenseMatrix2DImpl sin(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.sin, returnType); - } - - - public CLDenseMatrix2DImpl cos(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.cos, returnType); - } - - - public CLDenseMatrix2DImpl sinh(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.sinh, returnType); - } - - - public CLDenseMatrix2DImpl cosh(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.cosh, returnType); - } - - - public CLDenseMatrix2DImpl tan(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.tan, returnType); - } - - - public CLDenseMatrix2DImpl tanh(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.tanh, returnType); - } - - - public CLDenseMatrix2DImpl asin(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.asin, returnType); - } - - - public CLDenseMatrix2DImpl acos(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.acos, returnType); - } - - - public CLDenseMatrix2DImpl asinh(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.asinh, returnType); - } - - - public CLDenseMatrix2DImpl acosh(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.acosh, returnType); - } - - - public CLDenseMatrix2DImpl atan(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.atan, returnType); - } - - - public CLDenseMatrix2DImpl atanh(Ret returnType) throws MatrixException { - return op1(getMatrix(), Fun1.atanh, returnType); - } - - public static CLDenseMatrix2DImpl op2(CLMatrix2D in1, Fun2 fun, CLMatrix2D in2, Ret returnType) throws MatrixException { - final CLMatrix2D out = returnType == Ret.ORIG ? in1 : in1.blankClone(); - return new CLDenseMatrix2DImpl(CLMatrixUtils.op2(in1, fun, in2, out)); - } - public static CLDenseMatrix2DImpl op2(CLMatrix2D in1, Fun2 fun, V in2, Ret returnType) throws MatrixException { - final CLMatrix2D out = returnType == Ret.ORIG ? in1 : in1.blankClone(); - return new CLDenseMatrix2DImpl(CLMatrixUtils.op2(in1, fun, in2, out)); - } - - - public CLDenseMatrix2DImpl minus(Ret returnType, boolean ignoreNaN, CLDenseMatrix2DImpl m) throws MatrixException { - return op2(getMatrix(), Fun2.substract, m.getMatrix(), returnType); - } - - public CLDenseMatrix2DImpl minus(Ret returnType, boolean ignoreNaN, V v) throws MatrixException { - return op2(getMatrix(), Fun2.substract, v, returnType); - } - - public CLDenseMatrix2DImpl plus(Ret returnType, boolean ignoreNaN, CLDenseMatrix2DImpl m) throws MatrixException { - return op2(getMatrix(), Fun2.add, m.getMatrix(), returnType); - } - - public CLDenseMatrix2DImpl plus(Ret returnType, boolean ignoreNaN, V v) throws MatrixException { - return op2(getMatrix(), Fun2.add, v, returnType); - } - - public CLDenseMatrix2DImpl times(Ret returnType, boolean ignoreNaN, CLDenseMatrix2DImpl factor) throws MatrixException { - return op2(getMatrix(), Fun2.multiply, factor.getMatrix(), returnType); - } - - public CLDenseMatrix2DImpl times(Ret returnType, boolean ignoreNaN, V factor) throws MatrixException { - return op2(getMatrix(), Fun2.multiply, factor, returnType); - } - - public CLDenseMatrix2DImpl divide(Ret returnType, boolean ignoreNaN, CLDenseMatrix2DImpl factor) throws MatrixException { - return op2(getMatrix(), Fun2.divide, factor.getMatrix(), returnType); - } - - public CLDenseMatrix2DImpl divide(Ret returnType, boolean ignoreNaN, V factor) throws MatrixException { - return op2(getMatrix(), Fun2.divide, factor, returnType); - } - //protected abstract Matrix createMatrix(CLMatrixImpl mi); - - - static final int MAX_REDUCTION_SIZE = 32; - volatile Reductor minReductor; - public CLDenseMatrix2DImpl min() throws CLBuildException { - synchronized (this) { - if (minReductor == null) - minReductor = ReductionUtils.createReductor(getMatrix().getContext(), ReductionUtils.Operation.Min, getMatrix().getPrimitive().oclType, 1); - } - CLMatrix2D out = getMatrix().blankMatrix(1, 1); - CLMatrixUtils.reduce(getMatrix(), out, minReductor); - return new CLDenseMatrix2DImpl(out); - } - volatile Reductor maxReductor; - public CLDenseMatrix2DImpl max() throws CLBuildException { - synchronized (this) { - if (maxReductor == null) - maxReductor = ReductionUtils.createReductor(getMatrix().getContext(), ReductionUtils.Operation.Max, getMatrix().getPrimitive().oclType, 1); - } - CLMatrix2D - in = getMatrix(), - out = in.blankMatrix(1, 1); - CLMatrixUtils.reduce(in, out, minReductor); - return new CLDenseMatrix2DImpl(out); - } - - public boolean containsValue(final V value) throws CLBuildException { - final boolean ret[] = new boolean[1]; - getMatrix().getEvents().performRead(new CLEvents.Action() { - public CLEvent perform(CLEvent[] events) { - ret[0] = getMatrix().getKernels().containsValue(getMatrix().getPrimitive(), getMatrix().getBuffer(), getMatrix().getBuffer().getElementCount(), value, events); - return null; - } - }); - return ret[0]; - } - - public void clear() throws CLBuildException { - getMatrix().getEvents().performWrite(new CLEvents.Action() { - public CLEvent perform(CLEvent[] events) { - return getMatrix().getKernels().clear(getMatrix().getPrimitive(), getMatrix().getBuffer(), getMatrix().getBuffer().getElementCount(), events); - } - }); - } - - public CLQueue getQueue() { - return getMatrix().getQueue(); - } - -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLMatrixBenchmark.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLMatrixBenchmark.java deleted file mode 100644 index c2d4d87d..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLMatrixBenchmark.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.blas.CLDefaultMatrix2D; -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.blas.CLMatrixUtils; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - -import org.ujmp.core.Matrix; -import org.ujmp.core.benchmark.AbstractMatrix2DBenchmark; -import org.ujmp.core.doublematrix.DoubleMatrix2D; -import org.ujmp.core.exceptions.MatrixException; - -/** - * - * @author ochafik - */ -public class CLMatrixBenchmark extends AbstractMatrix2DBenchmark { - - @Override - public DoubleMatrix2D createMatrix(long... size) throws MatrixException { - return new CLDenseDoubleMatrix2D(size); - } - - @Override - public DoubleMatrix2D createMatrix(Matrix source) throws MatrixException { - if (source instanceof CLDenseDoubleMatrix2D) - return (DoubleMatrix2D)((CLDenseDoubleMatrix2D)source).copy(); - else { - DoubleMatrix2D dsource = (DoubleMatrix2D)source; - long rows = dsource.getRowCount(), columns = dsource.getColumnCount(); - CLDenseDoubleMatrix2D copy = new CLDenseDoubleMatrix2D(rows, columns); - long stride = copy.getStride(); - Pointer b = allocateDoubles(rows * stride).order(CLKernels.getInstance().getContext().getKernelsDefaultByteOrder()); - for (long i = 0; i < rows; i++) { - long offset = i * stride; - for (long j = 0; j < columns; j++) { - b.set(offset + i, dsource.getDouble(i, j)); - } - } - copy.write(b); - return copy; - } - } - -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLWrappedMatrix2D.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLWrappedMatrix2D.java deleted file mode 100644 index 777f8f68..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/CLWrappedMatrix2D.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.blas.CLDefaultMatrix2D; -import com.nativelibs4java.opencl.blas.CLEvents; -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.blas.CLMatrix2D; -import com.nativelibs4java.opencl.blas.CLMatrixUtils; -import com.nativelibs4java.opencl.util.Primitive; - -import org.bridj.Pointer; -import org.ujmp.core.doublematrix.DoubleMatrix2D; -import org.ujmp.core.floatmatrix.FloatMatrix2D; -import org.ujmp.core.matrix.Matrix2D; - -import static org.bridj.Pointer.allocateArray; - -/** - * - * @author ochafik - */ -public class CLWrappedMatrix2D implements CLMatrix2D { - public static CLMatrix2D wrap(final Matrix2D matrix, final CLKernels clUJMP) { - if (matrix instanceof CLMatrix2D) - return (CLMatrix2D)matrix; - - return new CLWrappedMatrix2D(matrix, clUJMP, CLDefaultMatrix2D.DEFAULT_BLOCK_SIZE); - } - - final Matrix2D matrix; - final CLKernels kernels; - final Primitive primitive; - final Class elementType; - final int blockSize; - final long stride; - - CLWrappedMatrix2D(Matrix2D matrix, CLKernels kernels, int blockSize) { - this.matrix = matrix; - this.kernels = kernels; - this.blockSize = blockSize; - this.stride = CLMatrixUtils.roundUp(matrix.getColumnCount(), blockSize); - - if (matrix instanceof DoubleMatrix2D) - this.primitive = Primitive.Double; - else if (matrix instanceof FloatMatrix2D) - this.primitive = Primitive.Float; - else - throw new UnsupportedOperationException(); - - elementType = (Class)primitive.primitiveType; - } - - final CLEvents events = new CLEvents(); - public CLEvents getEvents() { - return events; - } - - public CLKernels getKernels() { - return kernels; - } - - - public Primitive getPrimitive() { - return primitive; - } - - volatile CLBuffer buffer; - volatile Pointer data; - public synchronized CLBuffer getBuffer() { - long length = stride * CLMatrixUtils.roundUp(matrix.getColumnCount(), blockSize); - - // Read data - if (data == null) { - data = allocateArray(elementType, length).order(getContext().getByteOrder()); - } - MatrixUtils.read(matrix, data, stride); - - // Write data to CLBuffer - if (buffer == null) { - buffer = kernels.getContext().createBuffer(Usage.Input, elementType, length); - } - - events.performWrite(new CLEvents.Action() { - public CLEvent perform(CLEvent[] events) { - return buffer.write(getQueue(), data, false, events); - } - }); - - return buffer; - } - - public long getRowCount() { - return matrix.getRowCount(); - } - - public long getColumnCount() { - return matrix.getColumnCount(); - } - - public int getBlockSize() { - return blockSize; - } - - public long getStride() { - return stride; - } - - - public CLContext getContext() { - return kernels.getContext(); - } - public CLQueue getQueue() { - return kernels.getQueue(); - } - - public CLMatrix2D blankClone() { - return CLMatrixUtils.createMatrix(getRowCount(), getColumnCount(), elementType, getKernels()); - } - - public Class getPrimitiveClass() { - throw new UnsupportedOperationException("Not supported yet."); - } - - public CLMatrix2D blankMatrix(long rows, long columns) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public void write(Pointer b) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public void read(Pointer b) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public Pointer read() { - throw new UnsupportedOperationException("Not supported yet."); - } -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/DirectNIODenseDoubleMatrix2D.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/DirectNIODenseDoubleMatrix2D.java deleted file mode 100644 index fb491d4e..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/DirectNIODenseDoubleMatrix2D.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.blas.CLKernels; -import org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix2D; -import org.ujmp.core.interfaces.Wrapper; - -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - -/** - * - * @author ochafik - */ -public class DirectNIODenseDoubleMatrix2D extends AbstractDenseDoubleMatrix2D { - - /** - * - */ - private static final long serialVersionUID = 8936390922363132043L; - final Pointer data; - final long rows, columns; - - public DirectNIODenseDoubleMatrix2D(Pointer data, long rows, long columns) { - this.rows = rows; - this.columns = columns; - this.data = data; - } - - public DirectNIODenseDoubleMatrix2D(long rows, long columns) { - this(allocateDoubles(rows * columns).order(CLKernels.getInstance().getContext().getKernelsDefaultByteOrder()), rows, columns); - } - - public DirectNIODenseDoubleMatrix2D(long[] size) { - this(size[0], size[1]); - if (size.length != 2) - throw new IllegalArgumentException("Size is not 2D !"); - } - - - public Pointer getData() { - return data; - } - - public Pointer getReadableData() { - return getData(); - } - - - public Pointer getWritableData() { - return getData(); - } - - public long[] getSize() { - return new long[] { rows, columns }; - } - - public double getDouble(long row, long column) { - return data.getDoubleAtOffset((row * columns + column) << 3); - } - - @Override - public void setDouble(double value, long row, long column) { - data.setDoubleAtOffset((row * columns + column) << 3, value); - } - - @Override - public double getDouble(int row, int column) { - return getDouble((long)row, column); - } - - @Override - public void setDouble(double value, int row, int column) { - setDouble(value, (long)row, column); - } -} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/DirectNIODenseDoubleMatrix2DFactory.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/DirectNIODenseDoubleMatrix2DFactory.java deleted file mode 100644 index 62adea17..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/DirectNIODenseDoubleMatrix2DFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import org.ujmp.core.doublematrix.DenseDoubleMatrix2D; -import org.ujmp.core.doublematrix.factory.AbstractDoubleMatrix2DFactory; -import org.ujmp.core.exceptions.MatrixException; - -/** - * - * @author ochafik - */ -public class DirectNIODenseDoubleMatrix2DFactory extends - AbstractDoubleMatrix2DFactory { - private static final long serialVersionUID = 4390694808314618187L; - - - public DenseDoubleMatrix2D dense(long rows, long columns) - throws MatrixException { - return new DirectNIODenseDoubleMatrix2D(rows, columns); - } - -} \ No newline at end of file diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/MatrixUtils.java b/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/MatrixUtils.java deleted file mode 100644 index 20fb75d0..00000000 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/MatrixUtils.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.blas.CLMatrix2D; -import org.ujmp.core.floatmatrix.FloatMatrix2D; -import org.ujmp.core.doublematrix.DoubleMatrix2D; -import org.ujmp.core.matrix.Matrix2D; - -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - -/** - * - * @author ochafik - */ -public class MatrixUtils { - public static void write(double[] b, long stride, DoubleMatrix2D out) { - write(pointerToDoubles(b), stride, out); - } - public static void write(float[] b, long stride, FloatMatrix2D out) { - write(pointerToFloats(b), stride, out); - } - public static void write(Pointer b, long stride, DoubleMatrix2D out) { - long rows = out.getRowCount(), columns = out.getColumnCount(); - if (b.getValidElements() < rows * columns) - throw new IllegalArgumentException("Not enough data in input buffer to write into " + rows + "x" + columns + " matrix (only has " + b.getValidElements() + ")"); - if (out instanceof CLDenseDoubleMatrix2D && stride == ((CLDenseDoubleMatrix2D)out).getStride()) { - CLDenseDoubleMatrix2D mout = (CLDenseDoubleMatrix2D)out; - mout.write(b); - } else { - for (long i = 0; i < rows; i++) { - long offset = i * stride; - for (long j = 0; j < columns; j++) - out.setDouble(b.get(offset + j), i, j); - } - } - } - public static void write(Pointer b, long stride, FloatMatrix2D out) { - long rows = out.getRowCount(), columns = out.getColumnCount(); - if (b.getValidElements() < rows * columns) - throw new IllegalArgumentException("Not enough data in input buffer to write into " + rows + "x" + columns + " matrix (only has " + b.getValidElements() + ")"); - if (out instanceof CLDenseFloatMatrix2D && stride == ((CLDenseFloatMatrix2D)out).getStride()) { - CLDenseFloatMatrix2D mout = (CLDenseFloatMatrix2D)out; - mout.write(b); - } else { - for (long i = 0; i < rows; i++) { - long offset = i * stride; - for (long j = 0; j < columns; j++) - out.setFloat(b.get(offset + j), i, j); - } - } - } - - public static Pointer read(DoubleMatrix2D m) { - return read(m, m.getColumnCount()); - } - public static Pointer read(DoubleMatrix2D m, long stride) { - Pointer buffer = allocateDoubles(stride * m.getRowCount()).order(CLKernels.getInstance().getContext().getKernelsDefaultByteOrder()); - read(m, buffer, stride); - return buffer; - } - public static void read(Matrix2D m, Pointer out, long stride) { - if (m instanceof DoubleMatrix2D) - read((DoubleMatrix2D)m, (Pointer)out, stride); - else if (m instanceof FloatMatrix2D) - read((FloatMatrix2D)m, (Pointer)out, stride); - else - throw new UnsupportedOperationException("Can only read DoubleMatrix2D into DoubleBuffer for now"); - } - public static void read(DoubleMatrix2D m, Pointer out, long stride) { - long rows = m.getRowCount(), columns = m.getColumnCount(); - if (out.getValidElements() < rows * columns) - throw new IllegalArgumentException("Not enough space in output buffer to read into " + rows + "x" + columns + " matrix (only has " + out.getValidElements() + ")"); - - if (m instanceof CLDenseDoubleMatrix2D && stride == ((CLDenseDoubleMatrix2D)m).getStride()) { - CLDenseDoubleMatrix2D mm = (CLDenseDoubleMatrix2D)m; - mm.read(out); - } else { - for (long i = 0; i < rows; i++) { - long offset = i * stride; - for (long j = 0; j < columns; j++) { - out.set(offset + j, m.getDouble(i, j)); - } - } - } - } - - public static Pointer read(FloatMatrix2D m, long stride) { - Pointer buffer = allocateFloats(stride * m.getRowCount()).order(CLKernels.getInstance().getContext().getKernelsDefaultByteOrder()); - read(m, buffer, stride); - return buffer; - } - public static void read(FloatMatrix2D m, Pointer out, long stride) { - long rows = m.getRowCount(), columns = m.getColumnCount(); - if (out.getValidElements() < rows * columns) - throw new IllegalArgumentException("Not enough space in output buffer to read into " + rows + "x" + columns + " matrix (only has " + out.getValidElements() + ")"); - - if (m instanceof CLDenseFloatMatrix2D && stride == ((CLDenseFloatMatrix2D)m).getStride()) { - CLDenseFloatMatrix2D mm = (CLDenseFloatMatrix2D)m; - mm.read(out); - } else { - for (long i = 0; i < rows; i++) { - long offset = i * stride; - for (long j = 0; j < columns; j++) { - out.set(offset + j, m.getFloat(i, j)); - } - } - } - } -} diff --git a/Blas/src/test/java/com/nativelibs4java/opencl/blas/CLMatrixUtilsTest.java b/Blas/src/test/java/com/nativelibs4java/opencl/blas/CLMatrixUtilsTest.java deleted file mode 100644 index 20252ea0..00000000 --- a/Blas/src/test/java/com/nativelibs4java/opencl/blas/CLMatrixUtilsTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.nativelibs4java.opencl.blas; - -import static com.nativelibs4java.opencl.blas.CLMatrixUtils.roundUp; -import static org.junit.Assert.*; - -import org.junit.Test; -/** - * - * @author ochafik - */ - -public class CLMatrixUtilsTest { - - @Test - public void testRoundUp() { - assertEquals(0, roundUp(0, 16)); - assertEquals(16, roundUp(1, 16)); - assertEquals(16, roundUp(16, 16)); - assertEquals(32, roundUp(17, 16)); - } -} diff --git a/Blas/src/test/java/com/nativelibs4java/opencl/blas/ujmp/PerformanceTest.java b/Blas/src/test/java/com/nativelibs4java/opencl/blas/ujmp/PerformanceTest.java deleted file mode 100644 index 85adee2a..00000000 --- a/Blas/src/test/java/com/nativelibs4java/opencl/blas/ujmp/PerformanceTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.blas.ujmp; - -import com.nativelibs4java.opencl.CLDevice; -import org.ujmp.core.calculation.Calculation.Ret; -import org.ujmp.core.floatmatrix.impl.DefaultDenseFloatMatrix2D; -import org.ujmp.core.Matrix; -import com.nativelibs4java.util.Pair; -import com.nativelibs4java.opencl.blas.CLKernels; -import com.nativelibs4java.opencl.JavaCL; -import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; -import java.io.IOException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author ochafik - */ -public class PerformanceTest { - - public PerformanceTest() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Test - public void testGPUPerfFloat() throws IOException { - //CLKernels.setInstance(new CLKernels(JavaCL.createBestContext(DeviceFeature.GPU).createDefaultQueue())); - - //int size = 100; - - for (int size : new int[] { 10, 50, 100/*, 200, 400*/ }) { - - DefaultDenseFloatMatrix2D mJava = new DefaultDenseFloatMatrix2D(size, size); - Matrix pJava = testPerf("Java(size = " + size +")", mJava).getValue(); - - for (DeviceFeature feat : new DeviceFeature[] { DeviceFeature.CPU, DeviceFeature.GPU }) { - CLKernels.setInstance(new CLKernels(JavaCL.createBestContext(feat).createDefaultQueue())); - CLDevice device = CLKernels.getInstance().getQueue().getDevice(); - - CLDenseFloatMatrix2D mCL = new CLDenseFloatMatrix2D(size, size); - Matrix pCL = testPerf("OpenCL(size = " + size +", device = " + device + ")", mCL).getValue(); - - assertEquals(pJava, pCL); - } - } - } - - interface Action { - V perform(); - } - - private Pair testMillis(String title, Action action) { - int times = 10; - double total = 0; - V v = null; - for (int i = 0; i <= times; i++) { - long start = System.nanoTime(); - v = action.perform(); - double time = (System.nanoTime() - start) / 1000000.0; - if (i > 0) // skip first value (rough warmup) - total += time; - } - double avg = total / times; - System.out.println("Time[ " + title + " ] = " + avg + " ms"); - return new Pair(avg, v); - } - - private Pair testPerf(String title, final Matrix _m) { - final int pow = 100; - - System.out.println(); - testMillis("svd(" + title + ")", new Action() { - final Matrix m = _m.copy(); - public Void perform() { - Matrix[] svd = m.svd(); - for (Matrix s : svd) - s.getAsDouble(0, 0); - return null; - } - }); - - testMillis("sq(" + title + ")", new Action() { - final Matrix m = _m.copy(); - public Matrix perform() { - Matrix sq = m.mtimes(Ret.NEW, true, m); - sq.getAsDouble(0, 0); - return sq; - } - }); - - testMillis("add(" + title + ")", new Action() { - final Matrix m = _m.copy(); - public Matrix perform() { - Matrix mm = m.plus(Ret.ORIG, true, m).plus(Ret.ORIG, true, m).plus(Ret.ORIG, true, m).plus(Ret.ORIG, true, m); - mm.getAsDouble(0, 0); - return mm; - } - }); - - testMillis("sin(" + title + ")", new Action() { - final Matrix m = _m.copy(); - public Matrix perform() { - Matrix mm = m.sin(Ret.ORIG); - mm.getAsDouble(0, 0); - return mm; - } - }); - - testMillis("transpose(" + title + ")", new Action() { - final Matrix m = _m.copy(); - public Matrix perform() { - Matrix sq = m.transpose(Ret.ORIG).transpose(Ret.ORIG).transpose(Ret.ORIG).transpose(Ret.ORIG); - sq.getAsDouble(0, 0); - return sq; - } - }); - - return testMillis("pow(" + title + ", " + pow + ")", new Action() { - final Matrix m = _m.copy(); - public Matrix perform() { - Matrix power = m; - for (int i = 1; i < pow; i++) - power.mtimes(Ret.ORIG, true, m); - //Matrix power = m.power(Ret.NEW, pow); - power.getAsDouble(0, 0); - return power; - } - }); - } -} diff --git a/Blas/src/test/java/com/nativelibs4java/opencl/blas/ujmp/UJMPOpenCLTest.java b/Blas/src/test/java/com/nativelibs4java/opencl/blas/ujmp/UJMPOpenCLTest.java deleted file mode 100644 index e00e8f2b..00000000 --- a/Blas/src/test/java/com/nativelibs4java/opencl/blas/ujmp/UJMPOpenCLTest.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.nativelibs4java.opencl.blas.ujmp; - -import java.io.IOException; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.JavaCL; -import com.nativelibs4java.opencl.blas.CLKernels; -import static com.nativelibs4java.opencl.blas.ujmp.MatrixUtils.read; -import static com.nativelibs4java.opencl.blas.ujmp.MatrixUtils.write; -import com.nativelibs4java.util.Pair; -import static org.junit.Assert.*; - -import static java.lang.Math.*; - -import org.junit.Before; -import org.junit.Test; -import org.ujmp.core.Matrix; -import org.ujmp.core.MatrixFactory; -import org.ujmp.core.calculation.Calculation.Ret; -import org.ujmp.core.doublematrix.DenseDoubleMatrix2D; -import org.ujmp.core.doublematrix.impl.DefaultDenseDoubleMatrix2D; -import org.ujmp.core.floatmatrix.DenseFloatMatrix2D; -import org.ujmp.core.floatmatrix.FloatMatrix2D; -import org.ujmp.core.floatmatrix.impl.DefaultDenseFloatMatrix2D; -import org.ujmp.core.mapper.MatrixMapper; -/** - * - * @author ochafik - */ - -public class UJMPOpenCLTest { - CLDenseDoubleMatrix2DFactory doubleFactory = new CLDenseDoubleMatrix2DFactory(); - CLDenseFloatMatrix2DFactory floatFactory = new CLDenseFloatMatrix2DFactory(); - - @Before - public void installUJMPCL() { - try { - MatrixMapper.getInstance().setDenseFloatMatrix2DClassName(CLDenseFloatMatrix2D.class.getName()); - MatrixMapper.getInstance().setDenseDoubleMatrix2DClass(CLDenseDoubleMatrix2D.class); - } catch (Exception ex) { - ex.printStackTrace(); - throw new RuntimeException(ex); - } - } - - @Test - public void testInstalledUJMPCL() { - Matrix m = MatrixFactory.dense(1, 1); - assertTrue(m instanceof CLDenseDoubleMatrix2D); - } - - @Test - public void testOp2() { - - DenseFloatMatrix2D a = floatFactory.dense(2, 2); - DenseFloatMatrix2D b = floatFactory.dense(2, 2); - - float[] fa = new float[] { 10, 20, 30, 40 }, fb = new float[] { 1, 2, 3, 4 }; - write(fa, a.getColumnCount(), a); - write(fb, b.getColumnCount(), b); - - assertArrayEquals("failed plus", new float[] { 11, 22, 33, 44 }, read((FloatMatrix2D)a.plus(b), a.getColumnCount()).getFloats(), 0); - assertArrayEquals("failed minus", new float[] { 9, 18, 27, 36 }, read((FloatMatrix2D)a.minus(b), a.getColumnCount()).getFloats(), 0); - assertArrayEquals("failed times", new float[] { 10, 40, 90, 160 }, read((FloatMatrix2D)a.times(b), b.getColumnCount()).getFloats(), 0); - assertArrayEquals("failed divide", new float[] { 10, 10, 10, 10 }, read((FloatMatrix2D)a.divide(b), a.getColumnCount()).getFloats(), 0); - - assertArrayEquals("failed scalar plus", new float[] { 11, 21, 31, 41 }, read((FloatMatrix2D)a.plus(1), a.getColumnCount()).getFloats(), 0); - assertArrayEquals("failed scalar minus", new float[] { 9, 19, 29, 39 }, read((FloatMatrix2D)a.minus(1), a.getColumnCount()).getFloats(), 0); - assertArrayEquals("failed scalar times", new float[] { 20, 40, 60, 80 }, read((FloatMatrix2D)a.times(2), b.getColumnCount()).getFloats(), 0); - assertArrayEquals("failed scalar divide", new float[] { 1, 2, 3, 4 }, read((FloatMatrix2D)a.divide(10), a.getColumnCount()).getFloats(), 0); - - assertArrayEquals("failed sin", new float[] { (float)sin(fa[0]), (float)sin(fa[1]), (float)sin(fa[2]), (float)sin(fa[3]) }, - read((FloatMatrix2D)a.sin(Ret.NEW), a.getColumnCount()).getFloats(), 0.0001f); - assertArrayEquals("failed cos", new float[] { (float)cos(fa[0]), (float)cos(fa[1]), (float)cos(fa[2]), (float)cos(fa[3]) }, - read((FloatMatrix2D)a.cos(Ret.NEW), a.getColumnCount()).getFloats(), 0.0001f); - assertArrayEquals("failed tan", new float[] { (float)tan(fa[0]), (float)tan(fa[1]), (float)tan(fa[2]), (float)tan(fa[3]) }, - read((FloatMatrix2D)a.tan(Ret.NEW), a.getColumnCount()).getFloats(), 0.0001f); - - } - - @Test - public void testMultFloat() { - - DenseFloatMatrix2D m = floatFactory.dense(3, 3); - DenseFloatMatrix2D v = floatFactory.dense(3, 1); - //CLBuffer buffer = ((CLDenseFloatMatrix2D)m).getBuffer(); - CLQueue queue = ((CLDenseFloatMatrix2D)m).getImpl().getQueue(); - //System.out.println("Context = " + buffer.getContext()); - - float[] min = new float[] { 0, 0, 1, 0, 1, 0, 1, 0, 0 }; - write(min, m.getColumnCount(), m); - Pointer back = read(m, m.getColumnCount()); - for (int i = 0, cap = (int)back.getValidElements(); i < cap; i++) { - assertEquals(min[i], back.get(i), 0); - //System.out.println(back.get(i)); - } - - queue.finish(); - DenseFloatMatrix2D mout = (DenseFloatMatrix2D) m.mtimes(m); - queue.finish(); - - //System.out.println("m = \n" + m); - //System.out.println("mout = \n" + mout); - - //if (la instanceof CLLinearAlgebra) - // ((CLLinearAlgebra)la).queue.finish(); - //dmout.write((FloatBuffer)mout.read()); - - back = read(mout, mout.getColumnCount()); - //for (int i = 0, cap = (int)back.getValidElements(); i < cap; i++) - // System.out.println(back.get(i)); - - assertEquals(0, mout.getFloat(0, 1), 0); - assertEquals(0, mout.getFloat(1, 0), 0); - - assertEquals(1, mout.getFloat(0, 0), 0); - assertEquals(1, mout.getFloat(1, 1), 0); - assertEquals(1, mout.getFloat(2, 2), 0); - - write(new float[] { 1, 0, 0}, v.getColumnCount(), v); - DenseFloatMatrix2D vout = (DenseFloatMatrix2D)m.mtimes(v); - //System.out.println(v); - //System.out.println(vout); - - assertEquals(0, vout.getFloat(0, 0), 0); - assertEquals(0, vout.getFloat(1, 0), 0); - assertEquals(1, vout.getFloat(2, 0), 0); - } - - @Test - public void testContainsDouble() throws IOException { - - CLKernels.setInstance(new CLKernels()); - - CLDenseDoubleMatrix2D m = (CLDenseDoubleMatrix2D)MatrixFactory.dense(2, 2); - int row = 1, column = 1; - m.setDouble(1.1, row, column); - assertEquals(1.1, m.getDouble(row, column), 0.0); - assertTrue(m.containsDouble(1.1)); - assertTrue(!m.containsDouble(2.0)); - } - - - @Test - public void testContainsFloat() { - CLDenseFloatMatrix2D m = floatFactory.dense(2, 2); - int row = 1, column = 1; - m.setFloat(1.1f, row, column); - assertEquals(1.1f, m.getFloat(row, column), 0.0); - assertTrue(m.containsFloat(1.1f)); - assertTrue(!m.containsFloat(2.0f)); - } - - @Test - public void testClearFloat() { - CLDenseFloatMatrix2D m = floatFactory.dense(2, 2); - int row = 0, column = 1; - m.setFloat(1.1f, row, column); - assertEquals(1.1f, m.getFloat(row, column), 0.0); - m.clear(); - assertEquals(0f, m.getFloat(row, column), 0.0); - } - - static void sleep(long millis) { - try { Thread.sleep(millis); } catch (Exception ex) { ex.printStackTrace(); } - } - -} diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 00000000..a54e56c7 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,157 @@ +For future changes, please see CHANGELOG of JavaCL / BridJ version. + +Version 1.0.0-RC1 (r2130, 20110621) + +- BridJ version now becomes the default : the JNA version is still maintained and available with all Maven artifact ids suffixed with "-jna" (BridJ-based JavaCL's main artifact is now "javacl", while the JNA-based version is "javacl-jna") +- added simple Fourier-analysis classes (package com.nativelibs4java.opencl.util.fft), with double and float variants, usable with primitive arrays or OpenCL buffers : + - naive Discrete Fourier Transform (DFT) + - Fast Fourier Transform (FFT) for power-of-two arrays / buffers (performs better than Apache Commons on a CPU) +- added some compiler options to CLProgram : + - setFastRelaxedMath() (triggers all the others !) + - setFiniteMathOnly() + - setUnsafeMathOptimizations() + - setMadEnable() + - setNoSignedZero() +- added CLContext.createBuffer(Usage, Buffer) +- added CLBuffer.copyTo(CLQueue, CLMem destination, CLEvent...) and CLBuffer.emptyClone(Usage) +- added NIOUtils.indirectBuffer(size, bufferClass) +- added CLContext.toString +- deprecated CLXXXBuffer in favor of CLBuffer (CLIntBuffer becomes CLBuffer, etc...) +- changed CLContext.createBuffer(Usage, length, class) to createBuffer(Usage, class, length) to match the JavaCL/BridJ API (and provoke migration issues : people should now use a primitive class rather than an NIO buffer class !!! +- complete rewrite of CLBuffer genericity to unify with the BridJ port : CLBuffer is now CLBuffer, and CLBuffer.read/write/map are no longer strongly typed (it is implicitely typed with Buffer subclasses for compatibility with existing code). The BridJ port will be favoured, and its read/write/map methods use typed Pointer. +- complete rewrite of UJMP Matrix implementation, using principles borrowed from ScalaCL +- fixed issue #66 (create temp files in ~/.javacl subdirectories instead of /tmp) +- fixed OpenGL sharing on MacOS X +- fixed CLProgram.getBinaries() in some cases +- fixed CLBuffer.read on indirect buffers +- fixed NPE that happens with null varargs CLEvent[] array +- fixed length = 1 case in reduction utility +- fixed ATI detection ("ATI Stream" now replaced by "AMD Accelerated Parallel Processing", cf. Csaba's comment in issue #39) +- fixed issue #55 : applied Kazo Csaba's patch to fix the bounds of CLBuffer.map's returned buffer +- fixed inheritance of CLBuildException (now derives from CLException) + +Version 1.0-beta-6 (r1637, 20100204) + +- Fixed support of ATI Stream 2.3 (CPU) +- New interactive image kernel demo : lets you edit and test image kernels in a snap (bundled with a few samples) +- Experimental BridJ port with same functionality as JNA-powered version, but smaller and faster (JAR weighs 750 kB instead of 1.8 MB, overhead per-function call about 10x smaller) +- Added automatic and transparent program binaries caching : + - Disabled by default on ATI Stream. + - Can force on/off with : + - property -Djavacl.cacheBinaries=true/false + - environment variable JAVACL_CACHE_BINARIES=1/0 + - methods CLContext.setCacheBinaries and CLProgram.setCached +- JavaCL.createBestContext now takes an ordered list of CLPlatform.DeviceFeature enums that help prioritize the features considered as "best" (list can be empty or contain any of CPU, GPU, DoubleSupport, MaxComputeUnits, NativeEndianness, ImageSupport, MostImageFormats...). These features are preferences, not requirements : with createBestContext(GPU, MaxComputeUnits) you might end up getting a CPU-based context if there's no GPU available, but you'll have the most powerful GPU (in terms of compute units) if there are two of them. +- Kernels can now include files that are in the classpath (+ added CLProgram.addInclude that accepts directories and base URLs) +- Added LibCL : growing collection of OpenCL functions that can be included from any JavaCL kernel +- CLKernel.enqueueNDRange has a new overload without localWorkSizes argument (it's then adjusted to a good value by the OpenCL implementation). +- ScalaCLv2 was rewritten to fit nicely into Scala's collections framework. +- Added CLContext.createProgram(Map) to create from saved binaries (contribution from Kazo Csaba, issue #30) +- Added CLProgram.addBuildOption(String) +- Fixed CLBuffer.copyTo +- Demos now use the latest jogamp JOGL binaries (see the updated build instructions : http://code.google.com/p/javacl/wiki/Build) + +Version 1.0-beta-5 (r1067, 20100717) + +- Now using a nice configuration dialog when launching ParticlesDemo : has +optional OpenCL settings with "Fastest", "Normal" and "Safest" presets + +detailed platform and device choice (with optional OpenGL sharing choice). +- Added optional context properties map argument to JavaCL.createContext (can be nulled +out) +- Fixed issue #18: CLImage.write calls enqueueImageRead ! +- Documented workaround for Linux crashes (issue #20) : http://code.google.com/p/javacl/wiki/TroubleShootingJavaCLOnLinux +- Fixed issue #21: NIOUtils.put() doesn't accept ByteBuffer +- Fixed issue #25: CLEvent.waitFor bug causes segfault +- OpenCL 1.1 support : + - CLContext.createUserEvent() + - CLUserEvent.setStatus(int), setCompleted() + - CLEvent.setCallback(status, callbac), setCompletionCallback(callback) + - CLBuffer.createSubBuffer(usage, offset, length) + - CLContext.getDeviceCount() + - CLDevice.getOpenCLVersion() + - CLDevice.isHostUnifiedMemory() + - CLDevice.getNativeVectorWidthXXX() methods + - CLMem.setDestructorCallback(callback) + - CLKernel.getPreferredWorkGroupSizeMultiple() + - CLKernel.enqueueNDRange overload with potentially non-null globalOffsets + - CLImageFormat.ChannelOrder.Rx, RGx, RGBx +- Faster enums +- Check for cl_amd_fp64 in CLDevice.isDoubleSupported() +- Fixed CLProgram.getBinaries() +- Fixed issue #22 (maven pom issue) + +Version 1.0-beta-4 (r760, 20100121) + +- Changed semantics of offset & length arguments in typed CLxxxBuffer.read / write / map methods : now expressed in elements, not in bytes (e.g. 4 bytes per element for CLIntBuffer) +- Added OpenGL interoperability methods to CLContext and CLQueue (can create a CLByteBuffer from an OpenGL buffer object, a CLImage2D/3D from an OpenGL 2D/3D texture or a renderbuffer). +- Added OpenGL-compatible context creation methods to JavaCL & CLPlatform classes +- Added basic reduction support in ReductionUtils (cumulative additions, multiplications, min, max...) +- Created javacl-demos package, with Particles, Hardware Report and Mandelbrot demos... +- Finished migration from NativeLong to NativeSize (changes only the low-level bindings) +- Added profiling methods to CLEvent (+ facility CLDevice.createProfilingQueue()) +- Better JavaDoc for low-level bindings (links to Khronos online manual pages) +- Added deferred program allocation : CLProgram.addSource(String), CLProgram.allocate() (called automatically)... +- Added very simple OpenCL backend for UJMP (Universal Java Matrix Package), which does matrix multiplications in OpenCL. +- Created a kernel wrapper autogenerator (Maven plugin based on JNAerator) : translates all constants on the Java side and presents kernels as methods with the correct Java argument types. It assumes OpenCL kernels (*.c, *.cl) are in src/main/opencl +- Added wrappers around clGetKernelWorkGroupInfo +- Fixed respect of endianness of devices that have different endianness than platform +- Fixed issue #10: "getMaxWorkItemSizes() fails on win7 64 GTX260" + +Version 1.0-beta-3 (r , 20091030) + +- Fixed Issue #8 : NativeLong's can not represent size_t on windows x64 system (all user code that uses the low-level bindings needs to be updated : NativeLong -> NativeSize) +- Added CLContext/CLDevice.isDoubleSupported, isHalfSupported, isByteAddressableStoreSupported +- Added If function to ScalaCL (operates on statements or on expressions) +- Added CLAbstractEntity.release() +- Fixed Issue #4 : CLContext.createContext(CLDevice... devices) created context on only one device +- Regenerated the low level bindings with latest JNAerator : now using NativeSize class instead of NativeLong for size_t (fixes Issue #8) +- Fixed Issue #5 : fixed formatting of CLPlatform.toString() +- Fixed Issue #6 : use max X workgroup dimension for better benchmark speed +- Fixed Issue #7 : CLMem class bug in Usage.WriteOnly and Usage.ReadWrite +- Fixed Issue #11 : call clRetainMemObject when sharing a cl_mem between CLBuffer instances. +- Choose 'best' device in benchmark test + +Version 1.0-beta-2 + +- JAR is now self-sufficient (includes JNA + JNAerator's runtime classes) +- Added CLKernel.setLocalArg(argIndex, localArgByteLength) +- Allow localWorkSizes to be null in enqueueNDRange +- Added support for barriers and markers in CLQueue +- Fixed issue #2 : enqueueNDRange does not work for nDim > 1 +- Added CLDevice.getMaxWorkItemSizes() +- CLDevice.toString() now only prints the name +- Moved method createContext from CLContext to CLPlatform +- Added all the CL_DEVICE_PREFERRED_VECTOR_WIDTH_XXX infos to CLDevice as getPreferredVectorWithXXX() +- Changed return type of getExtensions() method of both CLPlatform and CLDevice from String to String[] +- Added com.nativelibs4java.opencl.HardwareReport (with main method) : outputs html report with devices stats +- Rationalized naming of all enums : CL_ENTITY_ATTRIBUTE_SOME_VALUE = CLEntity.Attribute.SomeValue (enum item SomeValue in enum Attribute in class CLEntity) +- Added full support of images : + - CLContext.getSupportedImageFormats + CLImageFormat and associated enums + - CLImage2D, CLImage3D and corresponding creation methods in CLContext + all image info getters +- CLMem is now an abstract base class + - CLBuffer with typed subclasses (CLByteBuffer, CLIntBuffer..) + - To create a CLBuffer : context.createIntBuffer(Input, size) + - Added CLBuffer.copyTo (clEnqueueCopyBuffer) + - Each typed CLBuffer subclass has map, mapLater, read methods that return typed NIO buffers +- Added full typing of OpenCL Exceptions (now possible to selectively catch a CLException.OutOfHostMemory, for instance) +- Added hashCode and equals method to most classes +- Added ability to create out of order queues and change queue properties after creation + +Version 1.0-beta-1 + +- New CLPlatform class (~ OpenCL implementation) which now hosts the list*Devices(...) methods +- Entry point of library is now OpenCL4Java.listPlatforms() +- New CLEvent class, returned by all enqueue* methods (with methods waitFor, invokeUponCompletion...) +- Better separation between blocking and non blocking calls +- New CLSampler class supported as argument of CLKernel +- Many info getters with typesafe enums / enum sets in classes CLDevice, CLPlatform, CLKernel... +- Much more complete JavaDoc : http://nativelibs4java.sourceforge.net/sites/OpenCL4Java/apidocs/ +- Example & benchmark classes became JUnit tests and moved here : http://code.google.com/p/nativelibs4java/source/browse/#svn/trunk/lib... + +While this release is rather OpenCL4Java-focused, ScalaCL also got its bunch of enhancements : +- Added scalar variables IntVar, FloatVar, ShortVar... +- 'local' keyword can be added to variables so they're local to the programs : val x = FloatVar local +- Added many OpenCL math functions +- Added methods ArrayVar.write(Range), ArrayVar.write(Seq) +- Various bugfixes + diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 36784845..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,278 +0,0 @@ -## Current development version (1.0-SNAPSHOT) - -... - -## Version 1.0.0-RC4 (20150308) - -- Dropped Blas artifact from main deployment (requires addional repo since ujmp is not in Maven Central) -- Dropped support for JNA variant of JavaCL. Migration is highly encouraged to get more features and bugfixes: https://code.google.com/p/javacl/wiki/MigratingFromJNAToBridJ -- Updated to BridJ 0.7 (brings fixes and lots of performance enhancements) -- Optimized allocation of native memory throughout the library (reusing thread-local pointer pools) -- Optimized (CLDevice, CLPlatform).hasExtension -- Added basic handling of structs in JavaCL Generator ([issue nativelibs4java#421] - (https://github.com/nativelibs4java/nativelibs4java/issues/421), [issue nativelibs4java#422] - (https://github.com/nativelibs4java/nativelibs4java/issues/422), [issue nativelibs4java#423] - (https://github.com/nativelibs4java/nativelibs4java/issues/423)) -- Added CLBuffer.copyTo, .copyBytesTo, .copyElementsTo -- Added CLBuffer.fillBuffer to support OpenCL 1.2 clEnqueueFillBuffer ([issue nativelibs4java#232] - (https://github.com/nativelibs4java/nativelibs4java/issues/232)) -- Added CLDevice.getParent() -- Added CLDevice.getPrintfBufferSize(), .isPreferredInteropUserSync(), .isLinkerAvailable() -- Added CLImage.copyTo ([issue nativelibs4java#508] - (https://github.com/nativelibs4java/nativelibs4java/issues/508)) -- Added CLImage.fillImage ([issue nativelibs4java#232] - (https://github.com/nativelibs4java/nativelibs4java/issues/232)) -- Added CLPlatform.unloadPlatformCompiler() with automatic switch between OpenCL 1.1 clUnloadCompiler and OpenCL 1.2 clUnloadPlatformCompiler ([issue nativelibs4java#232] - (https://github.com/nativelibs4java/nativelibs4java/issues/232)) -- Added CLQueue.enqueueBarrier & .enqueueMarker to support clEnqueueBarrierWithWaitList & clEnqueueMarkerWithWaitList (switching between OpenCL 1.1 and OpenCL 1.2 variants automatically) ([issue nativelibs4java#232] - (https://github.com/nativelibs4java/nativelibs4java/issues/232)) -- Added CLQueue.enqueueMigrateMemObjects ([issue nativelibs4java#232] - (https://github.com/nativelibs4java/nativelibs4java/issues/232)) -- Added JAVACL_LOG_CALLS=1 / -Djavacl.logCalls=true to log every native call (similar to BRIDJ_LOG_CALLS except it prints the parameter and return values) -- Added many missing CLDevice 1.2 info getters ([issue nativelibs4java#232] - (https://github.com/nativelibs4java/nativelibs4java/issues/232)), -- Added MapFlags.WriteInvalidateRegion (CL_MAP_WRITE_INVALIDATE_REGION from OpenCL 1.2) ([issue nativelibs4java#232] - (https://github.com/nativelibs4java/nativelibs4java/issues/232)) -- Fixed crash in CLPlatform.getBinaries() -- Fixed excessive logs for deprecated features and missing OpenCL 1.1 and 1.2 functions (especially if version < deprecatedVersion) -- Fixed [issue nativelibs4java#387] - (https://github.com/nativelibs4java/nativelibs4java/issues/387): don't call clReleaseDevice (OpenCL 1.2) unless explicitly needed -- Fixed [issue nativelibs4java#397] - (https://github.com/nativelibs4java/nativelibs4java/issues/397): crash on Radeon due to bug in driver (attempts to get the source from a program created with clCreateProgramWithBinary yields a segfault) -- Fixed [issue nativelibs4java#397] - (https://github.com/nativelibs4java/nativelibs4java/issues/397): major bug in CLProgram -- Fixed [issue nativelibs4java#420] - (https://github.com/nativelibs4java/nativelibs4java/issues/420): horrible random native crash (double release, found with new -Dbridj.debug.pointer.releases=true). -- Fixed [issue nativelibs4java#453] - (https://github.com/nativelibs4java/nativelibs4java/issues/453): don't try to load cached binaries for programs created from binaries! -- Fixed [issue nativelibs4java#455] - (https://github.com/nativelibs4java/nativelibs4java/issues/455): when reading binaries, skip devices that are not allowed -- Fixed [issue nativelibs4java#479] - (https://github.com/nativelibs4java/nativelibs4java/issues/479): avoid some NPEs in CLProgram.getProgramBuildInfo -- Fixed typo: CLDevice.getOpenCLVersion -> getOpenCLCVersion - -## Version 1.0.0-RC3 (20130107) - -- Fixed nasty regression in getBestDevice ! -- Fixed ati byte order hack -- Fixed byte order hack for ATI platforms -- Fixes / optimized event callbacks (but broke API: CLEvent.EventCallback now only takes the completion status as argument, not the event anymore) -- Fixed library probe -- Fixed handling of image2d_t and image3d_t in Maven plugin (contrib. from Remi Emonet, request #308 and [issue nativelibs4java#307] - (https://github.com/nativelibs4java/nativelibs4java/issues/307)) -- Fixed OpenGL interop on Windows ([issue nativelibs4java#312] - (https://github.com/nativelibs4java/nativelibs4java/issues/312)) -- Fixed error about mismatching byte order for byte buffers, and replaced mentions to getKernelsDefaultByteOrder() by getByteOrder() ([issue nativelibs4java#336] - (https://github.com/nativelibs4java/nativelibs4java/issues/336)) -- Fixed AMD App 2.7 Linux library loading code for -- Fixed AMD download link in demos. -- Added CLEvent.FIRE_AND_FORGET to avoid returning events from all the methods that accept a vararg eventsToWaitFor. -- Added naive OSGi support to the main JAR. -- Added list of devices in program errors. -- Added CLBuffer.allocateCompatibleMemory(CLDevice) -- Added client properties to CLContext (lazy + concurrent) -- Optimized low-level bindings on OpenCL 1.1+ platforms, with dynamic runtime switch (removed synchronized keyword from all native calls), and made OpenCL 1.0 synchronization a warning. -- Enhanced CLDevice.toString (include platform name) -- Deprecated CLKernel.enqueueNDRange with int[] parameters -- Return CLUserEvent from CLContext.createUserEvent(); - -## Version 1.0.0-RC2 (20120415, commit 6bc061dfce06b941086a29f696195e82fbaffbdc) - -- Release artifacts are available in Maven Central -- Added support for sub-images reading/writing from/to CLImage2D (slower than with full images) -- Fixed endianness issues with CLBuffer ([issue nativelibs4java#80] - (https://github.com/nativelibs4java/nativelibs4java/issues/80)) -- Fixed migration of cached binaries to newer versions of OS (e.g. upgrading from Snow Leopard to Lion) ([issue nativelibs4java#81] - (https://github.com/nativelibs4java/nativelibs4java/issues/81)) -- Fixed handling compiler options containing spaces ([issue nativelibs4java#274] - (https://github.com/nativelibs4java/nativelibs4java/issues/274)) -- Fixed tutorial artifact pom repositories ([issue nativelibs4java#279] - (https://github.com/nativelibs4java/nativelibs4java/issues/279)) -- Fixed many Javadoc typos -- Fixed support of Intel's OpenCL Windows runtime ([issue nativelibs4java#297] - (https://github.com/nativelibs4java/nativelibs4java/issues/297)) -- Enhanced LocalSize API (added static factory methods for all primitive types) -- Deprecated CLContext.getKernelsDefaultByteOrder() and CLDevice.getKernelsDefaultByteOrder() -- Added more informative exceptions when passing null pointers to CLBuffer.writeBytes ([issue nativelibs4java#257] - (https://github.com/nativelibs4java/nativelibs4java/issues/257)) -- Updated to OpenCL 1.2 headers -- Added -cl-nv-verbose, -cl-nv-maxrregcount, -cl-nv-opt-level + proper log even without error when nv-verbose is set -- Enhanced handling of endianness : warn when creating contexts with devices that have mismatching endianness, throw when creating buffer out of Buffer / Pointer with bad endianness -- Changed signature of CLPlatform.listDevices (now takes a single CLDevice.Type, including All, instead of an EnumSet thereof) -- Moved sources to github (https://github.com/ochafik/nativelibs4java/tree/master/libraries/OpenCL) - -## Version 1.0.0-RC1 (r2130, 20110621) - -- BridJ version now becomes the default : the JNA version is still maintained and available with all Maven artifact ids suffixed with "-jna" (BridJ-based JavaCL's main artifact is now "javacl", while the JNA-based version is "javacl-jna") -- added simple Fourier-analysis classes (package com.nativelibs4java.opencl.util.fft), with double and float variants, usable with primitive arrays or OpenCL buffers : - - naive Discrete Fourier Transform (DFT) - - Fast Fourier Transform (FFT) for power-of-two arrays / buffers (performs better than Apache Commons on a CPU) -- added some compiler options to CLProgram : - - setFastRelaxedMath() (triggers all the others !) - - setFiniteMathOnly() - - setUnsafeMathOptimizations() - - setMadEnable() - - setNoSignedZero() -- added CLContext.createBuffer(Usage, Buffer) -- added CLBuffer.copyTo(CLQueue, CLMem destination, CLEvent...) and CLBuffer.emptyClone(Usage) -- added NIOUtils.indirectBuffer(size, bufferClass) -- added CLContext.toString -- deprecated CLXXXBuffer in favor of CLBuffer<XXX> (CLIntBuffer becomes CLBuffer, etc...) -- changed CLContext.createBuffer(Usage, length, class) to createBuffer(Usage, class, length) to match the JavaCL/BridJ API (and provoke migration issues : people should now use a primitive class rather than an NIO buffer class !!! -- complete rewrite of CLBuffer genericity to unify with the BridJ port : CLBuffer<DoubleBuffer> is now CLBuffer, and CLBuffer.read/write/map are no longer strongly typed (it is implicitely typed with Buffer subclasses for compatibility with existing code). The BridJ port will be favoured, and its read/write/map methods use typed Pointer. -- complete rewrite of UJMP Matrix implementation, using principles borrowed from ScalaCL -- fixed [issue nativelibs4java#66] - (https://github.com/nativelibs4java/nativelibs4java/issues/66) (create temp files in ~/.javacl subdirectories instead of /tmp) -- fixed OpenGL sharing on MacOS X -- fixed CLProgram.getBinaries() in some cases -- fixed CLBuffer.read on indirect buffers -- fixed NPE that happens with null varargs CLEvent[] array -- fixed length = 1 case in reduction utility -- fixed ATI detection ("ATI Stream" now replaced by "AMD Accelerated Parallel Processing", cf. Csaba's comment in [issue nativelibs4java#39] - (https://github.com/nativelibs4java/nativelibs4java/issues/39)) -- fixed [issue nativelibs4java#55] - (https://github.com/nativelibs4java/nativelibs4java/issues/55) : applied Kazo Csaba's patch to fix the bounds of CLBuffer.map's returned buffer -- fixed inheritance of CLBuildException (now derives from CLException) - -## Version 1.0-beta-6 (r1637, 20100204) - -- Fixed support of ATI Stream 2.3 (CPU) -- New interactive image kernel demo : lets you edit and test image kernels in a snap (bundled with a few samples) -- Experimental BridJ port with same functionality as JNA-powered version, but smaller and faster (JAR weighs 750 kB instead of 1.8 MB, overhead per-function call about 10x smaller) -- Added automatic and transparent program binaries caching : - - Disabled by default on ATI Stream. - - Can force on/off with : - - property -Djavacl.cacheBinaries=true/false - - environment variable JAVACL_CACHE_BINARIES=1/0 - - methods CLContext.setCacheBinaries and CLProgram.setCached -- JavaCL.createBestContext now takes an ordered list of CLPlatform.DeviceFeature enums that help prioritize the features considered as "best" (list can be empty or contain any of CPU, GPU, DoubleSupport, MaxComputeUnits, NativeEndianness, ImageSupport, MostImageFormats...). These features are preferences, not requirements : with createBestContext(GPU, MaxComputeUnits) you might end up getting a CPU-based context if there's no GPU available, but you'll have the most powerful GPU (in terms of compute units) if there are two of them. -- Kernels can now include files that are in the classpath (+ added CLProgram.addInclude that accepts directories and base URLs) -- Added LibCL : growing collection of OpenCL functions that can be included from any JavaCL kernel -- CLKernel.enqueueNDRange has a new overload without localWorkSizes argument (it's then adjusted to a good value by the OpenCL implementation). -- ScalaCLv2 was rewritten to fit nicely into Scala's collections framework. -- Added CLContext.createProgram(Map<CLDevice, byte[]>) to create from saved binaries (contribution from Kazo Csaba, [issue nativelibs4java#30] - (https://github.com/nativelibs4java/nativelibs4java/issues/30)) -- Added CLProgram.addBuildOption(String) -- Fixed CLBuffer.copyTo -- Demos now use the latest jogamp JOGL binaries (see the updated build instructions : [http://code.google.com/p/javacl/wiki/Build) -](http://code.google.com/p/javacl/wiki/Build) -) -## Version 1.0-beta-5 (r1067, 20100717) - -- Now using a nice configuration dialog when launching ParticlesDemo : has -optional OpenCL settings with "Fastest", "Normal" and "Safest" presets + -detailed platform and device choice (with optional OpenGL sharing choice). -- Added optional context properties map argument to JavaCL.createContext (can be nulled -out) -- Fixed [issue nativelibs4java#18] - (https://github.com/nativelibs4java/nativelibs4java/issues/18): CLImage.write calls enqueueImageRead ! -- Documented workaround for Linux crashes ([issue nativelibs4java#20] - (https://github.com/nativelibs4java/nativelibs4java/issues/20)) : [http://code.google.com/p/javacl/wiki/TroubleShootingJavaCLOnLinux -](http://code.google.com/p/javacl/wiki/TroubleShootingJavaCLOnLinux -)- Fixed [issue nativelibs4java#21] - (https://github.com/nativelibs4java/nativelibs4java/issues/21): NIOUtils.put() doesn't accept ByteBuffer -- Fixed [issue nativelibs4java#25] - (https://github.com/nativelibs4java/nativelibs4java/issues/25): CLEvent.waitFor bug causes segfault -- OpenCL 1.1 support : - - CLContext.createUserEvent() - - CLUserEvent.setStatus(int), setCompleted() - - CLEvent.setCallback(status, callbac), setCompletionCallback(callback) - - CLBuffer.createSubBuffer(usage, offset, length) - - CLContext.getDeviceCount() - - CLDevice.getOpenCLVersion() - - CLDevice.isHostUnifiedMemory() - - CLDevice.getNativeVectorWidthXXX() methods - - CLMem.setDestructorCallback(callback) - - CLKernel.getPreferredWorkGroupSizeMultiple() - - CLKernel.enqueueNDRange overload with potentially non-null globalOffsets - - CLImageFormat.ChannelOrder.Rx, RGx, RGBx -- Faster enums -- Check for cl_amd_fp64 in CLDevice.isDoubleSupported() -- Fixed CLProgram.getBinaries() -- Fixed [issue nativelibs4java#22] - (https://github.com/nativelibs4java/nativelibs4java/issues/22) (maven pom issue) - -## Version 1.0-beta-4 (r760, 20100121) - -- Changed semantics of offset & length arguments in typed CLxxxBuffer.read / write / map methods : now expressed in elements, not in bytes (e.g. 4 bytes per element for CLIntBuffer) -- Added OpenGL interoperability methods to CLContext and CLQueue (can create a CLByteBuffer from an OpenGL buffer object, a CLImage2D/3D from an OpenGL 2D/3D texture or a renderbuffer). -- Added OpenGL-compatible context creation methods to JavaCL & CLPlatform classes -- Added basic reduction support in ReductionUtils (cumulative additions, multiplications, min, max...) -- Created javacl-demos package, with Particles, Hardware Report and Mandelbrot demos... -- Finished migration from NativeLong to NativeSize (changes only the low-level bindings) -- Added profiling methods to CLEvent (+ facility CLDevice.createProfilingQueue()) -- Better JavaDoc for low-level bindings (links to Khronos online manual pages) -- Added deferred program allocation : CLProgram.addSource(String), CLProgram.allocate() (called automatically)... -- Added very simple OpenCL backend for UJMP (Universal Java Matrix Package), which does matrix multiplications in OpenCL. -- Created a kernel wrapper autogenerator (Maven plugin based on JNAerator) : translates all constants on the Java side and presents kernels as methods with the correct Java argument types. It assumes OpenCL kernels (*.c, *.cl) are in src/main/opencl -- Added wrappers around clGetKernelWorkGroupInfo -- Fixed respect of endianness of devices that have different endianness than platform -- Fixed [issue nativelibs4java#10] - (https://github.com/nativelibs4java/nativelibs4java/issues/10): "getMaxWorkItemSizes() fails on win7 64 GTX260" - -## Version 1.0-beta-3 (r , 20091030) - -- Fixed [Issue nativelibs4java#8] - (https://github.com/nativelibs4java/nativelibs4java/issues/8) : NativeLong's can not represent size_t on windows x64 system (all user code that uses the low-level bindings needs to be updated : NativeLong -&gt; NativeSize) -- Added CLContext/CLDevice.isDoubleSupported, isHalfSupported, isByteAddressableStoreSupported -- Added If function to ScalaCL (operates on statements or on expressions) -- Added CLAbstractEntity.release() -- Fixed [Issue nativelibs4java#4] - (https://github.com/nativelibs4java/nativelibs4java/issues/4) : CLContext.createContext(CLDevice... devices) created context on only one device -- Regenerated the low level bindings with latest JNAerator : now using NativeSize class instead of NativeLong for size_t (fixes [Issue nativelibs4java#8] - (https://github.com/nativelibs4java/nativelibs4java/issues/8)) -- Fixed [Issue nativelibs4java#5] - (https://github.com/nativelibs4java/nativelibs4java/issues/5) : fixed formatting of CLPlatform.toString() -- Fixed [Issue nativelibs4java#6] - (https://github.com/nativelibs4java/nativelibs4java/issues/6) : use max X workgroup dimension for better benchmark speed -- Fixed [Issue nativelibs4java#7] - (https://github.com/nativelibs4java/nativelibs4java/issues/7) : CLMem class bug in Usage.WriteOnly and Usage.ReadWrite -- Fixed [Issue nativelibs4java#11] - (https://github.com/nativelibs4java/nativelibs4java/issues/11) : call clRetainMemObject when sharing a cl_mem between CLBuffer instances. -- Choose 'best' device in benchmark test - -## Version 1.0-beta-2 - -- JAR is now self-sufficient (includes JNA + JNAerator's runtime classes) -- Added CLKernel.setLocalArg(argIndex, localArgByteLength) -- Allow localWorkSizes to be null in enqueueNDRange -- Added support for barriers and markers in CLQueue -- Fixed [issue nativelibs4java#2] - (https://github.com/nativelibs4java/nativelibs4java/issues/2) : enqueueNDRange does not work for nDim > 1 -- Added CLDevice.getMaxWorkItemSizes() -- CLDevice.toString() now only prints the name -- Moved method createContext from CLContext to CLPlatform -- Added all the CL_DEVICE_PREFERRED_VECTOR_WIDTH_XXX infos to CLDevice as getPreferredVectorWithXXX() -- Changed return type of getExtensions() method of both CLPlatform and CLDevice from String to String[] -- Added com.nativelibs4java.opencl.HardwareReport (with main method) : outputs html report with devices stats -- Rationalized naming of all enums : CL_ENTITY_ATTRIBUTE_SOME_VALUE = CLEntity.Attribute.SomeValue (enum item SomeValue in enum Attribute in class CLEntity) -- Added full support of images : - - CLContext.getSupportedImageFormats + CLImageFormat and associated enums - - CLImage2D, CLImage3D and corresponding creation methods in CLContext + all image info getters -- CLMem is now an abstract base class - - CLBuffer with typed subclasses (CLByteBuffer, CLIntBuffer..) - - To create a CLBuffer : context.createIntBuffer(Input, size) - - Added CLBuffer.copyTo (clEnqueueCopyBuffer) - - Each typed CLBuffer subclass has map, mapLater, read methods that return typed NIO buffers -- Added full typing of OpenCL Exceptions (now possible to selectively catch a CLException.OutOfHostMemory, for instance) -- Added hashCode and equals method to most classes -- Added ability to create out of order queues and change queue properties after creation - -## Version 1.0-beta-1 - -- New CLPlatform class (~ OpenCL implementation) which now hosts the list*Devices(...) methods -- Entry point of library is now OpenCL4Java.listPlatforms() -- New CLEvent class, returned by all enqueue* methods (with methods waitFor, invokeUponCompletion...) -- Better separation between blocking and non blocking calls -- New CLSampler class supported as argument of CLKernel -- Many info getters with typesafe enums / enum sets in classes CLDevice, CLPlatform, CLKernel... -- Much more complete JavaDoc : [http://nativelibs4java.sourceforge.net/sites/OpenCL4Java/apidocs/](http://nativelibs4java.sourceforge.net/sites/OpenCL4Java/apidocs/) -- Example & benchmark classes became JUnit tests and moved here : [http://code.google.com/p/nativelibs4java/source/browse/#svn/trunk/lib...](http://code.google.com/p/nativelibs4java/source/browse/#svn/trunk/lib...) - -While this release is rather OpenCL4Java-focused, ScalaCL also got its bunch of enhancements : -- Added scalar variables IntVar, FloatVar, ShortVar... -- 'local' keyword can be added to variables so they're local to the programs : val x = FloatVar local -- Added many OpenCL math functions -- Added methods ArrayVar.write(Range), ArrayVar.write(Seq) -- Various bugfixes - diff --git a/Core/javacl-core-bridj.iml b/Core/javacl-core-bridj.iml deleted file mode 100644 index 6e7ab88d..00000000 --- a/Core/javacl-core-bridj.iml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/Core/javacl-core.iml b/Core/javacl-core.iml deleted file mode 100644 index 58668dc8..00000000 --- a/Core/javacl-core.iml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Core/pom.xml b/Core/pom.xml index af80287d..7fa89999 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -1,37 +1,40 @@ - - - 4.0.0 - com.nativelibs4java - javacl-core - JavaCL Core / BridJ - http://code.google.com/p/javacl/ - jar + + 4.0.0 + com.nativelibs4java + javacl-core-jna + JavaCL Core / JNA + http://code.google.com/p/javacl/ + 1.0.0-RC4 + jar - - + JavaCL is an Object-Oriented API that makes the C OpenCL API available to Java in a very natural way. It hides away the complexity of cross-platform C bindings, has a clean OO design (with generics, Java enums, NIO buffers, fully typed exceptions...), provides high-level features (OpenGL-interop, array reductions) and comes with samples and demos. For more info, please visit http://code.google.com/p/nativelibs4java/wiki/OpenCL. - - - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - .. - + - + + com.nativelibs4java + javacl-parent-jna + 1.0.0-RC4 + .. + + + + + + com.nativelibs4java + opencl4java-jna + - - com.nativelibs4java - opencl4java - - - com.nativelibs4java - nativelibs4java-utils - 1.6 - + + com.nativelibs4java + nativelibs4java-utils + 1.6 + compile + org.jogamp.gluegen @@ -45,41 +48,29 @@ For more info, please visit http://code.google.com/p/nativelibs4java/wiki/OpenCL 2.0.2-rc12 test - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.4 - - - - - - - - com.nativelibs4java - maven-velocity-plugin - - - - org.apache.maven.plugins - maven-shade-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - - 1 - false - - - - - + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.4 + + + + + + + + + com.nativelibs4java + maven-velocity-plugin + + + + diff --git a/Core/src/main/Header.vm b/Core/src/main/Header.vm deleted file mode 100644 index 9b292e30..00000000 --- a/Core/src/main/Header.vm +++ /dev/null @@ -1,122 +0,0 @@ -/* - * JavaCL - Java API and utilities for OpenCL - * http://javacl.googlecode.com/ - * - * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Olivier Chafik nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#macro (declareReusablePtrs) - ReusablePointers ptrs = ReusablePointers.get(); -#end - -#macro (declareEventsIn) - int[] eventsInCount = ptrs.int1Array; - Pointer eventsIn = - CLAbstractEntity.copyNonNullEntities(eventsToWaitFor, eventsInCount, ptrs.events_in); -#end - -#macro (declareEventOut) - Pointer eventOut = - eventsToWaitFor == null || CLEvent.containsFireAndForget(eventsToWaitFor) - ? null - : ptrs.event_out; -#end - -#macro (declareEventsOutBlockable) - Pointer eventOut = - blocking || eventsToWaitFor == null || CLEvent.containsFireAndForget(eventsToWaitFor) - ? null - : ptrs.event_out; -#end - -#macro (declarePErr) - Pointer pErr = ptrs.pErr; -#end - -#macro (declareReusablePtrsAndPErr) - #declareReusablePtrs() - #declarePErr() -#end - -#macro (checkPErr) - error(pErr.getInt()); -#end - -#macro (declareReusablePtrsAndEventsInOut) - #declareReusablePtrs() - #declareEventsIn() - #declareEventOut() -#end - -#macro (declareReusablePtrsAndEventsInOutBlockable) - #declareReusablePtrs() - #declareEventsIn() - #declareEventsOutBlockable() -#end - -#macro (eventOutArg) eventOut #end -#macro (eventOutArgRaw) getPeer(eventOut) #end - -#macro (eventsInArgsRaw) eventsInCount[0], getPeer(eventsIn) #end -#macro (eventsInArgs) eventsInCount[0], eventsIn #end - -#macro (eventsInOutArgsRaw) #eventsInArgsRaw(), #eventOutArgRaw() #end -#macro (eventsInOutArgs) #eventsInArgs(), #eventOutArg() #end - -#macro (eventOutWrapper $queue) CLEvent.createEventFromPointer($queue, eventOut) #end -#macro (returnEventOut $queue) return #eventOutWrapper($queue); #end - -#macro (declareInfosGetter $name $function) - protected static CLInfoGetter $name = new CLInfoGetter() { - @Override - protected int getInfo(long entity, int infoTypeEnum, long size, Pointer out, Pointer sizeOut) { - return $function(entity, infoTypeEnum, size, getPeer(out), getPeer(sizeOut)); - } - }; -#end - -#macro (documentEventsToWaitFor) - * @param eventsToWaitFor Events that need to complete before this particular command can be executed. Special value {@link CLEvent#FIRE_AND_FORGET} can be used to avoid returning a CLEvent. -#end - -#macro (documentEventsToWaitForAndReturn) -#documentEventsToWaitFor() - * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete, or null if eventsToWaitFor contains {@link CLEvent#FIRE_AND_FORGET}. -#end - -#macro (documentEventsToWaitForAndPairReturn $firstContent) -#documentEventsToWaitFor() - * @return Pair with $firstContent and event object that identifies this command and can be used to query or queue a wait for the command to complete, or null if eventsToWaitFor contains {@link CLEvent#FIRE_AND_FORGET}. -#end - -#macro (documentCallsFunction $functionName) - * Calls $functionName.
-#end - -#macro (documentQueue) - * @param queue Execution queue for this operation. -#end - diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLAbstractEntity.java b/Core/src/main/java/com/nativelibs4java/opencl/CLAbstractEntity.java new file mode 100644 index 00000000..5ff2ed81 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLAbstractEntity.java @@ -0,0 +1,110 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import com.sun.jna.PointerType; + +abstract class CLAbstractEntity { + protected volatile T entity; + private final boolean nullable; + + CLAbstractEntity(T entity) { + this(entity, false); + } + CLAbstractEntity(T entity, boolean nullable) { + if (!nullable && entity == null) { + throw new IllegalArgumentException("Null OpenCL " + getClass().getSimpleName() + " !"); + } + this.nullable = nullable; + this.entity = entity; + } + + /** + * Manual release of the OpenCL resources represented by this object.
+ * Note that resources are automatically released by the garbage collector, so in general there's no need to call this method.
+ * In an environment with fast allocation/deallocation of large objects, it might be safer to call release() manually, though.
+ * Note that release() does not necessarily free the object immediately : OpenCL maintains a reference count for all its objects, and an object released on the Java side might still be pointed to by running kernels or queued operations. + */ + public synchronized void release() { + if (entity == null) { + if (!nullable) + throw new RuntimeException("This " + getClass().getSimpleName() + " has already been released ! Besides, keep in mind that manual release is not necessary, as it will automatically be done by the garbage collector."); + else + return; + } + + doRelease(); + } + + public static > E[] getEntities(A[] objects, E[] out) { + for (int i = 0, len = objects.length; i < len; i++) + out[i] = objects[i].getEntity(); + return out; + } + synchronized T getEntity() { + if (entity == null && !nullable) + throw new RuntimeException("This " + getClass().getSimpleName() + " has been manually released and can't be used anymore !"); + + return entity; + } + + synchronized void doRelease() { + if (entity != null) { + clear(); + entity = null; + } + } + @Override + protected void finalize() throws Throwable { + doRelease(); + } + + protected abstract void clear(); + + /** + * Underyling implementation pointer-based hashCode computation + */ + @Override + public int hashCode() { + return getEntity() == null ? 0 : getEntity().getPointer().hashCode(); + } + + /** + * Underyling implementation pointer-based equality test + */ + @Override + public boolean equals(Object obj) { + if (obj == null || !getClass().isInstance(obj)) + return false; + CLAbstractEntity e = (CLAbstractEntity)obj; + return getEntity().getPointer().equals(e.getEntity().getPointer()); + } + +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLAbstractUserProgram.java b/Core/src/main/java/com/nativelibs4java/opencl/CLAbstractUserProgram.java similarity index 60% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLAbstractUserProgram.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLAbstractUserProgram.java index f4138a62..f488bb61 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLAbstractUserProgram.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLAbstractUserProgram.java @@ -1,4 +1,33 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; import com.nativelibs4java.util.IOUtils; @@ -21,6 +50,7 @@ public abstract class CLAbstractUserProgram { final CLProgram program; String rawSource; Map velocityArgs; + //Map kernels; volatile boolean addedSources; diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLBuildException.java b/Core/src/main/java/com/nativelibs4java/opencl/CLBuildException.java new file mode 100644 index 00000000..e4e69c04 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLBuildException.java @@ -0,0 +1,50 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; + +import com.ochafik.util.string.StringUtils; +import java.util.Collection; + +/** + * OpenCL program build exception + * @author ochafik + */ +@SuppressWarnings("serial") +public class CLBuildException extends CLException { + final CLProgram program; + CLBuildException(CLProgram program, String string, Collection errors) { + super(string + "\n" + StringUtils.implode(errors, "\n"), -1); + this.program = program; + } + public CLProgram getProgram() { + return program; + } +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLByteBuffer.java b/Core/src/main/java/com/nativelibs4java/opencl/CLByteBuffer.java new file mode 100644 index 00000000..1ff4fb48 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLByteBuffer.java @@ -0,0 +1,51 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; +import java.nio.*; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; + +/** + * OpenCL Memory Buffer Object.
+ * A buffer object stores a one-dimensional collection of elements.
+ * Elements of a buffer object can be a scalar data type (such as an int, float), vector data type, or a user-defined structure.
+ * see {@link CLContext#createByteBuffer(com.nativelibs4java.opencl.CLMem.Usage, long) } + * see {@link CLContext#createByteBuffer(com.nativelibs4java.opencl.CLMem.Usage, java.nio.Buffer, boolean) } + * @author Olivier Chafik + * @deprecated Use {@link CLBuffer}<{@link Byte}> + */ +@Deprecated +public class CLByteBuffer extends CLBuffer { + CLByteBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer) { + super(context, byteCount, entity, buffer, 1, ByteBuffer.class); + } +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLCharBuffer.java b/Core/src/main/java/com/nativelibs4java/opencl/CLCharBuffer.java new file mode 100644 index 00000000..5b6de6bf --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLCharBuffer.java @@ -0,0 +1,49 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; +import java.nio.*; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; + +/** + * OpenCL Memory Buffer Object with Character values.
+ * see {@link CLContext#createCharBuffer(com.nativelibs4java.opencl.CLMem.Usage, long) } + * see {@link CLContext#createCharBuffer(com.nativelibs4java.opencl.CLMem.Usage, java.nio.CharBuffer, boolean) } + * @author Olivier Chafik + * @deprecated Use {@link CLBuffer}<{@link Character}> + */ +@Deprecated +public class CLCharBuffer extends CLBuffer { + CLCharBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer) { + super(context, byteCount, entity, buffer, 2, CharBuffer.class); + } +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java b/Core/src/main/java/com/nativelibs4java/opencl/CLDevice.java similarity index 65% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLDevice.java index b30b9b47..f6c85622 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLDevice.java @@ -1,4 +1,33 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; import com.nativelibs4java.util.EnumValue; @@ -6,15 +35,15 @@ import com.nativelibs4java.opencl.library.OpenCLLibrary; import com.nativelibs4java.util.IOUtils; import com.nativelibs4java.util.NIOUtils; - +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; -import org.bridj.*; -import static org.bridj.Pointer.*; - +import com.sun.jna.*; +import com.sun.jna.ptr.*; import java.io.IOException; import java.nio.*; import static com.nativelibs4java.opencl.JavaCL.*; +import static com.nativelibs4java.util.JNAUtils.*; import static com.nativelibs4java.util.NIOUtils.*; import java.util.*; import static com.nativelibs4java.opencl.CLException.*; @@ -31,39 +60,33 @@ * {@link CLPlatform#listGPUDevices(boolean) } */ @SuppressWarnings("unused") -public class CLDevice extends CLAbstractEntity { +public class CLDevice extends CLAbstractEntity { - #declareInfosGetter("infos", "CL.clGetDeviceInfo") - - private volatile CLPlatform platform; - private volatile CLDevice parent; - private volatile boolean fetchedParent; - private final boolean needsRelease; + private static CLInfoGetter infos = new CLInfoGetter() { - CLDevice(CLPlatform platform, long device) { - this(platform, null, device, false); - } - CLDevice(CLPlatform platform, CLDevice parent, long device, boolean needsRelease) { + @Override + protected int getInfo(cl_device_id entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetDeviceInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; + volatile CLPlatform platform; + + CLDevice(CLPlatform platform, cl_device_id device) { super(device); this.platform = platform; - this.needsRelease = needsRelease; - this.parent = parent; - this.fetchedParent = parent != null; } - + public synchronized CLPlatform getPlatform() { if (platform == null) { Pointer pplat = infos.getPointer(getEntity(), CL_DEVICE_PLATFORM); - platform = new CLPlatform(getPeer(pplat)); + platform = new CLPlatform(pplat == null ? null : new cl_platform_id(pplat)); } return platform; } - @Override - protected void clear() { - if (needsRelease) - error(CL.clReleaseDevice(getEntity())); - } + @Override + protected void clear() { + } public String createSignature() { return getName() + "|" + getVendor() + "|" + getDriverVersion() + "|" + getProfile(); @@ -80,6 +103,7 @@ public static Map> getDevicesBySignature(List d return ret; } + private volatile ByteOrder byteOrder; public ByteOrder getByteOrder() { if (byteOrder == null) @@ -87,20 +111,16 @@ public ByteOrder getByteOrder() { return byteOrder; } - private volatile ByteOrder kernelsDefaultByteOrder; /** * @deprecated Use {@link CLDevice#getByteOrder()} */ @Deprecated public synchronized ByteOrder getKernelsDefaultByteOrder() { - if (kernelsDefaultByteOrder == null) { - kernelsDefaultByteOrder = ByteOrderHack.guessByteOrderNeededForBuffers(this); - } - return kernelsDefaultByteOrder; + return getByteOrder(); } /** Bit values for CL_DEVICE_EXECUTION_CAPABILITIES */ - public enum ExecutionCapability implements com.nativelibs4java.util.ValuedEnum { + public enum ExecutionCapability implements ValuedEnum { Kernel(CL_EXEC_KERNEL), NativeKernel(CL_EXEC_NATIVE_KERNEL); @@ -128,7 +148,7 @@ public EnumSet getExecutionCapabilities() { } /** Bit values for CL_DEVICE_TYPE */ - public enum Type implements com.nativelibs4java.util.ValuedEnum { + public enum Type implements ValuedEnum { CPU(CL_DEVICE_TYPE_CPU), GPU(CL_DEVICE_TYPE_GPU), @@ -263,34 +283,31 @@ public int getMaxWriteImageArgs() { @Override public String toString() { - return getName() + " (" + getPlatform().getName() + ")"; + return getName();// + "{singleFPConfig: " + getSingleFPConfig() + "}"; } /** -#documentCallsFunction("clCreateCommandQueue") * Create an OpenCL execution queue on this device for the specified context. * @param context context of the queue to create * @return new OpenCL queue object */ @SuppressWarnings("deprecation") public CLQueue createQueue(CLContext context, QueueProperties... queueProperties) { - #declareReusablePtrsAndPErr() - long flags = 0; + IntByReference pErr = new IntByReference(); + long flags = 0; for (QueueProperties prop : queueProperties) flags |= prop.value(); - long queue = CL.clCreateCommandQueue(context.getEntity(), getEntity(), flags, getPeer(pErr)); - #checkPErr() + cl_command_queue queue = CL.clCreateCommandQueue(context.getEntity(), getEntity(), flags, pErr); + error(pErr.getValue()); + return new CLQueue(context, queue, this); } - /** -#documentCallsFunction("clCreateCommandQueue") - */ @Deprecated public CLQueue createQueue(EnumSet queueProperties, CLContext context) { - #declareReusablePtrsAndPErr() - long queue = CL.clCreateCommandQueue(context.getEntity(), getEntity(), QueueProperties.getValue(queueProperties), getPeer(pErr)); - #checkPErr() + IntByReference pErr = new IntByReference(); + cl_command_queue queue = CL.clCreateCommandQueue(context.getEntity(), getEntity(), QueueProperties.getValue(queueProperties), pErr); + error(pErr.getValue()); return new CLQueue(context, queue, this); } @@ -383,17 +400,48 @@ public int getMinDataTypeAlign() { return infos.getInt(getEntity(), CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE); } + /** Bit values for CL_DEVICE_SINGLE_FP_CONFIG */ + public enum SingleFPConfig implements ValuedEnum { + + /** denorms are supported */ + Denorm(CL_FP_DENORM), + /** INF and quiet NaNs are supported. */ + InfNaN(CL_FP_INF_NAN), + /** round to nearest even rounding mode supported */ + RoundToNearest(CL_FP_ROUND_TO_NEAREST), + /** round to zero rounding mode supported */ + RoundToZero(CL_FP_ROUND_TO_ZERO), + /** round to +ve and -ve infinity rounding modes supported */ + RoundToInf(CL_FP_ROUND_TO_INF), + /** IEEE754-2008 fused multiply-add is supported. */ + FMA(CL_FP_FMA); + + SingleFPConfig(long value) { this.value = value; } + long value; + @Override + public long value() { return value; } + + + public static long getValue(EnumSet set) { + return EnumValues.getValue(set); + } + + public static EnumSet getEnumSet(long v) { + return EnumValues.getEnumSet(v, SingleFPConfig.class); + } + } + /** * Describes single precision floating- point capability of the device.
* The mandated minimum floating-point capability is: RoundToNearest and InfNaN. */ @InfoName("CL_DEVICE_SINGLE_FP_CONFIG") - public EnumSet getSingleFPConfig() { - return FpConfig.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_SINGLE_FP_CONFIG)); + public EnumSet getSingleFPConfig() { + return SingleFPConfig.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_SINGLE_FP_CONFIG)); } /** Values for CL_DEVICE_GLOBAL_MEM_CACHE_TYPE */ - public enum GlobalMemCacheType implements com.nativelibs4java.util.ValuedEnum { + public enum GlobalMemCacheType implements ValuedEnum { None(CL_NONE), ReadOnlyCache(CL_READ_ONLY_CACHE), @@ -460,7 +508,7 @@ public int getMaxConstantArgs() { } /** Values for CL_DEVICE_LOCAL_MEM_TYPE */ - public enum LocalMemType implements com.nativelibs4java.util.ValuedEnum { + public enum LocalMemType implements ValuedEnum { /** implying dedicated local memory storage such as SRAM */ Local(CL_LOCAL), @@ -503,23 +551,6 @@ public boolean hasErrorCorrectionSupport() { return infos.getBool(getEntity(), CL_DEVICE_ERROR_CORRECTION_SUPPORT); } - /** - * Maximum size of the internal buffer that holds the output of printf calls from a kernel. - * The minimum value for the FULL profile is 1 MB. - */ - @InfoName("CL_DEVICE_PRINTF_BUFFER_SIZE") - public long getPrintfBufferSize() { - return infos.getIntOrLong(getEntity(), CL_DEVICE_PRINTF_BUFFER_SIZE); - } - - /** - * Is CL_TRUE if the device’s preference is for the user to be responsible for synchronization, when sharing memory objects between OpenCL and other APIs such as DirectX, CL_FALSE if the device / implementation has a performant path for performing synchronization of memory object shared between OpenCL and other APIs such as DirectX. - */ - @InfoName("CL_DEVICE_PREFERRED_INTEROP_USER_SYNC") - public boolean isPreferredInteropUserSync() { - return infos.getBool(getEntity(), CL_DEVICE_PREFERRED_INTEROP_USER_SYNC); - } - @InfoName("Out of order queues support") public boolean hasOutOfOrderQueueSupport() { CLContext context = getPlatform().createContext(null, this); @@ -527,7 +558,7 @@ public boolean hasOutOfOrderQueueSupport() { try { queue = createOutOfOrderQueue(context); return true; - } catch (CLException ex) { + } catch (CLException.InvalidQueueProperties ex) { return false; } finally { if (queue != null) @@ -572,6 +603,17 @@ public boolean isCompilerAvailable() { return infos.getBool(getEntity(), CL_DEVICE_COMPILER_AVAILABLE); } + /** + * Is CL_FALSE if the implementation does not have a linker available. + * Is CL_TRUE if the linker is available. + * This can be CL_FALSE for the embedded platform profile only. + * This must be CL_TRUE if CL_DEVICE_COMPILER_AVAILABLE is CL_TRUE. + */ + @InfoName("CL_DEVICE_LINKER_AVAILABLE") + public boolean isLinkerAvailable() { + return infos.getBool(getEntity(), CL_DEVICE_LINKER_AVAILABLE); + } + /** Device name string. */ @@ -591,7 +633,7 @@ public String getName() { * @since OpenCL 1.1 */ @InfoName("CL_DEVICE_OPENCL_C_VERSION") - public String getOpenCLCVersion() { + public String getOpenCLVersion() { try { return infos.getString(getEntity(), CL_DEVICE_OPENCL_C_VERSION); } catch (Throwable th) { @@ -599,14 +641,7 @@ public String getOpenCLCVersion() { return "OpenCL C 1.0"; } } - /** - * @deprecated Legacy typo, use getOpenCLCVersion() instead. - */ - @Deprecated - public String getOpenCLVersion() { - return getOpenCLCVersion(); - } - + /** Vendor name string. */ @@ -615,60 +650,6 @@ public String getVendor() { return infos.getString(getEntity(), CL_DEVICE_VENDOR); } - /** - * Floating-point config of a device. - * The mandated minimum floating-point capability for devices that are not of type CL_DEVICE_TYPE_CUSTOM is: - * CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN. - */ - public enum FpConfig implements com.nativelibs4java.util.ValuedEnum { - /** - * Denorms are supported. - */ - Denorm(CL_FP_DENORM), - /** - * INF and quiet NaNs are supported. - */ - InfNan(CL_FP_INF_NAN), - /** - * Round to nearest even rounding mode supported. - */ - RoundToNearest(CL_FP_ROUND_TO_NEAREST), - /** - * Round to zero rounding mode supported. - */ - RoundToZero(CL_FP_ROUND_TO_ZERO), - /** - * Round to positive and negative infinity rounding modes supported. - */ - RoundToInf(CL_FP_ROUND_TO_INF), - /** - * IEEE754-2008 fused multiply- add is supported. - */ - FMA(CL_FP_FMA), - /** - * Divide and sqrt are correctly rounded as defined by the IEEE754 specification. - */ - CorrectlyRoundedDivideSqrt(CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT), - /** - * Basic floating-point operations (such as addition, subtraction, multiplication). - * are implemented in software. - */ - SoftFloat(CL_FP_SOFT_FLOAT); - - FpConfig(long value) { this.value = value; } - long value; - @Override - public long value() { return value; } - public static long getValue(EnumSet set) { - return EnumValues.getValue(set); - } - - public static EnumSet getEnumSet(long v) { - return EnumValues.getEnumSet(v, FpConfig.class); - } - } - - /** OpenCL software driver version string in the form major_number.minor_number. */ @@ -677,143 +658,6 @@ public String getDriverVersion() { return infos.getString(getEntity(), CL_DRIVER_VERSION); } - /** TODO */ - @InfoName("CL_DEVICE_IMAGE_MAX_ARRAY_SIZE") - public long getImageMaxArraySize() { - return infos.getIntOrLong(getEntity(), CL_DEVICE_IMAGE_MAX_ARRAY_SIZE); - } - - /** TODO */ - @InfoName("CL_DEVICE_IMAGE_MAX_BUFFER_SIZE") - public long getImageMaxBufferSize() { - return infos.getIntOrLong(getEntity(), CL_DEVICE_IMAGE_MAX_BUFFER_SIZE); - } - - /** TODO */ - @InfoName("CL_DEVICE_DOUBLE_FP_CONFIG") - public EnumSet getDoubleFpConfig() { - return isDoubleSupported() ? FpConfig.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_DOUBLE_FP_CONFIG)) : EnumSet.noneOf(FpConfig.class); - } - - /** TODO */ - @InfoName("CL_DEVICE_HALF_FP_CONFIG") - public EnumSet getHalfFpConfig() { - return isHalfSupported() ? FpConfig.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_HALF_FP_CONFIG)) : EnumSet.noneOf(FpConfig.class); - } - - /** TODO */ - @InfoName("CL_DEVICE_LINKER_AVAILABLE") - public boolean isLinkerAvailable() { - return infos.getBool(getEntity(), CL_DEVICE_LINKER_AVAILABLE); - } - - /** TODO */ - @InfoName("CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF") - public long getNativeVectorWidthHalf() { - return infos.getIntOrLong(getEntity(), CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF); - } - - /** Device partition types. */ - public enum PartitionType implements com.nativelibs4java.util.ValuedEnum { - Equally(CL_DEVICE_PARTITION_EQUALLY), - ByCounts(CL_DEVICE_PARTITION_BY_COUNTS), - ByAffinityDomain(CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN); - - PartitionType(long value) { this.value = value; } - long value; - @Override - public long value() { return value; } - public static long getValue(EnumSet set) { - return EnumValues.getValue(set); - } - - public static PartitionType getEnum(long v) { - return EnumValues.getEnum(v, PartitionType.class); - } - } - - @InfoName("CL_DEVICE_PARTITION_PROPERTIES") - public EnumSet getPartitionProperties() { - return getPartitionTypeInfo(CL_DEVICE_PARTITION_PROPERTIES); - } - - @InfoName("CL_DEVICE_PARTITION_TYPE") - public EnumSet getPartitionType() { - return getPartitionTypeInfo(CL_DEVICE_PARTITION_TYPE); - } - - private EnumSet getPartitionTypeInfo(int info) { - EnumSet ret = EnumSet.noneOf(PartitionType.class); - Pointer ptr = infos.getMemory(getEntity(), info); - if (ptr != null) { - Pointer props = ptr.as(SizeT.class); - for (long i = 0, n = props.getValidElements(); i < n; i++) { - long value = props.getSizeTAtIndex(i); - if (value == 0) { - break; - } - ret.add(PartitionType.getEnum(value)); - } - } - return ret; - } - - /** - * Returns the set of supported affinity domains for partitioning the device - * using {@link #createSubDevicesByAffinity(AffinityDomain)} - */ - @InfoName("CL_DEVICE_PARTITION_AFFINITY_DOMAIN") - public EnumSet getPartitionAffinityDomains() { - return AffinityDomain.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_PARTITION_AFFINITY_DOMAIN)); - } - - @InfoName("CL_DEVICE_PARTITION_MAX_SUB_DEVICES") - public int getPartitionMaxSubDevices() { - return infos.getInt(getEntity(), CL_DEVICE_PARTITION_MAX_SUB_DEVICES); - } - - /** TODO */ - @InfoName("CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF") - public long getPreferredVectorWidthHalf() { - return infos.getIntOrLong(getEntity(), CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF); - } - - /** TODO */ - @InfoName("CL_DEVICE_REFERENCE_COUNT") - public long getReferenceCount() { - return infos.getIntOrLong(getEntity(), CL_DEVICE_REFERENCE_COUNT); - } - - /** - * Affinity domain specified in {@link #createSubDevicesByAffinity(AffinityDomain)}, or null if the device is not a sub-device or wasn't split by affinity. - * This returns part of CL_DEVICE_PARTITION_TYPE. - */ - public AffinityDomain getPartitionAffinityDomain() { - Pointer memory = infos.getMemory(getEntity(), CL_DEVICE_PARTITION_TYPE); - long type = memory == null ? 0 : memory.getSizeT(); - if (type != CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) { - return null; - } - AffinityDomain affinityDomain = AffinityDomain.getEnum(memory.getSizeTAtIndex(1)); - return affinityDomain; - } - - - /** - * Returns the cl_device_id of the parent device to which this sub-device belongs. If device is a root-level device, a NULL value is returned. - */ - public synchronized CLDevice getParent() { - if (!fetchedParent) { - Pointer ptr = infos.getPointer(getEntity(), CL_DEVICE_PARENT_DEVICE); - if (ptr != null) { - parent = new CLDevice(platform, null, getPeer(ptr), false); - } - fetchedParent = true; - } - return parent; - } - - /** * OpenCL profile string.
* Returns the profile name supported by the device.
@@ -834,8 +678,12 @@ public String getProfile() { */ @InfoName("CL_DEVICE_HOST_UNIFIED_MEMORY") public boolean isHostUnifiedMemory() { - platform.requireMinVersionValue("CL_DEVICE_HOST_UNIFIED_MEMORY", 1.1); - return infos.getBool(getEntity(), CL_DEVICE_HOST_UNIFIED_MEMORY); + try { + return infos.getBool(getEntity(), CL_DEVICE_HOST_UNIFIED_MEMORY); + } catch (Throwable th) { + // TODO throw if supposed to handle OpenCL 1.1 + return false; + } } /** @@ -973,51 +821,26 @@ public String getVersion() { } /** - * List of extension names supported by the device. - * The list of extension names returned can be vendor supported extension names and one or more of the following Khronos approved extension names: - * - cl_khr_int64_base_atomics - * - cl_khr_int64_extended_atomics - * - cl_khr_fp16 - * - cl_khr_gl_sharing - * - cl_khr_gl_event - * - cl_khr_d3d10_sharing - * - cl_khr_dx9_media_sharing - * - cl_khr_d3d11_sharing - * - * The following approved Khronos extension names must be returned by all device that support OpenCL C 1.2: - * - cl_khr_global_int32_base_atomics - * - cl_khr_global_int32_extended_atomics - * - cl_khr_local_int32_base_atomics - * - cl_khr_local_int32_extended_atomics - * - cl_khr_byte_addressable_store - * - cl_khr_fp64 (for backward compatibility if double precision is supported) - * Please refer to the OpenCL 1.2 Extension Specification for a detailed description of these extensions. + Returns a space separated list of extension names (the extension names themselves do not contain any spaces). The list of extension names returned currently can include one or more of */ @InfoName("CL_DEVICE_EXTENSIONS") public String[] getExtensions() { if (extensions == null) { - extensions = new LinkedHashSet(Arrays.asList(infos.getString(getEntity(), CL_DEVICE_EXTENSIONS).split("\\s+"))); + extensions = infos.getString(getEntity(), CL_DEVICE_EXTENSIONS).split("\\s+"); } - return extensions.toArray(new String[extensions.size()]); + return extensions; } - private Set extensions; + private String[] extensions; public boolean hasExtension(String name) { - getExtensions(); - return extensions.contains(name.trim()); - } - - /** - * List of built-in kernels supported by the device. - */ - @InfoName("CL_DEVICE_BUILT_IN_KERNELS") - public String[] getBuiltInKernels() { - if (buildInKernels == null) { - buildInKernels = new LinkedHashSet(Arrays.asList(infos.getString(getEntity(), CL_DEVICE_BUILT_IN_KERNELS).split(";"))); + name = name.trim(); + for (String x : getExtensions()) { + if (name.equals(x.trim())) { + return true; + } } - return buildInKernels.toArray(new String[buildInKernels.size()]); + return false; } - private Set buildInKernels; /** * Whether this device support any double-precision number extension (cl_khr_fp64 or cl_amd_fp64) @@ -1100,7 +923,7 @@ public boolean isLocalInt32ExtendedAtomicsSupported() { } /** Bit values for CL_DEVICE_QUEUE_PROPERTIES */ - public static enum QueueProperties implements com.nativelibs4java.util.ValuedEnum { + public enum QueueProperties implements ValuedEnum { OutOfOrderExecModeEnable(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE), ProfilingEnable(CL_QUEUE_PROFILING_ENABLE); @@ -1128,118 +951,4 @@ public static EnumSet getEnumSet(long v) { public EnumSet getQueueProperties() { return QueueProperties.getEnumSet(infos.getIntOrLong(getEntity(), CL_DEVICE_QUEUE_PROPERTIES)); } - - /** Enums values for cl_device_affinity_domain */ - public enum AffinityDomain implements com.nativelibs4java.util.ValuedEnum { - /** Split the device into sub-devices comprised of compute units that share a NUMA node. */ - NUMA(CL_DEVICE_AFFINITY_DOMAIN_NUMA), - /** Split the device into sub-devices comprised of compute units that share a level 4 data cache. */ - L4Cache(CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE), - /** Split the device into sub-devices comprised of compute units that share a level 3 data cache. */ - L3Cache(CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE), - /** Split the device into sub-devices comprised of compute units that share a level 2 data cache. */ - L2Cache(CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE), - /** Split the device into sub-devices comprised of compute units that share a level 1 data cache. */ - L1Cache(CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE), - /** - * Split the device along the next partitionable affinity domain. The implementation shall finde - * first level along which the device or sub-device may be further subdivided in the order NUMA, - * L4, L3, L2, L1, and partition the device into sub-devices comprised of compute units that share - * memory subsystems at this level. - */ - NextPartitionable(CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE); - - AffinityDomain(long value) { this.value = value; } - long value; - @Override - public long value() { return value; } - - public static AffinityDomain getEnum(long v) { - return EnumValues.getEnum(v, AffinityDomain.class); - } - public static EnumSet getEnumSet(long v) { - return EnumValues.getEnumSet(v, AffinityDomain.class); - } - } - - /** - * Creates an array of sub-devices that each reference a non-intersecting set of compute units within this device. - * Split the aggregate device into as many smaller aggregate devices as can be created, each containing n compute units. The value n is passed as the value accompanying this property. If n does not divide evenly into CL_DEVICE_PARTITION_MAX_COMPUTE_UNITS, then the remaining compute units are not used. -#documentCallsFunction("clCreateSubDevices") - * @param computeUnitsForEverySubDevice Count of compute units for every subdevice. - */ - public CLDevice[] createSubDevicesEqually(int computeUnitsForEverySubDevice) { - return createSubDevices(pointerToSizeTs( - CL_DEVICE_PARTITION_EQUALLY, computeUnitsForEverySubDevice, 0, 0 - )); - } - - /** - * Creates an array of sub-devices that each reference a non-intersecting set of compute units within this device. - * For each nonzero count m in the list, a sub-device is created with m compute units in it. - * The number of non-zero count entries in the list may not exceed CL_DEVICE_PARTITION_MAX_SUB_DEVICES. - * The total number of compute units specified may not exceed CL_DEVICE_PARTITION_MAX_COMPUTE_UNITS. -#documentCallsFunction("clCreateSubDevices") - * @param computeUnitsForEachSubDevice List of counts of compute units for each subdevice. - */ - public CLDevice[] createSubDevicesByCounts(long... computeUnitsForEachSubDevice) { - Pointer pProperties = allocateSizeTs(1 + computeUnitsForEachSubDevice.length + 1 + 1); - int i = 0; - pProperties.setSizeTAtIndex(i++, CL_DEVICE_PARTITION_BY_COUNTS); - for (long count : computeUnitsForEachSubDevice) { - pProperties.setSizeTAtIndex(i++, count); - } - pProperties.setSizeTAtIndex(i++, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END); - return createSubDevices(pProperties); - } - - /** - * Creates an array of sub-devices that each reference a non-intersecting set of compute units within this device. - * Split the device into smaller aggregate devices containing one or more compute units that all share part of a cache hierarchy. - * The user may determine what happened by calling clGetDeviceInfo (CL_DEVICE_PARTITION_TYPE) on the sub-devices. -#documentCallsFunction("clCreateSubDevices") - * @param affinityDomain Affinity domain along which devices should be split. - */ - public CLDevice[] createSubDevicesByAffinity(AffinityDomain affinityDomain) { - return createSubDevices(pointerToSizeTs( - CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, affinityDomain.value(), 0 - )); - } - - /** - * Creates an array of sub-devices that each reference a non-intersecting set of compute units within this device. -#documentCallsFunction("clCreateSubDevices") -#documentEventsToWaitForAndReturn() - */ - CLDevice[] createSubDevices(Pointer pProperties) { - platform.requireMinVersionValue("clCreateSubDevices", 1.2); - - #declareReusablePtrs() - Pointer pNum = ptrs.int1; - error(CL.clCreateSubDevices(getEntity(), getPeer(pProperties), 0, 0, getPeer(pNum))); - int num = pNum.getInt(); - - Pointer pDevices = allocateSizeTs(num); - error(CL.clCreateSubDevices(getEntity(), getPeer(pProperties), num, getPeer(pDevices), 0)); - CLDevice[] devices = new CLDevice[(int) num]; - for (int i = 0; i < num; i++) { - devices[i] = new CLDevice(platform, this, pDevices.getSizeTAtIndex(i), true); - } - pDevices.release(); - return devices; - } - - /** -#documentCallsFunction("clEnqueueMigrateMemObjects") - * @param queue -#documentEventsToWaitForAndReturn() - */ - /* - public CLEvent enqueueMigrateMemObjects(CLQueue queue, CLEvent... eventsToWaitFor) { - context.getPlatform().requireMinVersionValue("clEnqueueMigrateMemObjects", 1.2); - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueMigrateMemObjects(queue.getEntity(), getEntity(), #eventsInOutArgsRaw())); - #returnEventOut("queue") - } - */ } diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLDoubleBuffer.java b/Core/src/main/java/com/nativelibs4java/opencl/CLDoubleBuffer.java new file mode 100644 index 00000000..65db50c0 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLDoubleBuffer.java @@ -0,0 +1,49 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; +import java.nio.*; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; + +/** + * OpenCL Memory Buffer Object with Double values.
+ * see {@link CLContext#createDoubleBuffer(com.nativelibs4java.opencl.CLMem.Usage, long) } + * see {@link CLContext#createDoubleBuffer(com.nativelibs4java.opencl.CLMem.Usage, java.nio.DoubleBuffer, boolean) } + * @author Olivier Chafik + * @deprecated Use {@link CLBuffer}<{@link Double}> + */ +@Deprecated +public class CLDoubleBuffer extends CLBuffer { + CLDoubleBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer) { + super(context, byteCount, entity, buffer, 8, DoubleBuffer.class); + } +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLEvent.java b/Core/src/main/java/com/nativelibs4java/opencl/CLEvent.java similarity index 62% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLEvent.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLEvent.java index bdfeca70..1d12d475 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLEvent.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLEvent.java @@ -1,20 +1,50 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; import static com.nativelibs4java.opencl.CLException.error; import static com.nativelibs4java.opencl.JavaCL.CL; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; import java.util.Arrays; import com.nativelibs4java.opencl.library.OpenCLLibrary; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event; import com.nativelibs4java.util.EnumValue; import com.nativelibs4java.util.EnumValues; -import org.bridj.*; -import org.bridj.ann.Ptr; -import static org.bridj.Pointer.*; -import static com.nativelibs4java.opencl.proxy.PointerUtils.*; +import com.nativelibs4java.util.ValuedEnum; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Callback; +import com.sun.jna.Memory; +import com.sun.jna.Pointer; /** * OpenCL event object.
@@ -31,30 +61,32 @@ * * @author ochafik */ -public class CLEvent extends CLAbstractEntity { +public class CLEvent extends CLAbstractEntity { - /** - * Pass this to special value to any method that expects a variable number of events to wait for and that returns an event, to completely avoid returning the completion event (will return null instead of the event). - */ - public static final CLEvent FIRE_AND_FORGET = new CLEvent(null, -1); - - #declareInfosGetter("infos", "CL.clGetEventInfo") + private static CLInfoGetter infos = new CLInfoGetter() { + @Override + protected int getInfo(cl_event entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetEventInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; - #declareInfosGetter("profilingInfos", "CL.clGetEventProfilingInfo") - - private final CLQueue queue; + private static CLInfoGetter profilingInfos = new CLInfoGetter() { + @Override + protected int getInfo(cl_event entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetEventProfilingInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; - CLEvent(CLQueue queue, long evt) { + CLEvent(cl_event evt) { super(evt, false); - this.queue = queue; } - - public CLQueue getQueue() { - return queue; + + CLEvent() { + super(null, true); } - + public interface EventCallback { - public void callback(int executionStatus); + public void callback(CLEvent event, int executionStatus); } /** @@ -66,21 +98,7 @@ public interface EventCallback { public void setCompletionCallback(final EventCallback callback) { setCallback(CL_COMPLETE, callback); } - - private static final clSetEventCallback_arg1_callback eventCallback = new clSetEventCallback_arg1_callback() { - public void apply(@Ptr long evt, int executionStatus, @Ptr long callbackPeer) { - EventCallback callback = (EventCallback)JNI.refToObject(callbackPeer); - try { - callback.callback(executionStatus); - } finally { - JNI.deleteGlobalRef(callbackPeer); - } - } - }; - private static final long eventCallbackPeer = getPeer(getPointer(eventCallback)); - /** -#documentCallsFunction("clSetEventCallback") * Registers a user callback function for a specific command execution status.
* The registered callback function will be called when the execution status of command associated with event changes to the execution status specified by command_exec_status. * @param commandExecStatus specifies the command execution status for which the callback is registered. The command execution callback values for which a callback can be registered are: CL_COMPLETE. There is no guarantee that the callback functions registered for various execution status values for an event will be called in the exact order that the execution status of a command changes. @@ -89,32 +107,65 @@ public void apply(@Ptr long evt, int executionStatus, @Ptr long callbackPeer) { * @since OpenCL 1.1 */ public void setCallback(int commandExecStatus, final EventCallback callback) { - queue.getContext().getPlatform().requireMinVersionValue("clSetEventCallback", 1.1); - error(CL.clSetEventCallback(getEntity(), commandExecStatus, eventCallbackPeer, JNI.newGlobalRef(callback))); + try { + error(CL.clSetEventCallback(getEntity(), commandExecStatus, new clSetEventCallback_arg1_callback() { + public void invoke(OpenCLLibrary.cl_event evt, int executionStatus, Pointer voidPtr1) { + callback.callback(CLEvent.this, executionStatus); + } + }, null)); + } catch (Throwable th) { + // TODO check if supposed to handle OpenCL 1.1 + throw new UnsupportedOperationException("Cannot set event callback (OpenCL 1.1 feature).", th); + } } - static CLEvent createEvent(final CLQueue queue, long evt) { + static boolean noEvents = false; + public static void setNoEvents(boolean noEvents) { + CLEvent.noEvents = noEvents; + } + static CLEvent createEvent(final CLQueue queue, cl_event evt) { return createEvent(queue, evt, false); } - - static CLEvent createEvent(final CLQueue queue, long evt, boolean isUserEvent) { - if (evt == 0) + static CLEvent createEvent(final CLQueue queue, cl_event evt, boolean isUserEvent) { + if (noEvents && queue != null) { + if (evt != null) + CL.clReleaseEvent(evt); + evt = null; + + if (isUserEvent) + return new CLUserEvent() { + volatile boolean waited = false; + @Override + public synchronized void waitFor() { + if (!waited) { + queue.finish(); + waited = true; + } + } + }; + return new CLEvent() { + volatile boolean waited = false; + @Override + public synchronized void waitFor() { + if (!waited) { + queue.finish(); + waited = true; + } + } + }; + } + if (evt == null) return null; return isUserEvent ? - new CLUserEvent(queue, evt) : - new CLEvent(queue, evt); + new CLUserEvent(evt) : + new CLEvent(evt); } - static CLEvent createEventFromPointer(CLQueue queue, Pointer evt1) { + static CLEvent createEvent(CLQueue queue, cl_event[] evt1) { if (evt1 == null) return null; - - long peer = evt1.getSizeT(); - if (peer == 0) - return null; - - return new CLEvent(queue, peer); + return createEvent(queue, evt1[0]); } @@ -122,11 +173,12 @@ static CLEvent createEventFromPointer(CLQueue queue, Pointer evt1) { * Wait for this event, blocking the caller thread independently of any queue until all of the command associated with this events completes. */ public void waitFor() { + if (entity == null) + return; waitFor(this); } /** -#documentCallsFunction("clWaitForEvents") * Wait for events, blocking the caller thread independently of any queue until all of the commands associated with the events completed. * @param eventsToWaitFor List of events which completion is to be waited for */ @@ -135,11 +187,10 @@ public static void waitFor(CLEvent... eventsToWaitFor) { return; try { - #declareReusablePtrs() - #declareEventsIn() - if (eventsIn == null) + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + if (evts == null || evts.length == 0) return; - error(CL.clWaitForEvents(#eventsInArgsRaw())); + error(CL.clWaitForEvents(evts.length, evts)); } catch (Exception ex) { throw new RuntimeException("Exception while waiting for events " + Arrays.asList(eventsToWaitFor), ex); } @@ -174,21 +225,49 @@ public void run() { }.start(); } - static boolean containsFireAndForget(CLEvent[] eventsToWaitFor) { - for (int i = eventsToWaitFor.length; i-- != 0;) { - if (eventsToWaitFor[i] == FIRE_AND_FORGET) - return true; - } - return false; + static cl_event[] new_event_out(CLEvent[] eventsToWaitFor) { + return noEvents || eventsToWaitFor == null ? null : new cl_event[1]; } + static cl_event[] to_cl_event_array(CLEvent... events) { + if (events == null) + return null; + if (noEvents) { + for (CLEvent evt : events) + if (evt != null) + evt.waitFor(); + return null; + } + int n = events.length; + if (n == 0) + return null; + int nonNulls = 0; + for (int i = 0; i < n; i++) + if (events[i] != null && events[i].getEntity() != null) + nonNulls++; + + if (nonNulls == 0) + return null; + + cl_event[] event_wait_list = new cl_event[nonNulls]; + int iDest = 0; + for (int i = 0; i < n; i++) { + CLEvent event = events[i]; + if (event == null || event.getEntity() == null) + continue; + event_wait_list[iDest] = event.getEntity(); + iDest++; + } + return event_wait_list; + } + @Override protected void clear() { error(CL.clReleaseEvent(getEntity())); } /** Values for CL_EVENT_COMMAND_EXECUTION_STATUS */ - public enum CommandExecutionStatus implements com.nativelibs4java.util.ValuedEnum { + public enum CommandExecutionStatus implements ValuedEnum { /** command has been enqueued in the command-queue */ Queued(CL_QUEUED), /** enqueued command has been submitted by the host to the device associated with the command-queue */ @@ -226,7 +305,7 @@ public int getCommandExecutionStatusValue() { } /** Values for CL_EVENT_COMMAND_TYPE */ - public enum CommandType implements com.nativelibs4java.util.ValuedEnum { + public enum CommandType implements ValuedEnum { NDRangeKernel(CL_COMMAND_NDRANGE_KERNEL), Task(CL_COMMAND_TASK), NativeKernel(CL_COMMAND_NATIVE_KERNEL), diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLException.java b/Core/src/main/java/com/nativelibs4java/opencl/CLException.java similarity index 76% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLException.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLException.java index 44dcf91f..d83ca423 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLException.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLException.java @@ -1,17 +1,42 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; - -import static com.nativelibs4java.opencl.JavaCL.log; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; - import com.nativelibs4java.opencl.library.OpenCLLibrary; import com.ochafik.util.string.StringUtils; - -import org.bridj.*; - +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.*; import java.lang.reflect.*; +import static com.nativelibs4java.opencl.JavaCL.log; import java.util.logging.Level; import java.util.logging.Logger; @@ -30,15 +55,9 @@ public int getCode() { return code; } - @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) - @interface ErrorCode { - int value(); - } - - public static class CLVersionException extends CLException { - public CLVersionException(String message) { - super(message, 0); - } + @Retention(RetentionPolicy.RUNTIME) + public @interface ErrorCode { + int value(); } public static class CLTypedException extends CLException { @@ -55,11 +74,8 @@ public String getMessage() { return message + logSuffix; } - void setKernelArg(CLKernel kernel, int argIndex, long size, Pointer ptr) { - message += " (kernel name = " + kernel.getFunctionName(); - message += ", num args = " + kernel.getNumArgs(); - message += ", arg index = " + argIndex; - message += ", arg size = " + size; + void setKernelArg(CLKernel kernel, int argIndex) { + message += " (kernel name = " + kernel.getFunctionName() + ", num args = " + kernel.getNumArgs() + ", arg index = " + argIndex; CLProgram program = kernel.getProgram(); if (program != null) message += ", source = <<<\n\t" + program.getSource().replaceAll("\n", "\n\t"); @@ -69,31 +85,13 @@ void setKernelArg(CLKernel kernel, int argIndex, long size, Pointer ptr) { } - @ErrorCode(CL_DEVICE_PARTITION_FAILED) - public static class DevicePartitionFailed extends CLTypedException {} - @ErrorCode(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST) - public static class ExecStatusErrorForEventsInWaitList extends CLTypedException {} @ErrorCode(CL_MISALIGNED_SUB_BUFFER_OFFSET) public static class MisalignedSubBufferOffset extends CLTypedException {} - @ErrorCode(CL_COMPILE_PROGRAM_FAILURE) - public static class CompileProgramFailure extends CLTypedException {} - @ErrorCode(CL_LINKER_NOT_AVAILABLE) - public static class LinkerNotAvailable extends CLTypedException {} - @ErrorCode(CL_LINK_PROGRAM_FAILURE) - public static class LinkProgramFailure extends CLTypedException {} - @ErrorCode(CL_KERNEL_ARG_INFO_NOT_AVAILABLE) - public static class KernelArgInfoNotAvailable extends CLTypedException {} - @ErrorCode(CL_IMAGE_FORMAT_MISMATCH) - public static class ImageFormatMismatch extends CLTypedException {} - @ErrorCode(CL_PROFILING_INFO_NOT_AVAILABLE) - public static class ProfilingInfoNotAvailable extends CLTypedException {} - @ErrorCode(CL_DEVICE_NOT_AVAILABLE) - public static class DeviceNotAvailable extends CLTypedException {} @ErrorCode(CL_OUT_OF_RESOURCES) public static class OutOfResources extends CLTypedException {} @ErrorCode(CL_COMPILER_NOT_AVAILABLE) public static class CompilerNotAvailable extends CLTypedException {} - @ErrorCode(CL_INVALID_GLOBAL_WORK_SIZE) + @ErrorCode(CL_INVALID_GLOBAL_WORK_SIZE) public static class InvalidGlobalWorkSize extends CLTypedException {} @ErrorCode(CL_MAP_FAILURE) public static class MapFailure extends CLTypedException {} @@ -129,22 +127,6 @@ public static class InvalidBufferSize extends CLTypedException {} public static class InvalidGlobalOffset extends CLTypedException {} @ErrorCode(CL_OUT_OF_HOST_MEMORY) public static class OutOfHostMemory extends CLTypedException {} - @ErrorCode(CL_INVALID_COMPILER_OPTIONS) - public static class InvalidCompilerOptions extends CLTypedException {} - @ErrorCode(CL_INVALID_DEVICE) - public static class InvalidDevice extends CLTypedException {} - @ErrorCode(CL_INVALID_DEVICE_PARTITION_COUNT) - public static class InvalidDevicePartitionCount extends CLTypedException {} - @ErrorCode(CL_INVALID_HOST_PTR) - public static class InvalidHostPtr extends CLTypedException {} - @ErrorCode(CL_INVALID_IMAGE_DESCRIPTOR) - public static class InvalidImageDescriptor extends CLTypedException {} - @ErrorCode(CL_INVALID_LINKER_OPTIONS) - public static class InvalidLinkerOptions extends CLTypedException {} - @ErrorCode(CL_INVALID_PLATFORM) - public static class InvalidPlatform extends CLTypedException {} - @ErrorCode(CL_INVALID_PROPERTY) - public static class InvalidProperty extends CLTypedException {} @ErrorCode(CL_INVALID_COMMAND_QUEUE) public static class InvalidCommandQueue extends CLTypedException {} @ErrorCode(CL_MEM_COPY_OVERLAP) @@ -244,6 +226,8 @@ static boolean failedForLackOfMemory(int err, int previousAttempts) { public static void error(int err) { if (err == CL_SUCCESS) return; + //if (err == CL_OUT_OF_RESOURCES) + // return; if (typedErrorClassesByCode == null) { typedErrorClassesByCode = new HashMap>(); @@ -267,7 +251,8 @@ public static void error(int err) { if (toThrow == null) toThrow = new CLException("OpenCL Error : " + errorString(err) + logSuffix, err); - throw toThrow; + //assert log(Level.SEVERE, null, toThrow); + + throw toThrow; } } - diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLFloatBuffer.java b/Core/src/main/java/com/nativelibs4java/opencl/CLFloatBuffer.java new file mode 100644 index 00000000..d80f1823 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLFloatBuffer.java @@ -0,0 +1,50 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; + +/** + * OpenCL Memory Buffer Object with Float values.
+ * see {@link CLContext#createFloatBuffer(com.nativelibs4java.opencl.CLMem.Usage, long) } + * see {@link CLContext#createFloatBuffer(com.nativelibs4java.opencl.CLMem.Usage, java.nio.FloatBuffer, boolean) } + * @author Olivier Chafik + * @deprecated Use {@link CLBuffer}<{@link Float}> + */ +@Deprecated +public class CLFloatBuffer extends CLBuffer { + CLFloatBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer) { + super(context, byteCount, entity, buffer, 4, FloatBuffer.class); + } +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLImage.java b/Core/src/main/java/com/nativelibs4java/opencl/CLImage.java new file mode 100644 index 00000000..b0ae629a --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLImage.java @@ -0,0 +1,192 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.CLException.error; +import static com.nativelibs4java.opencl.JavaCL.CL; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_FALSE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_IMAGE_ELEMENT_SIZE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_IMAGE_FORMAT; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_TRUE; +import static com.nativelibs4java.util.JNAUtils.toNS; +import static com.nativelibs4java.util.NIOUtils.directCopy; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; + +import com.nativelibs4java.opencl.library.cl_image_format; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; +import com.nativelibs4java.util.NIOUtils; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.ochafik.util.listenable.Pair; +import com.sun.jna.Native; +import com.sun.jna.Pointer; + + +/** + * OpenCL Image Memory Object.
+ * An image object is used to store a two- or three- dimensional texture, frame-buffer or image
+ * An image object is used to represent a buffer that can be used as a texture or a frame-buffer. The elements of an image object are selected from a list of predefined image formats. + * @author Oliveir Chafik + */ +public abstract class CLImage extends CLMem { + + CLImageFormat format; + CLImage(CLContext context, cl_mem entity, CLImageFormat format) { + super(context, -1, entity); + this.format = format; + } + + + + /** + * Return image format descriptor specified when image is created with CLContext.create{Input|Output|InputOutput}{2D|3D}. + */ + @InfoName("CL_IMAGE_FORMAT") + public CLImageFormat getFormat() { + if (format == null) { + /// TODO: DOES NOT SEEM TO WORK ON MAC OS X 10.6.1 / CPU + cl_image_format fmt = new cl_image_format(); + fmt.use(infos.getMemory(getEntity(), CL_IMAGE_FORMAT)); + fmt.read(); + format = new CLImageFormat(fmt); + } + return format; + } + + /** + * Return size of each element of the image memory object given by image.
+ * An element is made up of n channels. The value of n is given in cl_image_format descriptor. + */ + @InfoName("CL_IMAGE_ELEMENT_SIZE") + public long getElementSize() { + return infos.getIntOrLong(getEntity(), CL_IMAGE_ELEMENT_SIZE); + } + + + protected CLEvent read(CLQueue queue, NativeSize[] origin, NativeSize[] region, long rowPitch, long slicePitch, Buffer out, boolean blocking, CLEvent... eventsToWaitFor) { + /*if (!out.isDirect()) { + + }*/ + cl_event[] eventOut = blocking ? null : CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueReadImage(queue.getEntity(), getEntity(), + blocking ? CL_TRUE : CL_FALSE, + origin, + region, + toNS(rowPitch), + toNS(slicePitch), + Native.getDirectBufferPointer(out), + evts == null ? 0 : evts.length, evts, + eventOut + )); + return CLEvent.createEvent(queue, eventOut); + } + + protected CLEvent write(CLQueue queue, NativeSize[] origin, NativeSize[] region, long rowPitch, long slicePitch, Buffer in, boolean blocking, CLEvent... eventsToWaitFor) { + boolean indirect = !in.isDirect(); + if (indirect) + in = directCopy(in, getContext().getByteOrder()); + + cl_event[] eventOut = blocking ? null : CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueWriteImage(queue.getEntity(), getEntity(), + blocking ? CL_TRUE : CL_FALSE, + origin, + region, + toNS(rowPitch), + toNS(slicePitch), + Native.getDirectBufferPointer(in), + evts == null ? 0 : evts.length, evts, + eventOut + )); + CLEvent evt = CLEvent.createEvent(queue, eventOut); + + if (indirect && !blocking) { + final Buffer toHold = in; + evt.invokeUponCompletion(new Runnable() { + public void run() { + // Make sure the GC held a reference to directData until the write was completed ! + toHold.rewind(); + } + }); + } + + return evt; + } + + protected Pair map(CLQueue queue, MapFlags flags, + NativeSize[] offset3, NativeSize[] length3, + Long imageRowPitch, + Long imageSlicePitch, + boolean blocking, CLEvent... eventsToWaitFor) + { + //checkBounds(offset, length); + cl_event[] eventOut = blocking ? null : CLEvent.new_event_out(eventsToWaitFor); + IntBuffer pErr = NIOUtils.directInts(1, ByteOrder.nativeOrder()); + + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + Pointer p = CL.clEnqueueMapImage( + queue.getEntity(), getEntity(), blocking ? CL_TRUE : CL_FALSE, + flags.value(), + offset3, + length3, + imageRowPitch == null ? null : new NativeSizeByReference(toNS(imageRowPitch)), + imageSlicePitch == null ? null : new NativeSizeByReference(toNS(imageSlicePitch)), + evts == null ? 0 : evts.length, evts, + eventOut, + pErr + ); + error(pErr.get()); + return new Pair( + p.getByteBuffer(0, getByteCount()), + CLEvent.createEvent(queue, eventOut) + ); + } + + /** + * see {@link CLImage2D#map(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLMem.MapFlags, com.nativelibs4java.opencl.CLEvent[]) } + * see {@link CLImage3D#map(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLMem.MapFlags, com.nativelibs4java.opencl.CLEvent[]) } + * @param queue + * @param buffer + * @param eventsToWaitFor + * @return Event which completion indicates that the OpenCL was unmapped + */ + public CLEvent unmap(CLQueue queue, ByteBuffer buffer, CLEvent... eventsToWaitFor) { + cl_event[] eventOut = CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueUnmapMemObject(queue.getEntity(), getEntity(), Native.getDirectBufferPointer(buffer), evts == null ? 0 : evts.length, evts, eventOut)); + return CLEvent.createEvent(queue, eventOut); + } +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage2D.java b/Core/src/main/java/com/nativelibs4java/opencl/CLImage2D.java similarity index 58% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLImage2D.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLImage2D.java index 970bcd36..9eacad11 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage2D.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLImage2D.java @@ -1,9 +1,40 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; import com.nativelibs4java.opencl.ImageIOUtils.ImageInfo; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_HEIGHT; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_ROW_PITCH; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_WIDTH; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_IMAGE_HEIGHT; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_IMAGE_ROW_PITCH; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_IMAGE_WIDTH; +import static com.nativelibs4java.util.JNAUtils.toNS; +import static com.nativelibs4java.util.NIOUtils.directInts; import java.awt.Image; import java.awt.image.BufferedImage; @@ -11,12 +42,9 @@ import java.nio.ByteBuffer; import java.nio.IntBuffer; -import org.bridj.Pointer; -import org.bridj.SizeT; -import static org.bridj.Pointer.*; - -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import com.nativelibs4java.util.Pair; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; +import com.nativelibs4java.util.NIOUtils; +import com.ochafik.util.listenable.Pair; /** * OpenCL 2D Image Memory Object
@@ -29,8 +57,8 @@ * @author Olivier Chafik */ public class CLImage2D extends CLImage { - CLImage2D(CLContext context, long entityPeer, CLImageFormat format) { - super(context, entityPeer, format); + CLImage2D(CLContext context, cl_mem entity, CLImageFormat format) { + super(context, entity, format); } /** @@ -57,54 +85,13 @@ public long getHeight() { return infos.getIntOrLong(getEntity(), CL_IMAGE_HEIGHT); } - @Override - protected long[] getDimensions() { - return new long[] { getWidth(), getHeight() }; - } - - @Override - protected Pointer writeOrigin(long[] origin, ReusablePointer out) { - assert(origin.length == 2); - return out.pointerToSizeTs(origin[0], origin[1], 0); - } - - @Override - protected Pointer writeRegion(long[] region, ReusablePointer out) { - assert(region.length == 2); - return out.pointerToSizeTs(region[0], region[1], 1); - } - - /** -#documentEventsToWaitForAndReturn() - */ public CLEvent read(CLQueue queue, long minX, long minY, long width, long height, long rowPitch, Buffer out, boolean blocking, CLEvent... eventsToWaitFor) { - Pointer ptrOut = pointerToBuffer(out); - CLEvent evt = read(queue, minX, minY, width, height, rowPitch, ptrOut, blocking, eventsToWaitFor); - ptrOut.updateBuffer(out); // in case the buffer wasn't direct ! - return evt; + return read(queue, toNS(minX, minY, 0), toNS(width, height, 1), rowPitch, 0, out, blocking, eventsToWaitFor); } - /** -#documentEventsToWaitForAndReturn() - */ - public CLEvent read(CLQueue queue, long minX, long minY, long width, long height, long rowPitch, Pointer out, boolean blocking, CLEvent... eventsToWaitFor) { - return read(queue, pointerToSizeTs(minX, minY, 0), pointerToSizeTs(width, height, 1), rowPitch, 0, out, blocking, eventsToWaitFor); - } - /** -#documentEventsToWaitForAndReturn() - */ public CLEvent write(CLQueue queue, long minX, long minY, long width, long height, long rowPitch, Buffer in, boolean blocking, CLEvent... eventsToWaitFor) { - return write(queue, minX, minY, width, height, rowPitch, pointerToBuffer(in), blocking, eventsToWaitFor); - } - /** -#documentEventsToWaitForAndReturn() - */ - public CLEvent write(CLQueue queue, long minX, long minY, long width, long height, long rowPitch, Pointer in, boolean blocking, CLEvent... eventsToWaitFor) { - return write(queue, pointerToSizeTs(minX, minY, 0), pointerToSizeTs(width, height, 1), rowPitch, 0, in, blocking, eventsToWaitFor); + return write(queue, toNS(minX, minY, 0), toNS(width, height, 1), rowPitch, 0, in, blocking, eventsToWaitFor); } - /** - * @param eventsToWaitFor Events that need to complete before this particular command can be executed. - */ public BufferedImage read(CLQueue queue, CLEvent... eventsToWaitFor) { ImageInfo info = ImageIOUtils.getBufferedImageInfo(getFormat()); int imageType = info == null ? 0 : info.bufferedImageType; @@ -116,36 +103,24 @@ public BufferedImage read(CLQueue queue, CLEvent... eventsToWaitFor) { read(queue, im, false, eventsToWaitFor); return im; } - /** - * @param eventsToWaitFor Events that need to complete before this particular command can be executed. - */ public void read(CLQueue queue, BufferedImage imageOut, boolean allowDeoptimizingDirectWrite, CLEvent... eventsToWaitFor) { //if (!getFormat().isIntBased()) // throw new IllegalArgumentException("Image-read only supports int-based RGBA images"); ImageInfo info = ImageIOUtils.getBufferedImageInfo(getFormat()); int width = imageOut.getWidth(null), height = imageOut.getHeight(null); - Pointer dataOut = allocateArray(info.bufferElementsClass, width * height * info.channelCount).order(getContext().getByteOrder()); + Buffer dataOut = NIOUtils.directBuffer(width * height * info.channelCount, getContext().getByteOrder(), info.bufferClass); //Buffer dataOut = info.createBuffer(width, height, true); //IntBuffer dataOut = directInts(width * height, getContext().getByteOrder()); read(queue, 0, 0, width, height, 0, dataOut, true, eventsToWaitFor); - info.dataSetter.setData(imageOut, dataOut.getBuffer(), allowDeoptimizingDirectWrite); + info.dataSetter.setData(imageOut, dataOut, allowDeoptimizingDirectWrite); } - /** -#documentEventsToWaitForAndReturn() - */ public CLEvent write(CLQueue queue, Image image, CLEvent... eventsToWaitFor) { return write(queue, image, 0, 0, image.getWidth(null), image.getHeight(null), false, false, eventsToWaitFor); } - /** -#documentEventsToWaitForAndReturn() - */ public CLEvent write(CLQueue queue, Image image, boolean allowDeoptimizingDirectRead, boolean blocking, CLEvent... eventsToWaitFor) { return write(queue, image, 0, 0, image.getWidth(null), image.getHeight(null), allowDeoptimizingDirectRead, blocking, eventsToWaitFor); } - /** -#documentEventsToWaitForAndReturn() - */ public CLEvent write(CLQueue queue, Image image, int destX, int destY, int width, int height, boolean allowDeoptimizingDirectRead, boolean blocking, CLEvent... eventsToWaitFor) { //int imWidth = image.getWidth(null), height = image.getHeight(null); ImageInfo info = ImageIOUtils.getBufferedImageInfo(getFormat()); @@ -164,21 +139,15 @@ public void write(CLQueue queue, BufferedImage im) { } public ByteBuffer map(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) { - return map(queue, flags, pointerToSizeTs(0, 0), pointerToSizeTs(getWidth(), getHeight()), getWidth(), null, true, eventsToWaitFor).getFirst(); + return map(queue, flags, toNS(0, 0), toNS(getWidth(), getHeight()), getWidth(), null, true, eventsToWaitFor).getFirst(); } public ByteBuffer map(CLQueue queue, MapFlags flags, long offsetX, long offsetY, long lengthX, long lengthY, long rowPitch, CLEvent... eventsToWaitFor) { - return map(queue, flags, pointerToSizeTs(offsetX, offsetY), pointerToSizeTs(lengthX, lengthY), rowPitch, null, true, eventsToWaitFor).getFirst(); + return map(queue, flags, toNS(offsetX, offsetY), toNS(lengthX, lengthY), rowPitch, null, true, eventsToWaitFor).getFirst(); } - /** -#documentEventsToWaitForAndPairReturn("byte buffer") - */ public Pair mapLater(CLQueue queue, MapFlags flags, boolean blocking, CLEvent... eventsToWaitFor) { - return map(queue, flags, pointerToSizeTs(0, 0), pointerToSizeTs(getWidth(), getHeight()), getWidth(), null, blocking, eventsToWaitFor); + return map(queue, flags, toNS(0, 0), toNS(getWidth(), getHeight()), getWidth(), null, blocking, eventsToWaitFor); } - /** -#documentEventsToWaitForAndPairReturn("byte buffer") - */ - public Pair mapLater(CLQueue queue, MapFlags flags, long offsetX, long offsetY, long lengthX, long lengthY, long rowPitch, boolean blocking, CLEvent... eventsToWaitFor) { - return map(queue, flags, pointerToSizeTs(offsetX, offsetY), pointerToSizeTs(lengthX, lengthY), rowPitch, null, blocking, eventsToWaitFor); + public Pair mapLater(CLQueue queue, MapFlags flags, long offsetX, long offsetY, long lengthX, long lengthY, long rowPitch, boolean blocking, CLEvent... eventsToWaitFor) { + return map(queue, flags, toNS(offsetX, offsetY), toNS(lengthX, lengthY), rowPitch, null, blocking, eventsToWaitFor); } } diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLImage3D.java b/Core/src/main/java/com/nativelibs4java/opencl/CLImage3D.java new file mode 100644 index 00000000..9e88fd4b --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLImage3D.java @@ -0,0 +1,93 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_IMAGE_DEPTH; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_IMAGE_SLICE_PITCH; +import static com.nativelibs4java.util.JNAUtils.toNS; + +import java.nio.Buffer; +import java.nio.ByteBuffer; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; +import com.ochafik.util.listenable.Pair; + +/** + * OpenCL 3D Image Memory Object
+ * see {@link CLContext#createImage3D(com.nativelibs4java.opencl.CLMem.Usage, com.nativelibs4java.opencl.CLImageFormat, long, long, long) } + * see {@link CLContext#createImage3D(com.nativelibs4java.opencl.CLMem.Usage, com.nativelibs4java.opencl.CLImageFormat, long, long, long, long, long) } + * see {@link CLContext#createImage3D(com.nativelibs4java.opencl.CLMem.Usage, com.nativelibs4java.opencl.CLImageFormat, long, long, long, long, long, java.nio.Buffer, boolean) } + * see {@link CLContext#createImage3DFromGLTexture3D(com.nativelibs4java.opencl.CLMem.Usage, int, int) } + * @author Olivier Chafik + */ +public class CLImage3D extends CLImage2D { + CLImage3D(CLContext context, cl_mem entity, CLImageFormat format) { + super(context, entity, format); + } + + /** + * Return size in bytes of a 2D slice for this 3D image object.
+ */ + @InfoName("CL_IMAGE_SLICE_PITCH") + public long getSlicePitch() { + return infos.getIntOrLong(getEntity(), CL_IMAGE_SLICE_PITCH); + } + + /** + * Return depth of the image in pixels. + */ + @InfoName("CL_IMAGE_DEPTH") + public long getDepth() { + return infos.getIntOrLong(getEntity(), CL_IMAGE_DEPTH); + } + + public CLEvent read(CLQueue queue, long minX, long minY, long minZ, long width, long height, long depth, long rowPitch, long slicePitch, Buffer out, boolean blocking, CLEvent... eventsToWaitFor) { + return read(queue, toNS(minX, minY, minZ), toNS(width, height, depth), rowPitch, slicePitch, out, blocking, eventsToWaitFor); + } + + public CLEvent write(CLQueue queue, long minX, long minY, long minZ, long width, long height, long depth, long rowPitch, long slicePitch, Buffer in, boolean blocking, CLEvent... eventsToWaitFor) { + return write(queue, toNS(minX, minY, minZ), toNS(width, height, depth), rowPitch, slicePitch, in, blocking, eventsToWaitFor); + } + + public ByteBuffer map(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) { + return map(queue, flags, 0, 0, 0, getWidth(), getHeight(), getDepth(), getWidth(), getHeight(), true, eventsToWaitFor); + } + public Pair mapLater(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) { + return map(queue, flags, toNS(0, 0, 0), toNS(getWidth(), getHeight(), getDepth()), getWidth(), getHeight(), true, eventsToWaitFor); + } + + public ByteBuffer map(CLQueue queue, MapFlags flags, long offsetX, long offsetY, long offsetZ, long lengthX, long lengthY, long lengthZ, long rowPitch, long slicePitch, boolean blocking, CLEvent... eventsToWaitFor) { + return map(queue, flags, toNS(offsetX, offsetY, offsetZ), toNS(lengthX, lengthY, lengthZ), rowPitch, slicePitch, true, eventsToWaitFor).getFirst(); + } + public Pair mapLater(CLQueue queue, MapFlags flags, long offsetX, long offsetY, long offsetZ, long lengthX, long lengthY, long lengthZ, long rowPitch, long slicePitch, CLEvent... eventsToWaitFor) { + return map(queue, flags, toNS(offsetX, offsetY, offsetZ), toNS(lengthX, lengthY, lengthZ), rowPitch, slicePitch, true, eventsToWaitFor); + } + +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImageFormat.java b/Core/src/main/java/com/nativelibs4java/opencl/CLImageFormat.java similarity index 80% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLImageFormat.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLImageFormat.java index 333940b0..5e85211b 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImageFormat.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLImageFormat.java @@ -1,13 +1,40 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; import com.nativelibs4java.opencl.library.cl_image_format; import com.nativelibs4java.util.EnumValue; import com.nativelibs4java.util.EnumValues; -import org.bridj.*; -import static org.bridj.Pointer.*; +import com.nativelibs4java.util.ValuedEnum; /** * OpenCL Image Format @@ -20,10 +47,10 @@ public class CLImageFormat { private final ChannelDataType channelDataType; CLImageFormat(cl_image_format fmt) { - this(ChannelOrder.getEnum(fmt.image_channel_order()), ChannelDataType.getEnum(fmt.image_channel_data_type())); + this(ChannelOrder.getEnum(fmt.image_channel_order), ChannelDataType.getEnum(fmt.image_channel_data_type)); } cl_image_format to_cl_image_format() { - return new cl_image_format().image_channel_order((int)channelOrder.value()).image_channel_data_type((int)channelDataType.value()); + return new cl_image_format((int)channelOrder.value(), (int)channelDataType.value()); } public CLImageFormat(ChannelOrder channelOrder, ChannelDataType channelDataType) { super(); @@ -89,7 +116,7 @@ public String toString() { - public enum ChannelOrder implements com.nativelibs4java.util.ValuedEnum { + public enum ChannelOrder implements ValuedEnum { /** * components of channel data: (r, 0.0, 0.0, 1.0) @@ -164,7 +191,7 @@ public enum ChannelOrder implements com.nativelibs4java.util.ValuedEnum { /** * For example, to specify a normalized unsigned 8-bit / channel RGBA image, image_channel_order = CL_RGBA, and image_channel_data_type = CL_UNORM_INT8. The memory layout of this image format is described below: */ - public enum ChannelDataType implements com.nativelibs4java.util.ValuedEnum { + public enum ChannelDataType implements ValuedEnum { /** * Each channel component is a normalized signed 8-bit integer value */ diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLInfoGetter.java b/Core/src/main/java/com/nativelibs4java/opencl/CLInfoGetter.java new file mode 100644 index 00000000..a2e14b66 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLInfoGetter.java @@ -0,0 +1,148 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; + +import static com.nativelibs4java.opencl.CLException.error; +import static com.nativelibs4java.util.JNAUtils.readNS; +import static com.nativelibs4java.util.JNAUtils.toNS; + +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Memory; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.IntByReference; + +/** + * + * @author ochafik + */ +abstract class CLInfoGetter { + + protected abstract int getInfo(T entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut); + + public String getString(T entity, int infoName) { + NativeSizeByReference pLen = new NativeSizeByReference(); + error(getInfo(entity, infoName, toNS(0), null, pLen)); + + int len = pLen.getValue().intValue(); + if (len == 0) { + return ""; + } + Memory buffer = new Memory(len + 1); + error(getInfo(entity, infoName, pLen.getValue(), buffer, null)); + + return buffer.getString(0); + } + + public Pointer getPointer(T entity, int infoName) { + NativeSizeByReference pLen = new NativeSizeByReference(); + Memory mem = new Memory(Pointer.SIZE); + error(getInfo(entity, infoName, toNS(Pointer.SIZE), mem, pLen)); + if (pLen.getValue().intValue() != Pointer.SIZE) { + throw new RuntimeException("Not a pointer : len = " + pLen.getValue()); + } + return mem.getPointer(0); + } + + public Memory getMemory(T entity, int infoName) { + NativeSizeByReference pLen = new NativeSizeByReference(); + error(getInfo(entity, infoName, toNS(0), null, pLen)); + + Memory buffer = new Memory(pLen.getValue().intValue()); + error(getInfo(entity, infoName, pLen.getValue(), buffer, null)); + + return buffer; + } + + public long[] getNativeSizes(T entity, int infoName, int n) { + int nBytes = NativeSize.SIZE * n; + NativeSizeByReference pLen = new NativeSizeByReference(toNS(nBytes)); + Memory mem = new Memory(nBytes); + error(getInfo(entity, infoName, toNS(nBytes), mem, null)); + + if (pLen.getValue().longValue() != nBytes) { + throw new RuntimeException("Not a Size[" + n + "] : len = " + pLen.getValue()); + } + long[] longs = new long[n]; + for (int i = 0; i < n; i++) { + longs[i] = readNS(mem, i * NativeSize.SIZE).longValue(); + } + return longs; + } + + public int getOptionalFeatureInt(T entity, int infoName) { + try { + return getInt(entity, infoName); + } catch (CLException.InvalidValue ex) { + throw new UnsupportedOperationException("Cannot get value " + infoName, ex); + } catch (CLException.InvalidOperation ex) { + throw new UnsupportedOperationException("Cannot get value " + infoName, ex); + } + } + public int getInt(T entity, int infoName) { + return (int)getIntOrLong(entity, infoName); + } + + public boolean getBool(T entity, int infoName) { + NativeSizeByReference pLen = new NativeSizeByReference(); + Memory mem = new Memory(8); + error(getInfo(entity, infoName, toNS(8), mem, pLen)); + + switch ((int)pLen.getValue().longValue()) { + case 1: + return mem.getByte(0) != 0; + case 2: + return mem.getShort(0) != 0; + case 4: + return mem.getInt(0) != 0; + case 8: + return mem.getLong(0) != 0; + default: + throw new RuntimeException("Not a BOOL : len = " + pLen.getValue()); + } + } + + public long getIntOrLong(T entity, int infoName) { + NativeSizeByReference pLen = new NativeSizeByReference(); + Memory mem = new Memory(8); + error(getInfo(entity, infoName, toNS(8), mem, pLen)); + + switch (pLen.getValue().intValue()) { + case 4: + return mem.getInt(0); + case 8: + return mem.getLong(0); + default: + throw new RuntimeException("Not a native long : len = " + pLen.getValue()); + } + } +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLIntBuffer.java b/Core/src/main/java/com/nativelibs4java/opencl/CLIntBuffer.java new file mode 100644 index 00000000..41eb0013 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLIntBuffer.java @@ -0,0 +1,49 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; +import java.nio.*; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; + +/** + * OpenCL Memory Buffer Object with Int values.
+ * see {@link CLContext#createIntBuffer(com.nativelibs4java.opencl.CLMem.Usage, long) } + * see {@link CLContext#createIntBuffer(com.nativelibs4java.opencl.CLMem.Usage, java.nio.IntBuffer, boolean) } + * @author Olivier Chafik + * @deprecated Use {@link CLBuffer}<{@link Integer}> + */ +@Deprecated +public class CLIntBuffer extends CLBuffer { + CLIntBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer) { + super(context, byteCount, entity, buffer, 4, IntBuffer.class); + } +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLKernel.java b/Core/src/main/java/com/nativelibs4java/opencl/CLKernel.java old mode 100755 new mode 100644 similarity index 52% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLKernel.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLKernel.java index 81fe07ba..bb0144ed --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLKernel.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLKernel.java @@ -1,9 +1,38 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; import static com.nativelibs4java.opencl.CLException.*; import static com.nativelibs4java.opencl.JavaCL.CL; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; +import static com.nativelibs4java.util.JNAUtils.toNS; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -16,57 +45,61 @@ import java.util.HashMap; import java.util.Map; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_device_id; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_kernel; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_kernel; import com.nativelibs4java.util.NIOUtils; - -import org.bridj.*; -import static org.bridj.Pointer.*; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.ByteByReference; +import com.sun.jna.ptr.DoubleByReference; +import com.sun.jna.ptr.FloatByReference; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; +import com.sun.jna.ptr.PointerByReference; +import com.sun.jna.ptr.ShortByReference; /** * OpenCL kernel.
* A kernel is a function declared in a program.
* A kernel is identified by the __kernel qualifier applied to any function in a program.
- * A kernel object encapsulates the specific __kernel function declared in a program and the argument values to be used when executing this __kernel function.
- *
+ * A kernel object encapsulates the specific __kernel function declared in a program and the argument values to be used when executing this __kernel function.
+ *
* Kernels can be queued for execution in a CLQueue (see enqueueTask and enqueueNDRange) * See {@link CLProgram#createKernel(java.lang.String, java.lang.Object[])} and {@link CLProgram#createKernels()} * @author Olivier Chafik */ -public class CLKernel extends CLAbstractEntity { +public class CLKernel extends CLAbstractEntity { protected final CLProgram program; protected String name; - - #declareInfosGetter("infos", "CL.clGetKernelInfo") + private static CLInfoGetter infos = new CLInfoGetter() { + @Override + protected int getInfo(cl_kernel entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetKernelInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; - private volatile CLInfoGetter kernelInfos; - protected synchronized CLInfoGetter getKernelInfos() { + private volatile CLInfoGetter kernelInfos; + protected synchronized CLInfoGetter getKernelInfos() { if (kernelInfos == null) - kernelInfos = new CLInfoGetter() { + kernelInfos = new CLInfoGetter() { @Override - protected int getInfo(long entity, int infoTypeEnum, long size, Pointer out, Pointer sizeOut) { - return CL.clGetKernelWorkGroupInfo(getEntity(), entity, infoTypeEnum, size, getPeer(out), getPeer(sizeOut)); + protected int getInfo(cl_device_id entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetKernelWorkGroupInfo(getEntity(), entity, infoTypeEnum, size, out, sizeOut); } }; return kernelInfos; } - private final static int MAX_TMP_ITEMS = 16, MAX_TMP_ITEM_SIZE = 8; - - private final Pointer localPointer = Pointer.allocateBytes(MAX_TMP_ITEM_SIZE * MAX_TMP_ITEMS).withoutValidityInformation(); - - private final int contextAddressBits; - - CLKernel(CLProgram program, String name, long entity) { + CLKernel(CLProgram program, String name, cl_kernel entity) { super(entity); this.program = program; this.name = name; - this.contextAddressBits = getProgram().getContext().getAddressBits(); } - public CLProgram getProgram() { return program; } @@ -82,12 +115,16 @@ public String toString() { * @since OpenCL 1.1 */ public Map getPreferredWorkGroupSizeMultiple() { - program.getContext().getPlatform().requireMinVersionValue("CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE", 1.1); - CLDevice[] devices = program.getDevices(); - Map ret = new HashMap(devices.length); - for (CLDevice device : devices) - ret.put(device, getKernelInfos().getIntOrLong(device.getEntity(), CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE)); - return ret; + try { + CLDevice[] devices = program.getDevices(); + Map ret = new HashMap(devices.length); + for (CLDevice device : devices) + ret.put(device, getKernelInfos().getIntOrLong(device.getEntity(), CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE)); + return ret; + } catch (Throwable th) { + // TODO check if supposed to handle OpenCL 1.1 + throw new UnsupportedOperationException("Cannot get CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE (OpenCL 1.1 feature).", th); + } } /** @@ -133,206 +170,175 @@ public Map getLocalMemSize() { } public void setArgs(Object... args) { - //assert getNumArgs() == args.length; - for (int i = 0, n = args.length; i < n; i++) { + for (int i = 0; i < args.length; i++) { setObjectArg(i, args[i]); } } + public static class LocalSize { + long size; + public LocalSize(long size) { + this.size = size; + } + } + private static final NativeSize zeroNS = toNS(0); public static final Object NULL_POINTER_KERNEL_ARGUMENT = new Object() {}; - public void setObjectArg(int iArg, Object arg) { - boolean supported = true; - Class cls; - if (arg instanceof CLAbstractEntity) { - setArg(iArg, (CLAbstractEntity) arg); - } else if (arg instanceof Number) { - if (arg instanceof Integer) { - setArg(iArg, (Integer) arg); - } else if (arg instanceof Long) { - setArg(iArg, (Long) arg); - } else if (arg instanceof Short) { - setArg(iArg, (Short) arg); - } else if (arg instanceof Byte) { - setArg(iArg, (Byte) arg); - } else if (arg instanceof Float) { - setArg(iArg, (Float) arg); - } else if (arg instanceof Double) { - setArg(iArg, (Double) arg); - } else { - supported = false; - } + + if (arg == null) + throw new IllegalArgumentException("Null arguments are not accepted. Please use CLKernel.NULL_POINTER_KERNEL_ARGUMENT instead."); + + if (arg == NULL_POINTER_KERNEL_ARGUMENT) { + setArg(iArg, (NativeSize)zeroNS); + //} else if (arg instanceof NativeLong) { + // setArg(iArg, (NativeLong) arg); + } else if (arg instanceof NativeSize) { + setArg(iArg, (NativeSize) arg); + } else if (arg instanceof CLMem) { + setArg(iArg, (CLMem) arg); + } else if (arg instanceof CLEvent) { + setArg(iArg, (CLEvent) arg); + } else if (arg instanceof CLSampler) { + setArg(iArg, (CLSampler) arg); + } else if (arg instanceof Integer) { + setArg(iArg, (Integer) arg); } else if (arg instanceof LocalSize) { - setArg(iArg, (LocalSize)arg); + setArg(iArg, (LocalSize)arg); + } else if (arg instanceof Long) { + setArg(iArg, (Long) arg); + } else if (arg instanceof Short) { + setArg(iArg, (Short) arg); + } else if (arg instanceof Byte) { + setArg(iArg, (Byte) arg); + } else if (arg instanceof Float) { + setArg(iArg, (Float) arg); + } else if (arg instanceof Double) { + setArg(iArg, (Double) arg); } else if (arg instanceof Boolean) { - setArg(iArg, (Boolean)arg); - } else if (arg instanceof SizeT) { - setArg(iArg, (SizeT)arg); - } else if (arg == NULL_POINTER_KERNEL_ARGUMENT) { - setArg(iArg, SizeT.ZERO); - } else if ((cls = arg.getClass()).isArray()) { - if (arg instanceof int[]) { - setArg(iArg, (int[])arg); - } else if (arg instanceof long[]) { - setArg(iArg, (long[])arg); - } else if (arg instanceof short[]) { - setArg(iArg, (short[])arg); - } else if (arg instanceof double[]) { - setArg(iArg, (double[])arg); - } else if (arg instanceof float[]) { - setArg(iArg, (float[])arg); - } else if (arg instanceof byte[]) { - setArg(iArg, (byte[])arg); - } else if (arg instanceof boolean[]) { - setArg(iArg, (boolean[])arg); - } else { - supported = false; - } - } else if (arg instanceof Pointer) { - setArg(iArg, (Pointer)arg); + setArg(iArg, (byte)(Boolean.TRUE.equals(arg) ? 1 : 0)); } else if (arg instanceof Buffer) { - setArg(iArg, pointerToBuffer((Buffer) arg)); + setArg(iArg, (Buffer) arg); + } else if (arg instanceof int[]) { + setArg(iArg, IntBuffer.wrap((int[])arg)); + } else if (arg instanceof long[]) { + setArg(iArg, LongBuffer.wrap((long[])arg)); + } else if (arg instanceof short[]) { + setArg(iArg, ShortBuffer.wrap((short[])arg)); + } else if (arg instanceof double[]) { + setArg(iArg, DoubleBuffer.wrap((double[])arg)); + } else if (arg instanceof float[]) { + setArg(iArg, FloatBuffer.wrap((float[])arg)); + } else if (arg instanceof byte[]) { + setArg(iArg, ByteBuffer.wrap((byte[])arg)); + } else if (arg instanceof boolean[]) { + boolean[] bools = (boolean[])arg; + byte[] bytes = new byte[bools.length]; + for (int iValue = 0, n = bools.length; iValue < n; iValue++) + bytes[iValue] = (byte)(bools[iValue] ? 1 : 0); + setArg(iArg, ByteBuffer.wrap(bytes)); } else { - supported = false; - } - if (arg == null) - throw new IllegalArgumentException("Null arguments are not accepted. Please use CLKernel.NULL_POINTER_KERNEL_ARGUMENT instead."); - - if (!supported) { throw new IllegalArgumentException("Cannot handle kernel arguments of type " + arg.getClass().getName() + ". Use CLKernel.get() and OpenCL4Java directly."); } } - /** -#documentCallsFunction("clSetKernelArg") - */ public void setArg(int i, LocalSize arg) { setLocalArg(i, arg.size); } public void setLocalArg(int argIndex, long localArgByteLength) { - setKernelArg(argIndex, localArgByteLength, null); + setKernelArg(argIndex, toNS(localArgByteLength), null); } - private void setKernelArg(int i, long size, Pointer ptr) { - if (size <= 0) - throw new IllegalArgumentException("Kernel args must have a known byte size, given " + size + " instead."); + //public void setArg(int i, NativeLong arg) { + // error(CL.clSetKernelArg(getEntity(), i, toNS(NativeLong.SIZE), new NativeLongByReference(arg).getPointer())); +// error(CL.clSetKernelArg(get(), i, OpenCL4Java.toNL(Native.LONG_SIZE), new IntByReference(128).getPointer())); +// error(CL.clSetKernelArg(get(), i, toNL(Native.LONG_SIZE), new IntByReference(arg.intValue()).getPointer())); + //} + + public void setArg(int i, float[] arg) { + setArg(i, FloatBuffer.wrap(arg)); + } + public void setArg(int i, int[] arg) { + setArg(i, IntBuffer.wrap(arg)); + } + public void setArg(int i, double[] arg) { + setArg(i, DoubleBuffer.wrap(arg)); + } + public void setArg(int i, long[] arg) { + setArg(i, LongBuffer.wrap(arg)); + } + public void setArg(int i, short[] arg) { + setArg(i, ShortBuffer.wrap(arg)); + } + public void setArg(int i, byte[] arg) { + setArg(i, ByteBuffer.wrap(arg)); + } + public void setArg(int i, char[] arg) { + setArg(i, CharBuffer.wrap(arg)); + } + public void setArg(int i, Buffer arg) { + if (!arg.isDirect()) + arg = NIOUtils.directCopy(arg, getProgram().getContext().getByteOrder()); + long size = NIOUtils.getSizeInBytes(arg); + setKernelArg(i, toNS(size), Native.getDirectBufferPointer(arg)); + } + + protected void setKernelArg(int i, NativeSize size, Pointer ptr) { try { - error(CL.clSetKernelArg(getEntity(), i, size, getPeer(ptr))); + error(CL.clSetKernelArg(getEntity(), i, size, ptr)); } catch (CLTypedException ex) { - ex.setKernelArg(this, i, size, ptr); + ex.setKernelArg(this, i); throw ex; } } - - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, Pointer ptr) { - setKernelArg(i, ptr.getValidBytes(), ptr); - } - -#foreach ($prim in $primitives) - /** - * Sets a vector type value as the arg at index {@code i}. - * - * For instance to pass a {@code ${prim.Name}3}, one must pass a {@code ${prim.Name}[]} of size {@code 3}. - * -#documentCallsFunction("clSetKernelArg") - * @param i index of the argument in the kernel's parameters list - * @param arg array of ${prim.Name}s (of length 2, 3, 4, 8 or 16, which must match the arity of the OpenCL vector type used by the kernel). - */ - public void setArg(int i, ${prim.Name}[] arg) { - int length = normalizeVectorTypeArity(arg.length); - setKernelArg(i, length * ${prim.Size}, length <= MAX_TMP_ITEMS ? localPointer.set${prim.CapName}s(arg) : pointerTo${prim.CapName}s(arg)); - } -#end - - private static int normalizeVectorTypeArity(int length) { - switch (length) { - case 3: - // cl_3 is identical in size, alignment and behavior to cl_4. See section 6.1.5 - return 4; - case 2: - case 4: - case 8: - case 16: - return length; - default: - throw new IllegalArgumentException("Invalid vector type length: " + length + " (valid vector type sizes are 2, 3, 4, 8, 16)"); - } - } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, SizeT arg) { - switch (contextAddressBits) { + public void setArg(int i, NativeSize arg) { + switch (getProgram().getContext().getAddressBits()) { case 32: - setKernelArg(i, 4, localPointer.setInt(arg.intValue())); + setKernelArg(i, toNS(4), new IntByReference(arg.intValue()).getPointer()); break; case 64: - setKernelArg(i, 8, localPointer.setLong(arg.longValue())); + setKernelArg(i, toNS(8), new LongByReference(arg.longValue()).getPointer()); break; default: - setKernelArg(i, SizeT.SIZE, localPointer.setSizeT(arg.longValue())); + setKernelArg(i, toNS(NativeSize.SIZE), new NativeSizeByReference(arg).getPointer()); break; } } - /** -#documentCallsFunction("clSetKernelArg") - */ public void setArg(int i, int arg) { - setKernelArg(i, 4, localPointer.setInt(arg)); + setKernelArg(i, toNS(4), new IntByReference(arg).getPointer()); } - /** -#documentCallsFunction("clSetKernelArg") - */ public void setArg(int i, long arg) { - setKernelArg(i, 8, localPointer.setLong(arg)); + setKernelArg(i, toNS(8), new LongByReference(arg).getPointer()); } - /** -#documentCallsFunction("clSetKernelArg") - */ public void setArg(int i, short arg) { - setKernelArg(i, 2, localPointer.setShort(arg)); + setKernelArg(i, toNS(2), new ShortByReference(arg).getPointer()); } - /** -#documentCallsFunction("clSetKernelArg") - */ public void setArg(int i, byte arg) { - setKernelArg(i, 1, localPointer.setByte(arg)); + setKernelArg(i, toNS(1), new ByteByReference(arg).getPointer()); } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, boolean arg) { - setKernelArg(i, 1, localPointer.setByte(arg ? (byte)1 : (byte)0)); - } - - /** -#documentCallsFunction("clSetKernelArg") - */ public void setArg(int i, float arg) { - setKernelArg(i, 4, localPointer.setFloat(arg)); + setKernelArg(i, toNS(4), new FloatByReference(arg).getPointer()); } - /** -#documentCallsFunction("clSetKernelArg") - */ public void setArg(int i, double arg) { - setKernelArg(i, 8, localPointer.setDouble(arg)); + setKernelArg(i, toNS(8), new DoubleByReference(arg).getPointer()); } - /** -#documentCallsFunction("clSetKernelArg") - */ - public void setArg(int i, CLAbstractEntity arg) { - setKernelArg(i, Pointer.SIZE, localPointer.setSizeT(arg.getEntity())); + public void setArg(int index, CLMem mem) { + setKernelArg(index, toNS(Pointer.SIZE), new PointerByReference(mem.getEntity().getPointer()).getPointer()); + } + + public void setArg(int index, CLEvent event) { + setKernelArg(index, toNS(Pointer.SIZE), new PointerByReference(event.getEntity().getPointer()).getPointer()); + } + + public void setArg(int index, CLSampler sampler) { + setKernelArg(index, toNS(Pointer.SIZE), new PointerByReference(sampler.getEntity().getPointer()).getPointer()); } @Override @@ -340,91 +346,63 @@ protected void clear() { error(CL.clReleaseKernel(getEntity())); } - private static final Pointer oneNL = pointerToSizeT(1); + private static final NativeSize[] oneNL = new NativeSize[] {new NativeSize(1)}; /** -#documentCallsFunction("clEnqueueTask") * Enqueues a command to execute a kernel on a device.
* The kernel is executed using a single work-item. * @param queue -#documentEventsToWaitForAndReturn() + * @param eventsToWaitFor Events that need to complete before this particular command can be executed. + * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete. */ public CLEvent enqueueTask(CLQueue queue, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueTask(queue.getEntity(), getEntity(), #eventsInOutArgsRaw())); - #returnEventOut("queue") + cl_event[] eventOut = CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueNDRangeKernel(queue.getEntity(), getEntity(), 1, null, oneNL, oneNL, evts == null ? 0 : evts.length, evts, eventOut)); + return CLEvent.createEvent(queue, eventOut); } /** -#documentCallsFunction("clEnqueueNDRangeKernel") * Enqueues a command to execute a kernel on a device (see {@link CLKernel#enqueueNDRange(CLQueue, int[], int[], int[], CLEvent[])}) * @param globalWorkSizes Each element describes the number of global work-items in a dimension that will execute the kernel function. The total number of global work-items is computed as globalWorkSizes[0] * ... * globalWorkSizes[globalWorkSizes.length - 1]. * @param localWorkSizes Each element describes the number of work-items that make up a work-group (also referred to as the size of the work-group) that will execute the kernel specified by kernel. The total number of work-items in a work-group is computed as localWorkSizes[0] * ... * localWorkSizes[localWorkSizes.length - 1]. The total number of work-items in the work-group must be less than or equal to the CL_DEVICE_MAX_WORK_GROUP_SIZE value specified in table 4.3 and the number of work- items specified in localWorkSizes[0], ... localWorkSizes[localWorkSizes.length - 1] must be less than or equal to the corresponding values specified by CLDevice.getMaxWorkItemSizes()[dimensionIndex]. The explicitly specified localWorkSize will be used to determine how to break the global work-items specified by global_work_size into appropriate work-group instances. If localWorkSize is specified, the values specified in globalWorkSize[dimensionIndex] must be evenly divisible by the corresponding values specified in localWorkSize[dimensionIndex]. This parameter can be left null, in which case the OpenCL implementation will choose good values. * @param queue This kernel will be queued for execution on the device associated with that queue. -#documentEventsToWaitForAndReturn() + * @param eventsToWaitFor Events that need to complete before this particular command can be executed. + * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete. */ public CLEvent enqueueNDRange(CLQueue queue /*, int[] globalOffsets*/, int[] globalWorkSizes, int[] localWorkSizes, CLEvent... eventsToWaitFor) { return enqueueNDRange(queue, null, globalWorkSizes, localWorkSizes, eventsToWaitFor); } /** -#documentCallsFunction("clEnqueueNDRangeKernel") * Enqueues a command to execute a kernel on a device, using local work sizes chosen by the OpenCL implementation. * See {@link CLKernel#enqueueNDRange(CLQueue, int[], int[], int[], CLEvent[])} * @param globalWorkSizes Each element describes the number of global work-items in a dimension that will execute the kernel function. The total number of global work-items is computed as globalWorkSizes[0] * ... * globalWorkSizes[globalWorkSizes.length - 1]. * @param queue This kernel will be queued for execution on the device associated with that queue. -#documentEventsToWaitForAndReturn() + * @param eventsToWaitFor Events that need to complete before this particular command can be executed. + * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete. */ public CLEvent enqueueNDRange(CLQueue queue /*, int[] globalOffsets*/, int[] globalWorkSizes, CLEvent... eventsToWaitFor) { return enqueueNDRange(queue, null, globalWorkSizes, null, eventsToWaitFor); } /** -#documentCallsFunction("clEnqueueNDRangeKernel") * Enqueues a command to execute a kernel on a device. * @param globalOffsets Must be null in OpenCL 1.0. Each element describes the offset used to calculate the global ID of a work-item. If globalOffsets is null, the global IDs start at offset (0, 0, ... 0). * @param globalWorkSizes Each element describes the number of global work-items in a dimension that will execute the kernel function. The total number of global work-items is computed as globalWorkSizes[0] * ... * globalWorkSizes[globalWorkSizes.length - 1]. * @param localWorkSizes Each element describes the number of work-items that make up a work-group (also referred to as the size of the work-group) that will execute the kernel specified by kernel. The total number of work-items in a work-group is computed as localWorkSizes[0] * ... * localWorkSizes[localWorkSizes.length - 1]. The total number of work-items in the work-group must be less than or equal to the CL_DEVICE_MAX_WORK_GROUP_SIZE value specified in table 4.3 and the number of work- items specified in localWorkSizes[0], ... localWorkSizes[localWorkSizes.length - 1] must be less than or equal to the corresponding values specified by CLDevice.getMaxWorkItemSizes()[dimensionIndex]. The explicitly specified localWorkSize will be used to determine how to break the global work-items specified by global_work_size into appropriate work-group instances. If localWorkSize is specified, the values specified in globalWorkSize[dimensionIndex] must be evenly divisible by the corresponding values specified in localWorkSize[dimensionIndex]. This parameter can be left null, in which case the OpenCL implementation will choose good values. * @param queue This kernel will be queued for execution on the device associated with that queue. -#documentEventsToWaitForAndReturn() + * @param eventsToWaitFor Events that need to complete before this particular command can be executed. + * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete. */ - public CLEvent enqueueNDRange(CLQueue queue, long[] globalOffsets, long[] globalWorkSizes, long[] localWorkSizes, CLEvent... eventsToWaitFor) { - int nDims = globalWorkSizes.length; - if (localWorkSizes != null && localWorkSizes.length != nDims) { - throw new IllegalArgumentException("Global and local sizes must have same dimensions, given " + globalWorkSizes.length + " vs. " + localWorkSizes.length); - } - - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueNDRangeKernel( - queue.getEntity(), - getEntity(), - nDims, - getPeer(ptrs.sizeT3_1.pointerToSizeTs(globalOffsets)), - getPeer(ptrs.sizeT3_2.pointerToSizeTs(globalWorkSizes)), - getPeer(ptrs.sizeT3_3.pointerToSizeTs(localWorkSizes)), - #eventsInOutArgsRaw() - )); - #returnEventOut("queue") - } - - /** - * @deprecated Use {@link CLKernel#enqueueNDRange(CLQueue, long[], long[], long[], CLEvent[])} instead. - */ - @Deprecated public CLEvent enqueueNDRange(CLQueue queue, int[] globalOffsets, int[] globalWorkSizes, int[] localWorkSizes, CLEvent... eventsToWaitFor) { int nDims = globalWorkSizes.length; if (localWorkSizes != null && localWorkSizes.length != nDims) { throw new IllegalArgumentException("Global and local sizes must have same dimensions, given " + globalWorkSizes.length + " vs. " + localWorkSizes.length); } - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueNDRangeKernel( - queue.getEntity(), - getEntity(), - nDims, - getPeer(ptrs.sizeT3_1.pointerToSizeTs(globalOffsets)), - getPeer(ptrs.sizeT3_2.pointerToSizeTs(globalWorkSizes)), - getPeer(ptrs.sizeT3_3.pointerToSizeTs(localWorkSizes)), - #eventsInOutArgsRaw())); - #returnEventOut("queue") + cl_event[] eventOut = CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueNDRangeKernel(queue.getEntity(), getEntity(), nDims, toNS(globalOffsets), toNS(globalWorkSizes), toNS(localWorkSizes), evts == null ? 0 : evts.length, evts, eventOut)); + return CLEvent.createEvent(queue, eventOut); } /** @@ -432,9 +410,7 @@ public CLEvent enqueueNDRange(CLQueue queue, int[] globalOffsets, int[] globalWo */ @InfoName("CL_KERNEL_NUM_ARGS") public int getNumArgs() { - int numArgs = infos.getInt(getEntity(), CL_KERNEL_NUM_ARGS); - //System.out.println("numArgs = " + numArgs); - return numArgs; + return infos.getInt(getEntity(), CL_KERNEL_NUM_ARGS); } /** @@ -446,4 +422,6 @@ public String getFunctionName() { name = infos.getString(getEntity(), CL_KERNEL_FUNCTION_NAME); return name; } + + } diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLLongBuffer.java b/Core/src/main/java/com/nativelibs4java/opencl/CLLongBuffer.java new file mode 100644 index 00000000..c8ad8ea2 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLLongBuffer.java @@ -0,0 +1,49 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; +import java.nio.*; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; + +/** + * OpenCL Memory Buffer Object with Long values.
+ * see {@link CLContext#createLongBuffer(com.nativelibs4java.opencl.CLMem.Usage, long) } + * see {@link CLContext#createLongBuffer(com.nativelibs4java.opencl.CLMem.Usage, java.nio.LongBuffer, boolean) } + * @author Olivier Chafik + * @deprecated Use {@link CLBuffer}<{@link Long}> + */ +@Deprecated +public class CLLongBuffer extends CLBuffer { + CLLongBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer) { + super(context, byteCount, entity, buffer, 8, LongBuffer.class); + } +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLMem.java b/Core/src/main/java/com/nativelibs4java/opencl/CLMem.java similarity index 74% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLMem.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLMem.java index 09ca002c..a8ce2aca 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLMem.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLMem.java @@ -1,20 +1,50 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; import static com.nativelibs4java.opencl.CLException.error; import static com.nativelibs4java.opencl.JavaCL.CL; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; import java.util.EnumSet; import com.nativelibs4java.opencl.library.OpenCLLibrary; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; import com.nativelibs4java.util.EnumValue; import com.nativelibs4java.util.EnumValues; -import org.bridj.ann.Ptr; -import org.bridj.*; -import static org.bridj.Pointer.*; -import static com.nativelibs4java.opencl.proxy.PointerUtils.*; +import com.nativelibs4java.util.ValuedEnum; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Callback; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; /** * OpenCL memory object.
@@ -31,16 +61,21 @@ * Kernels take memory objects as input, and output to one or more memory objects. * @author Olivier Chafik */ -public abstract class CLMem extends CLAbstractEntity { +public abstract class CLMem extends CLAbstractEntity { protected final CLContext context; protected long byteCount = -1; boolean isGL; - #declareInfosGetter("infos", "CL.clGetImageInfo") + protected static CLInfoGetter infos = new CLInfoGetter() { + @Override + protected int getInfo(cl_mem entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetImageInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; - CLMem(CLContext context, long byteCount, long entityPeer) { - super(entityPeer); + CLMem(CLContext context, long byteCount, cl_mem entity) { + super(entity); this.byteCount = byteCount; this.context = context; } @@ -54,7 +89,6 @@ public interface DestructorCallback { } /** -#documentCallsFunction("clSetMemObjectDestructorCallback") * Registers a user callback function that will be called when the memory object is deleted and its resources freed.
* Each call to clSetMemObjectDestructorCallback registers the specified user callback function on a callback stack associated with memobj.
* The registered user callback functions are called in the reverse order in which they were registered.
@@ -64,15 +98,12 @@ public interface DestructorCallback { * @param callback */ public void setDestructorCallback(final DestructorCallback callback) { - context.getPlatform().requireMinVersionValue("clSetMemObjectDestructorCallback", 1.1); - clSetMemObjectDestructorCallback_arg1_callback cb = new clSetMemObjectDestructorCallback_arg1_callback() { - @Override - public void apply(@Ptr long mem, @Ptr long userData) { + error(CL.clSetMemObjectDestructorCallback(getEntity(), new clSetMemObjectDestructorCallback_arg1_callback() { + /// @param cl_mem1 user_data + public void invoke(OpenCLLibrary.cl_mem mem, Pointer userData) { callback.callback(CLMem.this); } - }; - BridJ.protectFromGC(cb); - error(CL.clSetMemObjectDestructorCallback(getEntity(), getPeer(getPointer(cb)), 0)); + }, null)); } public CLEvent acquireGLObject(CLQueue queue, CLEvent... eventsToWaitFor) { @@ -123,36 +154,7 @@ public Flags getFlags() { } } - /** - * Memory object migration options (see {@link CLQueue#enqueueMigrateMemObjects(CLMem[], java.lang.EnumSet, CLEvent[])}). - */ - public enum Migration implements com.nativelibs4java.util.ValuedEnum { - /** - * This flag indicates that the specified set of memory objects are to be migrated - * to the host, regardless of the target command-queue. - */ - Host(CL_MIGRATE_MEM_OBJECT_HOST), - /** - * This flag indicates that the contents of the set of memory objects are undefined after - * migration. The specified set of memory objects are migrated to the device associated with - * command_queue without incurring the overhead of migrating their contents. - */ - ContentUndefined(CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED); - - Migration(long value) { this.value = value; } - long value; - @Override - public long value() { return value; } - public static long getValue(EnumSet set) { - return EnumValues.getValue(set); - } - - public static EnumSet getEnumSet(long v) { - return EnumValues.getEnumSet(v, Migration.class); - } - } - - public enum Flags implements com.nativelibs4java.util.ValuedEnum { + public enum Flags implements ValuedEnum { /** * This flag specifies that the memory object will be read and written by a kernel. This is the default. */ @@ -190,7 +192,7 @@ public enum Flags implements com.nativelibs4java.util.ValuedEnum { public static long getValue(EnumSet set) { return EnumValues.getValue(set); } public static EnumSet getEnumSet(long v) { return EnumValues.getEnumSet(v, Flags.class); } } - public enum ObjectType implements com.nativelibs4java.util.ValuedEnum { + public enum ObjectType implements ValuedEnum { Buffer(CL_MEM_OBJECT_BUFFER), Image2D(CL_MEM_OBJECT_IMAGE2D), Image3D(CL_MEM_OBJECT_IMAGE3D); @@ -202,7 +204,7 @@ public enum ObjectType implements com.nativelibs4java.util.ValuedEnum { public static ObjectType getEnum(long v) { return EnumValues.getEnum(v, ObjectType.class); } } - public enum GLObjectType implements com.nativelibs4java.util.ValuedEnum { + public enum GLObjectType implements ValuedEnum { Buffer(CL_GL_OBJECT_BUFFER), RenderBuffer(CL_GL_OBJECT_RENDERBUFFER), Texture2D(CL_GL_OBJECT_TEXTURE2D), @@ -229,22 +231,17 @@ public int getName() { return name; } } - /** -#documentCallsFunction("clGetGLObjectInfo") - */ @SuppressWarnings("deprecation") public GLObjectInfo getGLObjectInfo() { - #declareReusablePtrs() - Pointer typeRef = ptrs.int1; - Pointer nameRef = ptrs.int2; - CL.clGetGLObjectInfo(getEntity(), getPeer(typeRef), getPeer(nameRef)); - return new GLObjectInfo(GLObjectType.getEnum(typeRef.getInt()), nameRef.getInt()); + IntByReference typeRef = new IntByReference(); + IntByReference nameRef = new IntByReference(); + CL.clGetGLObjectInfo(getEntity(), typeRef, nameRef); + return new GLObjectInfo(GLObjectType.getEnum(typeRef.getValue()), nameRef.getValue()); } - public enum MapFlags implements com.nativelibs4java.util.ValuedEnum { + public enum MapFlags implements ValuedEnum { Read(CL_MAP_READ), Write(CL_MAP_WRITE), - ReadWrite(CL_MAP_READ | CL_MAP_WRITE), - WriteInvalidateRegion(CL_MAP_WRITE_INVALIDATE_REGION); + ReadWrite(CL_MAP_READ | CL_MAP_WRITE); MapFlags(long value) { this.value = value; } long value; diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLPlatform.java b/Core/src/main/java/com/nativelibs4java/opencl/CLPlatform.java similarity index 63% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLPlatform.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLPlatform.java index b4f05684..d2c910fe 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLPlatform.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLPlatform.java @@ -1,38 +1,68 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; + +import com.nativelibs4java.util.ValuedEnum; import com.nativelibs4java.opencl.library.OpenGLContextUtils; import com.nativelibs4java.util.EnumValue; import com.nativelibs4java.util.EnumValues; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; - -import org.bridj.*; -import org.bridj.ann.*; -import static org.bridj.Pointer.*; - +import com.sun.jna.*; +import com.sun.jna.ptr.*; import java.nio.ByteOrder; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.logging.*; -import java.util.concurrent.ConcurrentHashMap; - import static com.nativelibs4java.opencl.JavaCL.*; import static com.nativelibs4java.opencl.CLException.*; +import static com.nativelibs4java.util.JNAUtils.*; /** * OpenCL implementation entry point. * see {@link JavaCL#listPlatforms() } * @author Olivier Chafik */ -public class CLPlatform extends CLAbstractEntity { +public class CLPlatform extends CLAbstractEntity { - CLPlatform(long platform) { + CLPlatform(cl_platform_id platform) { super(platform, true); } - - #declareInfosGetter("infos", "CL.clGetPlatformInfo") + private static CLInfoGetter infos = new CLInfoGetter() { + + @Override + protected int getInfo(cl_platform_id entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetPlatformInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; @Override public String toString() { @@ -94,13 +124,13 @@ public CLDevice[] listCPUDevices(boolean onlyAvailable) { } } - private CLDevice[] getDevices(Pointer ids, boolean onlyAvailable) { - int nDevs = (int)ids.getValidElements(); + private CLDevice[] getDevices(cl_device_id[] ids, boolean onlyAvailable) { + int nDevs = ids.length; CLDevice[] devices; if (onlyAvailable) { List list = new ArrayList(nDevs); for (int i = 0; i < nDevs; i++) { - CLDevice device = new CLDevice(this, ids.getSizeTAtIndex(i)); + CLDevice device = new CLDevice(this, ids[i]); if (device.isAvailable()) { list.add(device); } @@ -109,31 +139,28 @@ private CLDevice[] getDevices(Pointer ids, boolean onlyAvailable) { } else { devices = new CLDevice[nDevs]; for (int i = 0; i < nDevs; i++) { - devices[i] = new CLDevice(this, ids.getSizeTAtIndex(i)); + devices[i] = new CLDevice(this, ids[i]); } } return devices; } - long[] getContextProps(Map contextProperties) { - int nContextProperties = contextProperties == null ? 0 : contextProperties.size(); - final long[] properties = new long[(nContextProperties + 1) * 2 + 1]; - properties[0] = CL_CONTEXT_PLATFORM; - properties[1] = getEntity(); - int iProp = 2; - if (nContextProperties != 0) { - for (Map.Entry e : contextProperties.entrySet()) { - //if (!(v instanceof Number)) throw new IllegalArgumentException("Invalid context property value for '" + e.getKey() + ": " + v); - properties[iProp++] = e.getKey().value(); - Object v = e.getValue(); - if (v instanceof Number) - properties[iProp++] = ((Number)v).longValue(); - else if (v instanceof Pointer) - properties[iProp++] = ((Pointer)v).getPeer(); - else - throw new IllegalArgumentException("Cannot convert value " + v + " to a context property value !"); - } - } + static long[] getContextProps(Map contextProperties) { + if (contextProperties == null) + return null; + final long[] properties = new long[contextProperties.size() * 2 + 1]; + int iProp = 0; + for (Map.Entry e : contextProperties.entrySet()) { + //if (!(v instanceof Number)) throw new IllegalArgumentException("Invalid context property value for '" + e.getKey() + ": " + v); + properties[iProp++] = e.getKey().value(); + Object v = e.getValue(); + if (v instanceof Number) + properties[iProp++] = ((Number)v).longValue(); + else if (v instanceof Pointer) + properties[iProp++] = PointerUtils.getAddress((Pointer)v); + else + throw new IllegalArgumentException("Cannot convert value " + v + " to a context property value !"); + } //properties[iProp] = 0; return properties; } @@ -175,7 +202,7 @@ Comparable extractValue(CLDevice device) { } }, /** - * Prefer devices with the same byte ordering as the hosting platform (see {@link CLDevice#getByteOrder() }) + * Prefer devices with the same byte ordering as the hosting platform (see {@link CLDevice#getKernelsDefaultByteOrder() }) */ NativeEndianness { Comparable extractValue(CLDevice device) { @@ -207,7 +234,7 @@ Comparable extractValue(CLDevice device) { } }, /** - * Prefer devices with the greatest variety of supported image formats (see {@link CLContext#getSupportedImageFormats(CLMem.Flags, CLMem.ObjectType) }) + * Prefer devices with the greatest variety of supported image formats (see {@link CLContext#getSupportedImageFormats() }) */ MostImageFormats { Comparable extractValue(CLDevice device) { @@ -257,11 +284,11 @@ public static CLDevice getBestDevice(List evals, Collection getGLContextProperties(CLPlatform platform) { Map out = new LinkedHashMap(); - if (Platform.isMacOSX()) { - Pointer context = OpenGLContextUtils.CGLGetCurrentContext(); - Pointer shareGroup = OpenGLContextUtils.CGLGetShareGroup(context); - out.put(ContextProperties.CGLShareGroupApple, shareGroup.getPeer()); + if (Platform.isMac()) { + NativeSize context = OpenGLContextUtils.INSTANCE.CGLGetCurrentContext(); + NativeSize shareGroup = OpenGLContextUtils.INSTANCE.CGLGetShareGroup(context); + out.put(ContextProperties.CGLShareGroupApple, shareGroup.longValue()); } else if (Platform.isWindows()) { - Pointer context = OpenGLContextUtils.wglGetCurrentContext(); - Pointer dc = OpenGLContextUtils.wglGetCurrentDC(); - out.put(ContextProperties.GLContext, context.getPeer()); - out.put(ContextProperties.WGLHDC, dc.getPeer()); - out.put(ContextProperties.Platform, platform.getEntity()); - } else if (Platform.isUnix()) { - Pointer context = OpenGLContextUtils.glXGetCurrentContext(); - Pointer dc = OpenGLContextUtils.glXGetCurrentDisplay(); - out.put(ContextProperties.GLContext, context.getPeer()); - out.put(ContextProperties.GLXDisplay, dc.getPeer()); - out.put(ContextProperties.Platform, platform.getEntity()); + NativeSize context = OpenGLContextUtils.INSTANCE.wglGetCurrentContext(); + NativeSize dc = OpenGLContextUtils.INSTANCE.wglGetCurrentDC(); + out.put(ContextProperties.GLContext, context.longValue()); + out.put(ContextProperties.WGLHDC, dc.longValue()); + out.put(ContextProperties.Platform, PointerUtils.getAddress(platform.getEntity().getPointer())); + } else if (Platform.isX11()) { + NativeSize context = OpenGLContextUtils.INSTANCE.glXGetCurrentContext(); + NativeSize dc = OpenGLContextUtils.INSTANCE.glXGetCurrentDisplay(); + out.put(ContextProperties.GLContext, context.longValue()); + out.put(ContextProperties.GLXDisplay, dc.longValue()); + out.put(ContextProperties.Platform, PointerUtils.getAddress(platform.getEntity().getPointer())); } else throw new UnsupportedOperationException("Current GL context retrieval not implemented on this platform !"); @@ -315,9 +342,6 @@ static Map getGLContextProperties(CLPlatform platform return out; } - /** -#documentCallsFunction("clCreateContext") - */ @Deprecated public CLContext createGLCompatibleContext(CLDevice... devices) { for (CLDevice device : devices) { @@ -332,7 +356,6 @@ public CLContext createGLCompatibleContext(CLDevice... devices) { } /** -#documentCallsFunction("clCreateContext") * Creates an OpenCL context formed of the provided devices.
* It is generally not a good idea to create a context with more than one device, * because much data is shared between all the devices in the same context. @@ -344,41 +367,73 @@ public CLContext createContext(Map contextProperties, if (nDevs == 0) { throw new IllegalArgumentException("Cannot create a context with no associated device !"); } - Pointer ids = allocateSizeTs(nDevs); + cl_device_id[] ids = new cl_device_id[nDevs]; for (int i = 0; i < nDevs; i++) { - ids.setSizeTAtIndex(i, devices[i].getEntity()); + ids[i] = devices[i].getEntity(); } - #declareReusablePtrsAndPErr() + IntByReference errRef = new IntByReference(); long[] props = getContextProps(contextProperties); - Pointer propsRef = props == null ? null : pointerToSizeTs(props); - //System.out.println("ERROR CALLBACK " + Long.toHexString(errCb.getPeer())); - long context = CL.clCreateContext(getPeer(propsRef), nDevs, getPeer(ids), 0, 0, getPeer(pErr)); - #checkPErr(); + Memory propsMem = toNSArray(props); + NativeSizeByReference propsRef = new NativeSizeByReference(); + propsRef.setPointer(propsMem); + cl_context context = CL.clCreateContext(propsRef, ids.length, ids, null/*errorCallback.getPointer()*/, null, errRef); + error(errRef.getValue()); return new CLContext(this, ids, context); } - + /* + public static final clCreateContext_arg1_callback errorCallback = new clCreateContext_arg1_callback() { + public void apply(Pointer errInfo, Pointer private_info, @Ptr long cb, Pointer user_data) { + String log = errInfo.getCString(); + System.out.println("[JavaCL] " + log); + throw new CLException(log); + } + }; + */ + /** -#documentCallsFunction("clGetDeviceIDs") * List all the devices of the specified types, with only the ones declared as available if onlyAvailable is true. */ @SuppressWarnings("deprecation") public CLDevice[] listDevices(CLDevice.Type type, boolean onlyAvailable) { - Pointer pCount = allocateInt(); - error(CL.clGetDeviceIDs(getEntity(), type.value(), 0, 0, getPeer(pCount))); + IntByReference pCount = new IntByReference(); + error(CL.clGetDeviceIDs(getEntity(), type.value(), 0, (PointerByReference) null, pCount)); - int nDevs = pCount.getInt(); - if (nDevs <= 0) { + int nDevs = pCount.getValue(); + if (nDevs == 0) { return new CLDevice[0]; } - Pointer ids = allocateSizeTs(nDevs); + cl_device_id[] ids = new cl_device_id[nDevs]; - error(CL.clGetDeviceIDs(getEntity(), type.value(), nDevs, getPeer(ids), 0)); + error(CL.clGetDeviceIDs(getEntity(), type.value(), nDevs, ids, pCount)); return getDevices(ids, onlyAvailable); } + /* + public CLDevice[] listGLDevices(long openglContextId, boolean onlyAvailable) { + + IntByReference errRef = new IntByReference(); + long[] props = getContextProps(getGLContextProperties()); + Memory propsMem = toNSArray(props); + NativeSizeByReference propsRef = new NativeSizeByReference(); + propsRef.setPointer(propsMem); + + NativeSizeByReference pCount = new NativeSizeByReference(); + error(CL.clGetGLContextInfoKHR(propsRef, CL_DEVICES_FOR_GL_CONTEXT_KHR, toNS(0), (Pointer) null, pCount)); + + int nDevs = pCount.getValue().intValue(); + if (nDevs == 0) + return new CLDevice[0]; + Memory idsMem = new Memory(nDevs * Pointer.SIZE); + error(CL.clGetGLContextInfoKHR(propsRef, CL_DEVICES_FOR_GL_CONTEXT_KHR, toNS(nDevs), idsMem, pCount)); + cl_device_id[] ids = new cl_device_id[nDevs]; + for (int i = 0; i < nDevs; i++) + ids[i] = new cl_device_id(idsMem.getPointer(i * Pointer.SIZE)); + return getDevices(ids, onlyAvailable); + }*/ + /** * OpenCL profile string. Returns the profile name supported by the implementation. The profile name returned can be one of the following strings: *
    @@ -393,7 +448,7 @@ public String getProfile() { /** OpenCL version string. Returns the OpenCL version supported by the implementation. This version string has the following format: - OpenCL<space><major_version.min or_version><space><platform- specific information> + OpenCL Last Revision Date: 5/16/09 Page 30 The major_version.minor_version value returned will be 1.0. */ @@ -402,42 +457,6 @@ public String getVersion() { return infos.getString(getEntity(), CL_PLATFORM_VERSION); } - private double versionValue = Double.NaN; - private static final Pattern VERSION_PATTERN = Pattern.compile("OpenCL (\\d+\\.\\d+)\\b.*"); - double getVersionValue() { - if (Double.isNaN(versionValue)) { - String versionString = getVersion(); - Matcher matcher = VERSION_PATTERN.matcher(versionString); - if (matcher.matches()) { - String str = matcher.group(1); - versionValue = Double.parseDouble(str); - } else { - log(Level.SEVERE, "Failed to parse OpenCL version: '" + versionString + "'"); - } - } - return versionValue; - } - void requireMinVersionValue(String feature, double minValue) { - requireMinVersionValue(feature, minValue, Double.NaN); - } - private Set featuresCheckedForVersion = Collections.newSetFromMap(new ConcurrentHashMap()); - void requireMinVersionValue(String feature, double minValue, double deprecationValue) { - double value = getVersionValue(); - if (value < minValue) { - throw new CLVersionException(feature + " requires OpenCL version " + minValue + - " (detected version is " + value + ")"); - } else if (!Double.isNaN(deprecationValue) && featuresCheckedForVersion.add(feature)) { - Level level = null; - if (value < deprecationValue && JavaCL.verbose) - level = Level.INFO; - else if (value >= deprecationValue) - level = Level.WARNING; - if (level != null && shouldLog(level)) - log(level, feature + " is deprecated from OpenCL version " + deprecationValue + - " (detected version is " + value + ")"); - } - } - /** * Platform name string. */ @@ -461,15 +480,21 @@ public String getVendor() { @InfoName("CL_PLATFORM_EXTENSIONS") public String[] getExtensions() { if (extensions == null) { - extensions = new LinkedHashSet(Arrays.asList(infos.getString(getEntity(), CL_PLATFORM_EXTENSIONS).split("\\s+"))); + extensions = infos.getString(getEntity(), CL_PLATFORM_EXTENSIONS).split("\\s+"); } - return extensions.toArray(new String[extensions.size()]); + return extensions; } - private Set extensions; - public boolean hasExtension(String name) { - getExtensions(); - return extensions.contains(name.trim()); + private String[] extensions; + + boolean hasExtension(String name) { + name = name.trim(); + for (String x : getExtensions()) { + if (name.equals(x.trim())) { + return true; + } + } + return false; } @InfoName("cl_nv_device_attribute_query") @@ -492,17 +517,4 @@ public boolean isGLSharingSupported() { return hasExtension("cl_khr_gl_sharing") || hasExtension("cl_APPLE_gl_sharing"); } - /** - * Allows the implementation to release the resources allocated by the OpenCL compiler for this platform. - */ - public void unloadPlatformCompiler() { - if (getVersionValue() < 1.2) { - requireMinVersionValue("clUnloadCompiler", 1.1, 1.2); - error(CL.clUnloadCompiler()); - } else { - requireMinVersionValue("clUnloadPlatformCompiler", 1.2); - error(CL.clUnloadPlatformCompiler(getEntity())); - } - } - } diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLProgram.java b/Core/src/main/java/com/nativelibs4java/opencl/CLProgram.java similarity index 61% rename from Core/src/main/velocity/com/nativelibs4java/opencl/CLProgram.java rename to Core/src/main/java/com/nativelibs4java/opencl/CLProgram.java index f55e592b..da694227 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLProgram.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLProgram.java @@ -1,20 +1,48 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; -import java.util.Iterator; -import java.util.Arrays; -import com.nativelibs4java.util.Pair; +import com.ochafik.util.listenable.Pair; import static com.nativelibs4java.opencl.CLException.error; import static com.nativelibs4java.opencl.CLException.errorString; import static com.nativelibs4java.opencl.CLException.failedForLackOfMemory; import static com.nativelibs4java.opencl.JavaCL.CL; import static com.nativelibs4java.opencl.JavaCL.log; import java.util.logging.Level; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_PROGRAM_BINARIES; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_PROGRAM_BINARY_SIZES; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_PROGRAM_BUILD_LOG; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_PROGRAM_SOURCE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_SUCCESS; -import static org.bridj.util.DefaultParameterizedType.paramType; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_PROGRAM_BINARIES; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_PROGRAM_BINARY_SIZES; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_PROGRAM_BUILD_LOG; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_PROGRAM_SOURCE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_SUCCESS; +import static com.nativelibs4java.util.JNAUtils.readNSArray; +import static com.nativelibs4java.util.JNAUtils.toNS; import java.io.IOException; import java.io.File; import java.io.FileInputStream; @@ -28,18 +56,26 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.Set; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Arrays; import java.util.Map; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_device_id; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_kernel; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_program; -import com.nativelibs4java.util.IOUtils; -import com.ochafik.util.string.StringUtils; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_kernel; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_program; +import com.nativelibs4java.util.NIOUtils; +import com.ochafik.io.IOUtils; +import com.ochafik.io.ReadText; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.ochafik.util.string.RegexUtils; +import com.sun.jna.Memory; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; @@ -51,7 +87,6 @@ import java.net.URL; import java.util.Collection; import java.util.regex.Pattern; -import java.util.regex.Matcher; import java.util.zip.CRC32; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -59,9 +94,6 @@ import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPInputStream; -import org.bridj.*; -import static org.bridj.Pointer.*; - /** * OpenCL program.
    * An OpenCL program consists of a set of kernels that are identified as functions declared with the __kernel qualifier in the program source. OpenCL programs may also contain auxiliary functions and constant data that can be used by __kernel functions. The program executable can be generated online or offline by the OpenCL compiler for the appropriate target device(s).
    @@ -77,73 +109,69 @@ * * A program can be compiled on the fly (costly) but its binaries can be stored and * loaded back in subsequent executions to avoid recompilation.
    - * By default, program binaries are automatically cached on stable platforms (which currently exclude ATI Stream), - * but the caching can be forced on/off with * see {@link CLContext#setCacheBinaries(boolean) }.
    - * To create a program from sources, please use see {@link CLContext#createProgram(java.lang.String[]) } + * By default, program binaries are automatically cached on stable platforms (which currently exclude ATI Stream), but the caching can be forced on/off with * {@link CLContext#setCached(boolean) }.
    + * To create a program from sources, please use {@link CLContext#createProgram(java.lang.String[]) } * @author Olivier Chafik */ -public class CLProgram extends CLAbstractEntity { +public class CLProgram extends CLAbstractEntity { protected final CLContext context; - protected boolean loadedFromBinary; - #declareInfosGetter("infos", "CL.clGetProgramInfo") + private static CLInfoGetter infos = new CLInfoGetter() { + @Override + protected int getInfo(cl_program entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetProgramInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; CLDevice[] devices; CLProgram(CLContext context, CLDevice... devices) { - super(0, true); + super(null, true); this.context = context; this.devices = devices == null || devices.length == 0 ? context.getDevices() : devices; } - CLProgram(CLContext context, Map binaries, String source) { - super(0, true); - this.context = context; - this.source = source; + CLProgram(CLContext context, Map binaries, String source) { + super(null, true); + this.context = context; + this.source = source; - setBinaries(binaries); - } - - protected void setBinaries(Map binaries) { + setBinaries(binaries); + } + protected void setBinaries(Map binaries) { if (this.devices == null) { - this.devices = new CLDevice[binaries.size()]; - int iDevice = 0; - for (CLDevice device : binaries.keySet()) - this.devices[iDevice++] = device; + this.devices = new CLDevice[binaries.size()]; + int iDevice = 0; + for (CLDevice device : binaries.keySet()) + this.devices[iDevice++] = device; } int nDevices = this.devices.length; - if (binaries.size() != nDevices) - throw new IllegalArgumentException("Not enough binaries in provided map : expected " + nDevices + " (devices = " + Arrays.asList(devices) + "), got " + binaries.size() + " (" + binaries.keySet() + ")"); - - #declareReusablePtrsAndPErr() - Pointer lengths = ptrs.sizeT3_1.allocatedSizeTs(nDevices); - Pointer deviceIds = ptrs.sizeT3_2.allocatedSizeTs(nDevices); - Pointer binariesArray = ptrs.sizeT3_3.allocatedSizeTs(nDevices); - Pointer[] binariesMems = new Pointer[nDevices]; - - int iDevice = 0; - for (CLDevice device : devices) { + NativeSize[] lengths = new NativeSize[nDevices]; + cl_device_id[] deviceIds = new cl_device_id[nDevices]; + Memory binariesArray = new Memory(Pointer.SIZE * nDevices); + Memory[] binariesMems = new Memory[nDevices]; + + for (int iDevice = 0; iDevice < nDevices; iDevice++) + { + CLDevice device = devices[iDevice]; byte[] binary = binaries.get(device); - if (binary == null) - throw new IllegalArgumentException("No binary for device " + device + " in provided binaries"); - - binariesArray.setPointerAtIndex(iDevice, binariesMems[iDevice] = pointerToBytes(binary)); - lengths.setSizeTAtIndex(iDevice, binary.length); - deviceIds.setSizeTAtIndex(iDevice, device.getEntity()); - - iDevice++; + + Memory binaryMem = binariesMems[iDevice] = new Memory(binary.length); + binaryMem.write(0, binary, 0, binary.length); + binariesArray.setPointer(iDevice * Pointer.SIZE, binaryMem); + + lengths[iDevice] = toNS(binary.length); + deviceIds[iDevice] = device.getEntity(); } - nDevices = iDevice; - if (nDevices == 0) - return; - + PointerByReference binariesPtr = new PointerByReference(); + binariesPtr.setPointer(binariesArray); + + IntBuffer errBuff = NIOUtils.directInts(1, ByteOrder.nativeOrder()); int previousAttempts = 0; - Pointer statuses = ptrs.int3_1.allocatedInts(nDevices); - do { - setEntity(CL.clCreateProgramWithBinary(context.getEntity(), nDevices, getPeer(deviceIds), getPeer(lengths), getPeer(binariesArray), getPeer(statuses), getPeer(pErr))); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); - if (getEntity() != 0) - loadedFromBinary = true; - } + IntBuffer statuses = NIOUtils.directInts(nDevices, ByteOrder.nativeOrder()); + do { + entity = CL.clCreateProgramWithBinary(context.getEntity(), nDevices, deviceIds, lengths, binariesPtr, statuses, errBuff); + } while (failedForLackOfMemory(errBuff.get(0), previousAttempts++)); + } /** * Write the compiled binaries of this program (for all devices it was compiled for), so that it can be restored later using {@link CLContext#loadProgram(java.io.InputStream) } @@ -187,10 +215,12 @@ public static void writeBinaries(Map binaries, String source, } public static Pair, String> readBinaries(List allowedDevices, String expectedContentSignatureString, InputStream in) throws IOException { Map ret = new HashMap(); - Map> allowedDevicesBySignature = CLDevice.getDevicesBySignature(allowedDevices); + Map> devicesBySignature = CLDevice.getDevicesBySignature(allowedDevices); ZipInputStream zin = new ZipInputStream(new GZIPInputStream(new BufferedInputStream(in))); ZipEntry ze; + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + String source = null; boolean first = true; @@ -203,26 +233,25 @@ public static Pair, String> readBinaries(List al throw new IOException("Expected signature to be the first zip entry, got '" + signature + "' instead !"); first = false; + bout.reset(); int len; - ByteArrayOutputStream bout = new ByteArrayOutputStream(); while ((len = zin.read(b)) > 0) bout.write(b, 0, len); byte[] data = bout.toByteArray(); if (isSignature) { if (expectedContentSignatureString != null) { - String contentSignatureString = new String(data, textEncoding); - if (!expectedContentSignatureString.equals(contentSignatureString)) - throw new IOException("Content signature does not match expected one :\nExpected '" + expectedContentSignatureString + "',\nGot '" + contentSignatureString + "'"); - } - } else if (signature.equals(SourceZipEntryName)) { - source = new String(data, textEncoding); - } else { - List devices = allowedDevicesBySignature.get(signature); - if (devices != null) - for (CLDevice device : devices) - ret.put(device, data); - } + String contentSignatureString = new String(data, textEncoding); + if (!expectedContentSignatureString.equals(contentSignatureString)) + throw new IOException("Content signature does not match expected one :\nExpected '" + expectedContentSignatureString + "',\nGot '" + contentSignatureString + "'"); + } + } else if (signature.equals(SourceZipEntryName)) { + source = new String(data, textEncoding); + } else { + List devices = devicesBySignature.get(signature); + for (CLDevice device : devices) + ret.put(device, data); + } } zin.close(); return new Pair, String>(ret, source); @@ -239,14 +268,14 @@ public CLDevice[] getDevices() { public static boolean passMacrosAsSources = true; public synchronized void allocate() { - if (isAllocated()) + if (entity != null) throw new IllegalThreadStateException("Program was already allocated !"); if (passMacrosAsSources) { if (macros != null && !macros.isEmpty()) { StringBuilder b = new StringBuilder(); for (Map.Entry m : macros.entrySet()) - b.append("#" + "define " + m.getKey() + " " + m.getValue() + "\n"); + b.append("#define " + m.getKey() + " " + m.getValue() + "\n"); this.sources.add(0, b.toString()); } } @@ -262,48 +291,25 @@ public synchronized void allocate() { } String[] sources = this.sources.toArray(new String[this.sources.size()]); - #declareReusablePtrsAndPErr() - - Pointer pLengths = ptrs.sizeT3_1.allocatedSizeTs(sources.length); - long[] lengths = new long[sources.length]; + NativeSize[] lengths = new NativeSize[sources.length]; for (int i = 0; i < sources.length; i++) { - pLengths.setSizeTAtIndex(i, sources[i].length()); + lengths[i] = toNS(sources[i].length()); } - - long program; - int previousAttempts = 0; - Pointer> pSources = pointerToCStrings(sources); - do { - program = CL.clCreateProgramWithSource( - context.getEntity(), - sources.length, - getPeer(pSources), - getPeer(pLengths), - getPeer(pErr) - ); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); - Pointer.release(pSources); - setEntity(program); + IntBuffer errBuff = NIOUtils.directInts(1, ByteOrder.nativeOrder()); + cl_program program; + int previousAttempts = 0; + do { + program = CL.clCreateProgramWithSource(context.getEntity(), sources.length, sources, lengths, errBuff); + } while (failedForLackOfMemory(errBuff.get(0), previousAttempts++)); + entity = program; } - private boolean isAllocated() { - return super.getEntity() != 0; - } - /* @Override protected synchronized cl_program getEntity() { - if (!isAllocated()) + if (entity == null) allocate(); - return super.getEntity(); - }*/ - - @Override - protected synchronized long getEntity() { - if (!isAllocated()) - allocate(); - - return super.getEntity(); + return entity; } List includes; @@ -322,7 +328,7 @@ public synchronized void addInclude(String path) { resolvedInclusions = null; } public synchronized void addSource(String src) { - if (isAllocated()) + if (entity != null) throw new IllegalThreadStateException("Program was already allocated : cannot add sources anymore."); sources.add(src); resolvedInclusions = null; @@ -368,11 +374,8 @@ public Map resolveInclusions() throws IOException { static Pattern includePattern = Pattern.compile("#\\s*include\\s*\"([^\"]+)\""); private void resolveInclusions(String source, Map ret) throws IOException { - List includedPaths = new ArrayList(); - Matcher m = includePattern.matcher(source); - while (m.find()) { - includedPaths.add(m.group(1)); - } + Collection includedPaths = RegexUtils.find(source, includePattern, 1); + //System.out.println("Included paths = " + includedPaths); for (String includedPath : includedPaths) { if (ret.containsKey(includedPath)) continue; @@ -380,7 +383,7 @@ private void resolveInclusions(String source, Map ret) throws IOExc if (url == null) { assert log(Level.SEVERE, "Failed to resolve include '" + includedPath + "'"); } else { - String s = IOUtils.readText(url); + String s = ReadText.readText(url); ret.put(includedPath, url); resolveInclusions(s, ret); } @@ -392,7 +395,7 @@ public String getIncludedSourceContent(String path) throws IOException { if (url == null) return null; - String src = IOUtils.readText(url); + String src = ReadText.readText(url); return src; } @@ -400,7 +403,7 @@ public URL getIncludedSourceURL(String path) throws MalformedURLException { File f = new File(path); if (f.exists()) return f.toURI().toURL(); - URL url = Platform.getClassLoader(getClass()).getResource(path); + URL url = getClass().getClassLoader().getResource(path); if (url != null) return url; @@ -410,7 +413,7 @@ public URL getIncludedSourceURL(String path) throws MalformedURLException { if (f.exists()) return f.toURI().toURL(); - url = Platform.getClassLoader(getClass()).getResource(f.toString()); + url = getClass().getClassLoader().getResource(f.toString()); if (url != null) return url; @@ -432,7 +435,7 @@ public URL getIncludedSourceURL(String path) throws MalformedURLException { * Get the source code of this program */ public synchronized String getSource() { - if (source == null && !loadedFromBinary) + if (source == null) source = infos.getString(getEntity(), CL_PROGRAM_SOURCE); return source; @@ -448,34 +451,31 @@ public Map getBinaries() throws CLBuildException { build(); } - Pointer s = infos.getMemory(getEntity(), CL_PROGRAM_BINARY_SIZES); - int n = (int)s.getValidBytes() / Platform.SIZE_T_SIZE; - long[] sizes = s.getSizeTs(n); - //int[] sizes = new int[n]; - //for (int i = 0; i < n; i++) { - // sizes[i] = s.getNativeLong(i * Native.LONG_SIZE).intValue(); - //} - - Pointer[] binMems = (Pointer[])new Pointer[n]; - #declareReusablePtrs() - Pointer binPtrs = ptrs.sizeT3_1.allocatedSizeTs(n);//allocatePointers(n); - for (int i = 0; i < n; i++) { - binPtrs.setPointerAtIndex(i, binMems[i] = allocateBytes(sizes[i])); - } - error(infos.getInfo(getEntity(), CL_PROGRAM_BINARIES, n * Pointer.SIZE, binPtrs, null)); + Memory s = infos.getMemory(getEntity(), CL_PROGRAM_BINARY_SIZES); + int n = (int)s.getSize() / Native.SIZE_T_SIZE; + NativeSize[] sizes = readNSArray(s, n); + //int[] sizes = new int[n]; + //for (int i = 0; i < n; i++) { + // sizes[i] = s.getNativeLong(i * Native.LONG_SIZE).intValue(); + //} + + Memory[] binMems = new Memory[n]; + Memory ptrs = new Memory(n * Native.POINTER_SIZE); + for (int i = 0; i < n; i++) { + ptrs.setPointer(i * Native.POINTER_SIZE, binMems[i] = new Memory(sizes[i].intValue())); + } + error(infos.getInfo(getEntity(), CL_PROGRAM_BINARIES, toNS(ptrs.getSize() * Native.POINTER_SIZE), ptrs, null)); - Map ret = new HashMap(devices.length); + Map ret = new HashMap(devices.length); int iBin = n == devices.length + 1 ? 1 : 0; - for (int i = 0; i < devices.length; i++) { + for (int i = 0; i < n; i++) { CLDevice device = devices[i]; - Pointer bytes = binMems[iBin + i]; - if (bytes != null) { - ret.put(device, bytes.getBytes((int)sizes[iBin + i])); - Pointer.release(bytes); - } - } - return ret; - } + Memory bytes = binMems[iBin + i]; + if (bytes != null) + ret.put(device, bytes.getByteArray(0, sizes[iBin + i].intValue())); + } + return ret; + } /** * Returns the context of this program @@ -551,39 +551,6 @@ public void setFiniteMathOnly() { public void setUnsafeMathOptimizations() { addBuildOption("-cl-unsafe-math-optimizations"); } - /** - * Add the -cl-nv-verbose compilation option (NVIDIA GPUs only)
    - * Enable verbose mode. Output will be reported in JavaCL's log at the INFO level - */ - public void setNVVerbose() { - addBuildOption("-cl-nv-verbose"); - } - /** - * Add the -cl-nv-maxrregcount=N compilation option (NVIDIA GPUs only)
    - * Specify the maximum number of registers that GPU functions can use. - * Until a function-specific limit, a higher value will generally increase - * the performance of individual GPU threads that execute this function. - * However, because thread registers are allocated from a global register - * pool on each GPU, a higher value of this option will also reduce the - * maximum thread block size, thereby reducing the amount of thread - * parallelism. Hence, a good maxrregcount value is the result of a - * trade-off. - * If this option is not specified, then no maximum is assumed. Otherwise - * the specified value will be rounded to the next multiple of 4 registers - * until the GPU specific maximum of 128 registers. - * @param N positive integer - */ - public void setNVMaximumRegistryCount(int N) { - addBuildOption("-cl-nv-maxrregcount=" + N); - } - /** - * Add the -cl-nv-opt-level compilation option (NVIDIA GPUs only)
    - * Specify optimization level (default value: 3) - * @param N positive integer, or 0 (no optimization). - */ - public void setNVOptimizationLevel(int N) { - addBuildOption("-cl-nv-opt-level=" + N); - } /** * Please see OpenCL's clBuildProgram documentation for details on supported build options. @@ -598,37 +565,13 @@ public synchronized void addBuildOption(String option) { extraBuildOptions.add(option); } - + protected String getOptionsString() { StringBuilder b = new StringBuilder("-DJAVACL=1 "); - if (extraBuildOptions != null) { - if (JavaCL.debug) { - boolean isCPUOnly = true; - for (CLDevice device : getDevices()) { - if (!device.getType().contains(CLDevice.Type.CPU)) { - isCPUOnly = false; - break; - } - } - if (!isCPUOnly) - log(Level.WARNING, "Debug mode : cannot only compile with debug flags on a CPU-only context"); - else { - for (Iterator it = extraBuildOptions.iterator(); it.hasNext();) { - String opt = it.next(); - if ((opt.startsWith("-O") || opt.startsWith("-g:")) && !JavaCL.DEBUG_COMPILER_FLAGS.contains(opt)) { - log(Level.WARNING, "Debug mode : removed argument \"" + opt + "\" from OpenCL compiler command-line arguments"); - it.remove(); - } - } - extraBuildOptions.addAll(JavaCL.DEBUG_COMPILER_FLAGS); - log(Level.ALL, "Debug mode : added OpenCL compiler command-line arguments \"" + StringUtils.implode(JavaCL.DEBUG_COMPILER_FLAGS, " ") + "\""); - } - } - for (String option : extraBuildOptions) - b.append(option.contains(" ") || option.contains("\"") ? "\"" + option.replaceAll("\"", "\\\"") + "\"" : option).append(' '); - - } + if (extraBuildOptions != null) + for (String option : extraBuildOptions) + b.append(option).append(' '); // http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clBuildProgram.html //b.append("-O2 -cl-no-signed-zeros -cl-unsafe-math-optimizations -cl-finite-math-only -cl-fast-relaxed-math -cl-strict-aliasing "); @@ -694,36 +637,7 @@ protected String computeCacheSignature() throws IOException { "os.version", "os.name" }; - - private String getProgramBuildInfo(long pgm, long deviceId) { - Pointer pLen = allocateSizeT(); - error(CL.clGetProgramBuildInfo(pgm, deviceId, CL_PROGRAM_BUILD_LOG, 0, 0, getPeer(pLen))); - long len = pLen.getSizeT(); - if (len == 0) { - return null; - } - Pointer buffer = allocateBytes(len); - error(CL.clGetProgramBuildInfo(pgm, deviceId, CL_PROGRAM_BUILD_LOG, len, getPeer(buffer), 0)); - String s = buffer.getCString(); - Pointer.release(pLen); - Pointer.release(buffer); - return s; - } - private Set getProgramBuildInfo(long pgm, Pointer deviceIds) { - Set errs = new HashSet(); - if (deviceIds == null) { - String s = getProgramBuildInfo(pgm, 0); - if (s != null && s.length() > 0) - errs.add(s); - } else { - for (SizeT device : deviceIds) { - String s = getProgramBuildInfo(pgm, device.longValue()); - if (s != null && s.length() > 0) - errs.add(s); - } - } - return errs; - } + boolean built; /** * Returns the context of this program @@ -735,7 +649,7 @@ public synchronized CLProgram build() throws CLBuildException { String contentSignature = null; File cacheFile = null; boolean readBinaries = false; - if (!loadedFromBinary && isCached()) { + if (isCached()) { try { contentSignature = computeCacheSignature(); byte[] sha = java.security.MessageDigest.getInstance("MD5").digest(contentSignature.getBytes(textEncoding)); @@ -751,60 +665,63 @@ public synchronized CLProgram build() throws CLBuildException { assert log(Level.INFO, "Read binaries cache from '" + cacheFile + "'"); readBinaries = true; } - } catch (Throwable ex) { - assert log(Level.WARNING, "Failed to load cached program : " + ex.getMessage()); - setEntity(0); + } catch (Exception ex) { + assert log(Level.WARNING, "Failed to load cached program", ex); + entity = null; } } - if (!isAllocated()) + if (entity == null) allocate(); Runnable deleteTempFiles = null; if (!readBinaries) try { - deleteTempFiles = copyIncludesToTemporaryDirectory(); + deleteTempFiles = copyIncludesToTemporaryDirectory(); } catch (IOException ex) { - throw new CLBuildException(this, ex.toString(), Collections.EMPTY_LIST); + throw new CLBuildException(this, ex.toString(), Collections.EMPTY_LIST); } int nDevices = devices.length; - Pointer deviceIds = null; + cl_device_id[] deviceIds = null; if (nDevices != 0) { - deviceIds = allocateSizeTs(nDevices); + deviceIds = new cl_device_id[nDevices]; for (int i = 0; i < nDevices; i++) - deviceIds.setSizeTAtIndex(i, devices[i].getEntity()); + deviceIds[i] = devices[i].getEntity(); } - Pointer pOptions = pointerToCString(getOptionsString()); - int err = CL.clBuildProgram( - getEntity(), - nDevices, - getPeer(deviceIds), - getPeer(pOptions), - 0, - 0 - ); - Pointer.release(pOptions); - Set errors = getProgramBuildInfo(getEntity(), deviceIds); - - if (err != CL_SUCCESS) { - throw new CLBuildException(this, "Compilation failure : " + errorString(err) + " (devices: " + Arrays.asList(getDevices()) + ")", errors); - } else { - if (!errors.isEmpty()) - JavaCL.log(Level.INFO, "Build info :\n\t" + StringUtils.implode(errors, "\n\t")); + int err = CL.clBuildProgram(getEntity(), nDevices, deviceIds, readBinaries ? null : getOptionsString(), null, null); + //int err = CL.clBuildProgram(getEntity(), 0, null, getOptionsString(), null, null); + if (err != CL_SUCCESS) {//BUILD_PROGRAM_FAILURE) { + NativeSizeByReference len = new NativeSizeByReference(); + int bufLen = 2048 * 32; //TODO find proper size + Memory buffer = new Memory(bufLen); + + HashSet errs = new HashSet(); + if (deviceIds == null) { + error(CL.clGetProgramBuildInfo(getEntity(), null, CL_PROGRAM_BUILD_LOG, toNS(bufLen), buffer, len)); + String s = buffer.getString(0); + errs.add(s); + } else + for (cl_device_id device : deviceIds) { + error(CL.clGetProgramBuildInfo(getEntity(), device, CL_PROGRAM_BUILD_LOG, toNS(bufLen), buffer, len)); + String s = buffer.getString(0); + errs.add(s); + } + + throw new CLBuildException(this, "Compilation failure : " + errorString(err), errs); } built = true; if (deleteTempFiles != null) deleteTempFiles.run(); - if (isCached() && !readBinaries && !loadedFromBinary) { + if (isCached() && !readBinaries) { JavaCL.userCacheDir.mkdirs(); try { - Map binaries = getBinaries(); - if (!binaries.isEmpty()) { - writeBinaries(getBinaries(), getSource(), contentSignature, new FileOutputStream(cacheFile)); - assert log(Level.INFO, "Wrote binaries cache to '" + cacheFile + "'"); - } + Map binaries = getBinaries(); + if (!binaries.isEmpty()) { + writeBinaries(getBinaries(), getSource(), contentSignature, new FileOutputStream(cacheFile)); + assert log(Level.INFO, "Wrote binaries cache to '" + cacheFile + "'"); + } } catch (Exception ex) { new IOException("[JavaCL] Failed to cache program", ex).printStackTrace(); } @@ -818,34 +735,31 @@ protected void clear() { error(CL.clReleaseProgram(getEntity())); } - /** -#documentCallsFunction("clCreateKernelsInProgram") - * Return all the kernels found in the program. - */ - public CLKernel[] createKernels() throws CLBuildException { + /** + * Return all the kernels found in the program. + */ + public CLKernel[] createKernels() throws CLBuildException { synchronized (this) { - if (!built) - build(); + if (!built) + build(); } - #declareReusablePtrs() - Pointer pCount = ptrs.int1; - int previousAttempts = 0; - while (failedForLackOfMemory(CL.clCreateKernelsInProgram(getEntity(), 0, 0, getPeer(pCount)), previousAttempts++)) {} + IntByReference pCount = new IntByReference(); + int previousAttempts = 0; + while (failedForLackOfMemory(CL.clCreateKernelsInProgram(getEntity(), 0, (cl_kernel[])null, pCount), previousAttempts++)) {} - int count = pCount.getInt(); - Pointer kerns = ptrs.sizeT3_1.allocatedSizeTs(count); - previousAttempts = 0; - while (failedForLackOfMemory(CL.clCreateKernelsInProgram(getEntity(), count, getPeer(kerns), getPeer(pCount)), previousAttempts++)) {} + int count = pCount.getValue(); + cl_kernel[] kerns = new cl_kernel[count]; + previousAttempts = 0; + while (failedForLackOfMemory(CL.clCreateKernelsInProgram(getEntity(), count, kerns, pCount), previousAttempts++)) {} - CLKernel[] kernels = new CLKernel[count]; - for (int i = 0; i < count; i++) - kernels[i] = new CLKernel(this, null, kerns.getSizeTAtIndex(i)); + CLKernel[] kernels = new CLKernel[count]; + for (int i = 0; i < count; i++) + kernels[i] = new CLKernel(this, null, kerns[i]); - return kernels; - } + return kernels; + } /** -#documentCallsFunction("clCreateKernel") * Find a kernel by its functionName, and optionally bind some arguments to it. */ public CLKernel createKernel(String name, Object... args) throws CLBuildException { @@ -853,18 +767,17 @@ public CLKernel createKernel(String name, Object... args) throws CLBuildExceptio if (!built) build(); } - #declareReusablePtrsAndPErr() - Pointer pName = pointerToCString(name); - long kernel; + IntBuffer errBuff = NIOUtils.directInts(1, ByteOrder.nativeOrder()); + cl_kernel kernel; int previousAttempts = 0; do { - kernel = CL.clCreateKernel(getEntity(), getPeer(pName), getPeer(pErr)); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); - Pointer.release(pName); + kernel = CL.clCreateKernel(getEntity(), name, errBuff); + } while (failedForLackOfMemory(errBuff.get(0), previousAttempts++)); CLKernel kn = new CLKernel(this, name, kernel); - if (args.length != 0) - kn.setArgs(args); + kn.setArgs(args); return kn; } + + } diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLQueue.java b/Core/src/main/java/com/nativelibs4java/opencl/CLQueue.java new file mode 100644 index 00000000..7ecaf370 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLQueue.java @@ -0,0 +1,194 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.CLException.error; +import static com.nativelibs4java.opencl.JavaCL.CL; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_FALSE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_QUEUE_PROPERTIES; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_TRUE; + +import java.util.EnumSet; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.LongByReference; + +/** + * OpenCL command queue.
    + * OpenCL objects such as memory, program and kernel objects are created using a context.
    + * Operations on these objects are performed using a command-queue.
    + * The command-queue can be used to queue a set of operations (referred to as commands) in order.
    + * Having multiple command-queues allows applications to queue multiple independent commands without requiring synchronization.
    + * Note that this should work as long as these objects are not being shared.
    + * Sharing of objects across multiple command-queues will require the application to perform appropriate synchronization.
    + *
    + * A queue is bound to a single device. + * see {@link CLDevice#createQueue(com.nativelibs4java.opencl.CLContext, com.nativelibs4java.opencl.CLDevice.QueueProperties[]) } + * see {@link CLDevice#createOutOfOrderQueue(com.nativelibs4java.opencl.CLContext) } + * see {@link CLDevice#createProfilingQueue(com.nativelibs4java.opencl.CLContext) } + * see {@link CLContext#createDefaultQueue(com.nativelibs4java.opencl.CLDevice.QueueProperties[]) } + * see {@link CLContext#createDefaultOutOfOrderQueue() } + * see {@link CLContext#createDefaultProfilingQueue() } + * @author Olivier Chafik + * + */ +public class CLQueue extends CLAbstractEntity { + + private CLInfoGetter infos = new CLInfoGetter() { + @Override + protected int getInfo(cl_command_queue entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetCommandQueueInfo(getEntity(), infoTypeEnum, size, out, sizeOut); + } + }; + + final CLContext context; + final CLDevice device; + + CLQueue(CLContext context, cl_command_queue entity, CLDevice device) { + super(entity); + this.context = context; + this.device = device; + } + + public CLContext getContext() { + return context; + } + public CLDevice getDevice() { + return device; + } + + volatile Boolean outOfOrder; + public synchronized boolean isOutOfOrder() { + if (outOfOrder == null) + outOfOrder = getProperties().contains(CLDevice.QueueProperties.OutOfOrderExecModeEnable); + return outOfOrder; + } + + @InfoName("CL_QUEUE_PROPERTIES") + public EnumSet getProperties() { + return CLDevice.QueueProperties.getEnumSet(infos.getIntOrLong(getEntity(), CL_QUEUE_PROPERTIES)); + } + + @SuppressWarnings("deprecation") + public void setProperty(CLDevice.QueueProperties property, boolean enabled) { + error(CL.clSetCommandQueueProperty(getEntity(), property.value(), enabled ? CL_TRUE : CL_FALSE, (LongByReference)null)); + } + + + @Override + protected void clear() { + error(CL.clReleaseCommandQueue(getEntity())); + } + + /** + * Blocks until all previously queued OpenCL commands in this queue are issued to the associated device and have completed.
    + * finish() does not return until all queued commands in this queue have been processed and completed.
    + * finish() is also a synchronization point. + */ + public void finish() { + error(CL.clFinish(getEntity())); + } + + /** + * Issues all previously queued OpenCL commands in this queue to the device associated with this queue.
    + * flush() only guarantees that all queued commands in this queue get issued to the appropriate device.
    + * There is no guarantee that they will be complete after flush() returns. + */ + public void flush() { + error(CL.clFlush(getEntity())); + } + + /** + * Enqueues a wait for a specific event or a list of events to complete before any future commands queued in the this queue are executed. + */ + public void enqueueWaitForEvents(CLEvent... events) { + cl_event[] evts = CLEvent.to_cl_event_array(events); + error(CL.clEnqueueWaitForEvents(getEntity(), evts == null ? 0 : evts.length, evts)); + } + + /** + * Enqueue a barrier operation.
    + * The enqueueBarrier() command ensures that all queued commands in command_queue have finished execution before the next batch of commands can begin execution.
    + * enqueueBarrier() is a synchronization point. + */ + public void enqueueBarrier() { + error(CL.clEnqueueBarrier(getEntity())); + } + + /** + * Enqueue a marker command to command_queue.
    + * The marker command returns an event which can be used by to queue a wait on this marker event i.e. wait for all commands queued before the marker command to complete. + * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete. + */ + public CLEvent enqueueMarker() { + cl_event[] eventOut = new cl_event[1]; + error(CL.clEnqueueMarker(getEntity(), eventOut)); + return CLEvent.createEvent(this, eventOut); + } + + /** + * Used to acquire OpenCL memory objects that have been created from OpenGL objects.
    + * These objects need to be acquired before they can be used by any OpenCL commands queued to a command-queue.
    + * The OpenGL objects are acquired by the OpenCL context associated with this queue and can therefore be used by all command-queues associated with the OpenCL context. + * @param objects CL memory objects that correspond to GL objects. + * @param eventsToWaitFor Events that need to complete before this particular command can be executed. + * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete. + */ + public CLEvent enqueueAcquireGLObjects(CLMem[] objects, CLEvent... eventsToWaitFor) { + cl_event[] eventOut = CLEvent.new_event_out(eventsToWaitFor); + cl_mem[] mems = new cl_mem[objects.length]; + for (int i = 0; i < objects.length; i++) + mems[i] = objects[i].getEntity(); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueAcquireGLObjects(getEntity(), mems.length, mems, evts == null ? 0 : evts.length, evts, eventOut)); + return CLEvent.createEvent(this, eventOut); + } + + /** + * Used to release OpenCL memory objects that have been created from OpenGL objects.
    + * These objects need to be released before they can be used by OpenGL.
    + * The OpenGL objects are released by the OpenCL context associated with this queue. + * @param objects CL memory objects that correpond to GL objects. + * @param eventsToWaitFor Events that need to complete before this particular command can be executed. + * @return Event object that identifies this command and can be used to query or queue a wait for the command to complete. + */ + public CLEvent enqueueReleaseGLObjects(CLMem[] objects, CLEvent... eventsToWaitFor) { + cl_event[] eventOut = CLEvent.new_event_out(eventsToWaitFor); + cl_mem[] mems = getEntities(objects, new cl_mem[objects.length]); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueReleaseGLObjects(getEntity(), mems.length, mems, evts == null ? 0 : evts.length, evts, eventOut)); + return CLEvent.createEvent(this, eventOut); + } +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLSampler.java b/Core/src/main/java/com/nativelibs4java/opencl/CLSampler.java new file mode 100644 index 00000000..43f66f18 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLSampler.java @@ -0,0 +1,135 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.CLException.error; +import static com.nativelibs4java.opencl.JavaCL.CL; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_ADDRESS_CLAMP; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_ADDRESS_CLAMP_TO_EDGE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_ADDRESS_NONE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_ADDRESS_REPEAT; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_FILTER_LINEAR; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_FILTER_NEAREST; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_SAMPLER_ADDRESSING_MODE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_SAMPLER_FILTER_MODE; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.CL_SAMPLER_NORMALIZED_COORDS; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_sampler; +import com.nativelibs4java.util.EnumValue; +import com.nativelibs4java.util.EnumValues; +import com.nativelibs4java.util.ValuedEnum; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Pointer; + +/** + * OpenCL sampler object.
    + * A sampler object describes how to sample an image when the image is read in the kernel.
    + * The built-in functions to read from an image in a kernel take a sampler as an argument.
    + * The sampler arguments to the image read function can be sampler objects created using OpenCL functions and passed as argument values to the kernel or can be samplers declared inside a kernel. + *
    + * see {@link CLContext#createSampler(boolean, com.nativelibs4java.opencl.CLSampler.AddressingMode, com.nativelibs4java.opencl.CLSampler.FilterMode) } + * @author Olivier Chafik + */ +public class CLSampler extends CLAbstractEntity { + private static CLInfoGetter infos = new CLInfoGetter() { + @Override + protected int getInfo(cl_sampler entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetSamplerInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; + + CLSampler(cl_sampler entity) { + super(entity); + } + + @Override + protected void clear() { + error(CL.clReleaseSampler(getEntity())); + } + + /** + * Values for CL_SAMPLER_ADDRESSING_MODE
    + * How out-of-range image coordinates are handled when reading from an image + */ + public enum AddressingMode implements ValuedEnum { + Repeat(CL_ADDRESS_REPEAT), + ClampToEdge(CL_ADDRESS_CLAMP_TO_EDGE), + Clamp(CL_ADDRESS_CLAMP), + None(CL_ADDRESS_NONE); + + AddressingMode(long value) { this.value = value; } + long value; + @Override + public long value() { return value; } + public static AddressingMode getEnum(long v) { return EnumValues.getEnum(v, AddressingMode.class); } + } + + /** + * Return the value specified by addressing_mode argument to CLContext.createSampler. + */ + @InfoName("CL_SAMPLER_ADDRESSING_MODE") + public AddressingMode getAddressingMode() { + return AddressingMode.getEnum(infos.getInt(getEntity(), CL_SAMPLER_ADDRESSING_MODE)); + } + + /** + * Values for CL_SAMPLER_FILTER_MODE
    + * Type of filter that must be applied when reading an image + */ + public enum FilterMode implements ValuedEnum { + Nearest(CL_FILTER_NEAREST), + Linear(CL_FILTER_LINEAR); + + FilterMode(long value) { this.value = value; } + long value; + @Override + public long value() { return value; } + public static FilterMode getEnum(int v) { return EnumValues.getEnum(v, FilterMode.class); } + } + /** + * Return the value specified by filter_mode argument to CLContext.createSampler. + */ + @InfoName("CL_SAMPLER_FILTER_MODE") + public FilterMode getFilterMode() { + return FilterMode.getEnum(infos.getInt(getEntity(), CL_SAMPLER_FILTER_MODE)); + } + + /** + * Return the value specified by normalized_coords argument to CLContext.createSampler. + */ + @InfoName("CL_SAMPLER_NORMALIZED_COORDS") + public boolean getNormalizedCoords() { + return infos.getBool(getEntity(), CL_SAMPLER_NORMALIZED_COORDS); + } + + + +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLShortBuffer.java b/Core/src/main/java/com/nativelibs4java/opencl/CLShortBuffer.java new file mode 100644 index 00000000..75e6d044 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLShortBuffer.java @@ -0,0 +1,49 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; +import java.nio.*; + +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; + +/** + * OpenCL Memory Buffer Object with Short values.
    + * see {@link CLContext#createShortBuffer(com.nativelibs4java.opencl.CLMem.Usage, long) } + * see {@link CLContext#createShortBuffer(com.nativelibs4java.opencl.CLMem.Usage, java.nio.ShortBuffer, boolean) } + * @author Olivier Chafik + * @deprecated Use {@link CLBuffer}<{@link Short}> + */ +@Deprecated +public class CLShortBuffer extends CLBuffer { + CLShortBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer) { + super(context, byteCount, entity, buffer, 2, ShortBuffer.class); + } +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/CLUserEvent.java b/Core/src/main/java/com/nativelibs4java/opencl/CLUserEvent.java new file mode 100644 index 00000000..add0b8d5 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/CLUserEvent.java @@ -0,0 +1,61 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; + + +import static com.nativelibs4java.opencl.JavaCL.CL; +import static com.nativelibs4java.opencl.CLException.error; +import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event; + +public class CLUserEvent extends CLEvent { + CLUserEvent(cl_event evt) { + super(evt); + } + CLUserEvent() { + super(); + } + /** + * Sets the execution status of a this event object. + * NOTE: Enqueued commands that specify user events in the event_wait_list argument of clEnqueue*** commands must ensure that the status of these user events being waited on are set using clSetUserEventStatus before any OpenCL APIs that release OpenCL objects except for event objects are called; otherwise the behavior is undefined. More details in the OpenCL specifications at section 5.9. + * @param executionStatus specifies the new execution status to be set and can be CL_COMPLETE or a negative integer value to indicate an error. A negative integer value causes all enqueued commands that wait on this user event to be terminated. setStatus can only be called once to change the execution status of event. + */ + public void setStatus(int executionStatus) { + error(CL.clSetUserEventStatus(getEntity(), executionStatus)); + } + + /** + * Calls setStatus(CL_COMPLETE) + */ + public void setComplete() { + setStatus(CL_COMPLETE); + } +} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/ImageIOUtils.java b/Core/src/main/java/com/nativelibs4java/opencl/ImageIOUtils.java similarity index 98% rename from Core/src/main/velocity/com/nativelibs4java/opencl/ImageIOUtils.java rename to Core/src/main/java/com/nativelibs4java/opencl/ImageIOUtils.java index 097154c8..95088199 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/ImageIOUtils.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/ImageIOUtils.java @@ -1,4 +1,3 @@ -#parse("main/Header.vm") package com.nativelibs4java.opencl; import com.nativelibs4java.opencl.CLImageFormat.ChannelOrder; @@ -19,7 +18,7 @@ * TYPE_BYTE_INDEXED * TYPE_CUSTOM * TYPE_INT_ARGB_PRE (no support for pre-multiplied channels) - * TYPE_INT_BGR + * TYPE_INT_BGR * TYPE_INT_RGB (no support for UnsignedInt8 channel data type) * TYPE_USHORT_555_RGB * TYPE_USHORT_565_RGB @@ -33,7 +32,6 @@ public static class ImageInfo { public final ImageDataGetter dataGetter; public final ImageDataSetter dataSetter; public final Class bufferClass; - public final Class bufferElementsClass; public final int channelCount; public final int pixelByteSize; public ImageInfo( @@ -42,7 +40,6 @@ public ImageInfo( ImageDataGetter dataGetter, ImageDataSetter dataSetter, Class bufferClass, - Class bufferElementsClass, int channelCount, int pixelByteSize) { @@ -51,7 +48,6 @@ public ImageInfo( this.dataGetter = dataGetter; this.dataSetter = dataSetter; this.bufferClass = bufferClass; - this.bufferElementsClass = bufferElementsClass; this.channelCount = channelCount; this.pixelByteSize = pixelByteSize; } @@ -105,7 +101,6 @@ public void setData(Image image, Buffer data, boolean allowDeoptimizingDirectWri } }, IntBuffer.class, - Integer.class, 1, 4 ); @@ -196,7 +191,6 @@ public void setData(BufferedImage image, Buffer inputBuffer, boolean allowDeopti } }, ShortBuffer.class, - Short.class, 1, 2 ); @@ -261,7 +255,6 @@ public void setData(BufferedImage image, Buffer inputBuffer, boolean allowDeopti } }, ShortBuffer.class, - Short.class, 4, 4 * 2 ); @@ -322,7 +315,6 @@ public void setData(BufferedImage image, Buffer inputBuffer, boolean allowDeopti } }, ByteBuffer.class, - Byte.class, 1, 1 ); @@ -402,7 +394,6 @@ public void setData(BufferedImage image, Buffer inputBuffer, boolean allowDeopti } }, IntBuffer.class, - Integer.class, 1, 4 ); diff --git a/Core/src/main/java/com/nativelibs4java/opencl/InfoName.java b/Core/src/main/java/com/nativelibs4java/opencl/InfoName.java new file mode 100644 index 00000000..ff001a6c --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/InfoName.java @@ -0,0 +1,46 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Tagging annotation to indicate the name of an OpenCL information in the OpenCL specifications. + * @author ochafik + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface InfoName { + String value(); +} diff --git a/Core/src/main/java/com/nativelibs4java/opencl/JavaCL.java b/Core/src/main/java/com/nativelibs4java/opencl/JavaCL.java new file mode 100644 index 00000000..656b87a3 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/opencl/JavaCL.java @@ -0,0 +1,244 @@ +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.nativelibs4java.opencl; + +import static com.nativelibs4java.opencl.CLException.error; +import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; + +import java.io.File; +import java.io.IOException; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.logging.*; + +import com.nativelibs4java.opencl.library.OpenCLLibrary; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_platform_id; +import com.sun.jna.Platform; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.PointerByReference; +import com.sun.jna.Native; + +/** + * Entry point class for the OpenCL4Java Object-oriented wrappers around the OpenCL API.
    + * @author Olivier Chafik + */ +public class JavaCL { + + static final boolean verbose = "true".equals(System.getProperty("javacl.verbose")) || "1".equals(System.getenv("JAVACL_VERBOSE")); + static final int minLogLevel = Level.WARNING.intValue(); + static boolean shouldLog(Level level) { + return verbose || level.intValue() >= minLogLevel; + } + static boolean log(Level level, String message, Throwable ex) { + if (!shouldLog(level)) + return true; + Logger.getLogger(JavaCL.class.getName()).log(level, message, ex); + return true; + } + + static boolean log(Level level, String message) { + log(level, message, null); + return true; + } + + private static int getPlatformIDs(OpenCLLibrary lib, int count, cl_platform_id[] out, IntByReference pCount) { + try { + return lib.clIcdGetPlatformIDsKHR(count, out, pCount); + } catch (Throwable th) { + return lib.clGetPlatformIDs(count, out, pCount); + } + } + public interface OpenCLStdCallLibrary extends com.nativelibs4java.opencl.library.OpenCLLibrary, com.sun.jna.win32.StdCallLibrary { + + } + + static final OpenCLLibrary CL; + static { + Class libClass = Platform.isWindows() && !Platform.is64Bit() ? OpenCLStdCallLibrary.class : OpenCLLibrary.class; + OpenCLLibrary lib = (OpenCLLibrary)Native.loadLibrary("OpenCL", libClass); + //if (Platform.isWindows()) + try { + IntByReference pCount = new IntByReference(); + boolean success = false; + try { + success = getPlatformIDs(lib, 0, null, pCount) == OpenCLLibrary.CL_SUCCESS; + } catch (Throwable th) {} + if (!success) { + OpenCLLibrary atiLib = null; + if (Platform.is64Bit()) + atiLib = (OpenCLLibrary)Native.loadLibrary("atiocl64", libClass); + if (atiLib == null) + atiLib = (OpenCLLibrary)Native.loadLibrary("atiocl32", libClass); + if (atiLib == null) + atiLib = (OpenCLLibrary)Native.loadLibrary("atiocl", libClass); + if (atiLib != null) { + int err = getPlatformIDs(atiLib, 0, null, pCount); + if (err == OpenCLLibrary.CL_SUCCESS) { + System.out.println("[JavaCL] Hacking around ATI's weird driver bugs (using atiocl library instead of OpenCL)"); + lib = atiLib; + } + } + } + } catch (Throwable th) {} + + CL = (OpenCLLibrary)Native.synchronizedLibrary(lib); + } + + /** + * List the OpenCL implementations that contain at least one GPU device. + */ + public static CLPlatform[] listGPUPoweredPlatforms() { + CLPlatform[] platforms = listPlatforms(); + List out = new ArrayList(platforms.length); + for (CLPlatform platform : platforms) { + if (platform.listGPUDevices(true).length > 0) + out.add(platform); + } + return out.toArray(new CLPlatform[out.size()]); + } + /** + * Lists all available OpenCL implementations. + */ + public static CLPlatform[] listPlatforms() { + IntByReference pCount = new IntByReference(); + error(getPlatformIDs(CL, 0, null, pCount)); + + int nPlats = pCount.getValue(); + if (nPlats == 0) + return new CLPlatform[0]; + + cl_platform_id[] ids = new cl_platform_id[nPlats]; + + error(getPlatformIDs(CL, nPlats, ids, null)); + CLPlatform[] platforms = new CLPlatform[nPlats]; + + for (int i = 0; i < nPlats; i++) { + platforms[i] = new CLPlatform(ids[i]); + } + return platforms; + } + + /** + * Creates an OpenCL context formed of the provided devices.
    + * It is generally not a good idea to create a context with more than one device, + * because much data is shared between all the devices in the same context. + * @param devices devices that are to form the new context + * @return new OpenCL context + */ + public static CLContext createContext(Map contextProperties, CLDevice... devices) { + return devices[0].getPlatform().createContext(contextProperties, devices); + } + + /** + * Allows the implementation to release the resources allocated by the OpenCL compiler.
    + * This is a hint from the application and does not guarantee that the compiler will not be used in the future or that the compiler will actually be unloaded by the implementation.
    + * Calls to Program.build() after unloadCompiler() will reload the compiler, if necessary, to build the appropriate program executable. + */ + public static void unloadCompiler() { + error(CL.clUnloadCompiler()); + } + + /** + * Returns the "best" OpenCL device (currently, the one that has the largest amount of compute units).
    + * For more control on what is to be considered a better device, please use the {@link JavaCL#getBestDevice(CLPlatform.DeviceFeature[]) } variant.
    + * This is currently equivalent to getBestDevice(MaxComputeUnits) + */ + public static CLDevice getBestDevice() { + return getBestDevice(CLPlatform.DeviceFeature.MaxComputeUnits); + } + /** + * Returns the "best" OpenCL device based on the comparison of the provided prioritized device feature.
    + * The returned device does not necessarily exhibit the features listed in preferredFeatures, but it has the best ordered composition of them.
    + * For instance on a system with a GPU and a CPU device, JavaCL.getBestDevice(CPU, MaxComputeUnits) will return the CPU device, but on another system with two GPUs and no CPU device it will return the GPU that has the most compute units. + */ + public static CLDevice getBestDevice(CLPlatform.DeviceFeature... preferredFeatures) { + List devices = new ArrayList(); + for (CLPlatform platform : listPlatforms()) + devices.addAll(Arrays.asList(platform.listAllDevices(true))); + return CLPlatform.getBestDevice(Arrays.asList(preferredFeatures), devices); + } + /** + * Creates an OpenCL context with the "best" device (see {@link JavaCL#getBestDevice() }) + */ + public static CLContext createBestContext() { + return createBestContext(DeviceFeature.MaxComputeUnits); + } + + /** + * Creates an OpenCL context with the "best" device based on the comparison of the provided prioritized device feature (see {@link JavaCL#getBestDevice(CLPlatform.DeviceFeature) }) + */ + public static CLContext createBestContext(CLPlatform.DeviceFeature... preferredFeatures) { + CLDevice device = getBestDevice(preferredFeatures); + return device.getPlatform().createContext(null, device); + } + + /** + * Creates an OpenCL context able to share entities with the current OpenGL context. + * @throws RuntimeException if JavaCL is unable to create an OpenGL-shared OpenCL context. + */ + public static CLContext createContextFromCurrentGL() { + RuntimeException first = null; + for (CLPlatform platform : listPlatforms()) { + try { + CLContext ctx = platform.createContextFromCurrentGL(); + if (ctx != null) + return ctx; + } catch (RuntimeException ex) { + if (first == null) + first = ex; + + } + } + throw new RuntimeException("Failed to create an OpenCL context based on the current OpenGL context", first); + } + + static File userJavaCLDir = new File(new File(System.getProperty("user.home")), ".javacl"); + static File userCacheDir = new File(userJavaCLDir, "cache"); + + static synchronized File createTempFile(String prefix, String suffix, String category) { + File dir = new File(userJavaCLDir, category); + dir.mkdirs(); + try { + return File.createTempFile(prefix, suffix, dir); + } catch (IOException ex) { + throw new RuntimeException("Failed to create a temporary directory for category '" + category + "' in " + userJavaCLDir + ": " + ex.getMessage(), ex); + } + } + static synchronized File createTempDirectory(String prefix, String suffix, String category) { + File file = createTempFile(prefix, suffix, category); + file.delete(); + file.mkdir(); + return file; + } +} diff --git a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/package-info.java b/Core/src/main/java/com/nativelibs4java/opencl/package-info.java similarity index 76% rename from Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/package-info.java rename to Core/src/main/java/com/nativelibs4java/opencl/package-info.java index 33bcda92..887220cc 100644 --- a/Blas/src/main/java/com/nativelibs4java/opencl/blas/ujmp/package-info.java +++ b/Core/src/main/java/com/nativelibs4java/opencl/package-info.java @@ -29,11 +29,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** - * OpenCL UJMP float/double dense matrix implementations with many asynchronous accelerated operations (multiplication, transpose, piece-wise unary or binary operations...).
    - * To install these implementations, please use the following calls : - *
    {@code
    - * MatrixMapper.getInstance().setDenseDoubleMatrix2DClass(CLDenseDoubleMatrix2D.class);
    - * MatrixMapper.getInstance().setDenseFloatMatrix2DClass(CLDenseFloatMatrix2D.class);
    - * }
    + * Object-oriented wrappers around the OpenCL API, with methods that help creating and managing OpenCL applications.
    + * Also see the low-level bindings : {@link com.nativelibs4java.opencl.library.OpenCL4Java} */ -package com.nativelibs4java.opencl.blas.ujmp; +package com.nativelibs4java.opencl; diff --git a/Core/src/main/java/com/nativelibs4java/util/JNAUtils.java b/Core/src/main/java/com/nativelibs4java/util/JNAUtils.java new file mode 100644 index 00000000..6e230836 --- /dev/null +++ b/Core/src/main/java/com/nativelibs4java/util/JNAUtils.java @@ -0,0 +1,121 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.nativelibs4java.util; + +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.*; +import com.sun.jna.ptr.*; + +/** + * JNA-related util methods + * @author ochafik + */ +public class JNAUtils { + + /** + * Casts an IntByReference to a NativeLongByReference + */ + public static NativeSizeByReference castToNS(IntByReference local) { + NativeSizeByReference nl = new NativeSizeByReference(); + nl.setPointer(local.getPointer()); + return nl; + } + + /** + * Casts a LongByReference to a NativeSizeByReference + */ + public static NativeSizeByReference castToNS(LongByReference local) { + NativeSizeByReference nl = new NativeSizeByReference(); + nl.setPointer(local.getPointer()); + return nl; + } + + public static NativeSize readNS(Pointer p, long offset) { + if (NativeSize.SIZE == 4) + return new NativeSize(p.getInt(offset)); + else if (NativeSize.SIZE == 8) + return new NativeSize(p.getLong(offset)); + else + throw new RuntimeException("sizeof(size_t) must be either 4 or 8"); + } + public static void writeNS(Pointer p, long offset, long value) { + if (NativeSize.SIZE == 4) + p.setInt(offset, (int)value); + else if (NativeSize.SIZE == 8) + p.setLong(offset, value); + else + throw new RuntimeException("sizeof(size_t) must be either 4 or 8"); + } + + public static NativeSize[] readNSArray(Pointer p, int n) { + NativeSize[] sizes = new NativeSize[n]; + for (int i = 0; i < n; i++) + sizes[i] = readNS(p, i * NativeSize.SIZE); + return sizes; + } + + public static void writeNSArray(Pointer p, long... values) { + if (values == null) + return; + for (int i = 0, n = values.length; i < n; i++) + writeNS(p, i * NativeSize.SIZE, values[i]); + } + + /** + * Converts int/long values array to a Memory object containing contiguous size_t values + * @see NativeSize#SIZE + */ + public static Memory toNSArray(long... values) { + if (values == null) + return null; + Memory mem = new Memory(values.length * NativeSize.SIZE); + writeNSArray(mem, values); + return mem; + } + + /** + * Return a new Size with the provided int value + */ + public static NativeSize[] toNS(int[] ints) { + if (ints == null) + return null; + int n = ints.length; + NativeSize[] nls = new NativeSize[n]; + for (int i = 0; i < n; i++) + nls[i] = toNS(ints[i]); + + return nls; + } + + /** + * Return a new NativeSize array with the provided long values + */ + public static NativeSize[] toNS(long... ints) { + if (ints == null) + return null; + int n = ints.length; + NativeSize[] nls = new NativeSize[n]; + for (int i = 0; i < n; i++) + nls[i] = toNS(ints[i]); + + return nls; + } + + /** + * Return a new NativeSize with the provided int value + */ + public static NativeSize toNS(int i) { + return new NativeSize(i); + } + + /** + * Return a new NativeSize with the provided long value + */ + public static NativeSize toNS(long i) { + return new NativeSize(i); + } +} diff --git a/Core/src/main/java/com/ochafik/util/string/StringUtils.java b/Core/src/main/java/com/ochafik/util/string/StringUtils.java deleted file mode 100644 index 9dbe70e9..00000000 --- a/Core/src/main/java/com/ochafik/util/string/StringUtils.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - Copyright (c) 2009-2011 Olivier Chafik, All Rights Reserved - - This file is part of JNAerator (http://jnaerator.googlecode.com/). - - JNAerator is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - JNAerator is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JNAerator. If not, see . -*/ -package com.ochafik.util.string; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -public class StringUtils { - public static String htmlize(String text) { - return text.startsWith("") ? - text : ""+ - text.replace("&", "&").replace("<", "<").replace(">", ">").replace("\n","
    ")+ - ""; - } - - static Pattern spacePattern; - public static List explode(String s) { - if (spacePattern == null) { - spacePattern = Pattern.compile("\\s+"); - } - return explode(s, spacePattern); - } - public static List explode(String s, String sep) { - StringTokenizer st=new StringTokenizer(s,sep); - List v = new ArrayList(); - for (;st.hasMoreTokens();) { - v.add(st.nextToken()); - } - return v; - } - -/* - public static final String implode(Object[] strings, String separator) { - return implode(Arrays.asList(strings), separator); - } -*/ - public static String implode(double[] array, String separator) { - StringBuffer out = new StringBuffer(); - boolean first = true; - for (double v : array) { - if (first) first = false; - else out.append(separator); - out.append(v); - } - return out.toString(); - } - - public static String implode(Object[] values) { - return implode(values, ", "); - } - public static String implode(Object[] values, Object separator) { - return implode(Arrays.asList(values), separator); - } - public static final String implode(Iterable elements, Object separator) { - String sepStr = separator.toString(); - StringBuilder out = new StringBuilder(); - boolean first = true; - for (Object s : elements) { - if (s == null) - continue; - - if (first) - first = false; - else - out.append(sepStr); - out.append(s); - } - return out.toString(); - } - public static final String implode(Iterable strings) { - return implode(strings, ", "); - } - /* - public static final String implode(Collection strings, String separator) { - int size = 0, n = strings.size(); - for (Object s : strings) - if (s != null) - size += s.toString().length(); - - StringBuffer out = new StringBuffer(size + separator.length() * (n == 0 ? 0 : n - 1)); - boolean first = true; - for (Object s : strings) { - if (s == null) - continue; - - if (first) first = false; - else out.append(separator); - out.append(s); - } - return out.toString(); - } - */ - public static final List explode(String string, Pattern separator) { - int lastIndex = 0, len = string.length(); - - Matcher matcher = separator.matcher(string); - List ret = new LinkedList(); - - while (matcher.find()) { - String s = string.substring(lastIndex, matcher.start()); - if (s.length() > 0) ret.add(s); - lastIndex = matcher.end(); - } - String s = string.substring(lastIndex, len); - if (s.length() > 0) ret.add(s); - - return ret; - } - - public static String replace(String pattern, String replace, String s) { - return concatWithSeparator(explode(s,pattern).toArray(new String[0]),replace); - } - public static final String concat(String[] a) { - StringBuffer b=new StringBuffer(); - for (int i=0;i127||Character.isISOControl(c)) { - b.append("\\u"); - String nb=Integer.toString((int)c,16); - int nblen=nb.length(); - switch (nblen) { - case 1: - b.append(0); - case 2: - b.append(0); - case 3: - b.append(0); - case 4: - b.append(nb); - break; - default: - throw new IllegalArgumentException("Should not happen !"); - } - } else b.append(c); - } - } - return b.toString(); - } - public static final String javaUnEscape(String s) { - char c; - int len=s.length(); - StringBuffer b=new StringBuffer(len); - for (int i=0;i strings, String separator) { - List cap = new ArrayList(strings.size()); - for (String s : strings) - cap.add(capitalize(s)); - return implode(cap, separator); - } - - public static String uncapitalize(String string) { - return string.length() == 0 ? "" : Character.toLowerCase(string.charAt(0)) + string.substring(1); - } - public static final String LINE_SEPARATOR; - static { - LINE_SEPARATOR = System.getProperty("line.separator"); - } - -} diff --git a/Core/src/main/jnlp/HardwareReport.jnlp b/Core/src/main/jnlp/HardwareReport.jnlp index 795dff74..cf7d8c23 100644 --- a/Core/src/main/jnlp/HardwareReport.jnlp +++ b/Core/src/main/jnlp/HardwareReport.jnlp @@ -1,18 +1,18 @@ - JavaCL-BridJ HardwareReport + JavaCL HardwareReport Olivier Chafik - JavaCL-BridJ HardwareReport - JavaCL-BridJ HardwareReport + JavaCL HardwareReport + JavaCL HardwareReport - + @@ -20,13 +20,8 @@ - - - - JavaCL-BridJ Interactive Image Transform Demo + JavaCL Interactive Image Transform Demo Olivier Chafik - Image Transform Kernel Editor + Demos for JavaCL-BridJ (Object-Oriented OpenCL Library for Java) + Image Transform Kernel Editor + Demos for JavaCL (Object-Oriented OpenCL Library for Java) - + @@ -19,8 +19,14 @@ - - + + + + + + + - JavaCL-BridJ + JavaCL Olivier Chafik - Object-Oriented OpenCL-BridJ Library for Java + Object-Oriented OpenCL Library for Java - + - - - + diff --git a/Core/src/main/jnlp/MandelbrotDemo.jnlp b/Core/src/main/jnlp/MandelbrotDemo.jnlp index b7f3aa96..688533bc 100644 --- a/Core/src/main/jnlp/MandelbrotDemo.jnlp +++ b/Core/src/main/jnlp/MandelbrotDemo.jnlp @@ -1,17 +1,17 @@ - JavaCL-BridJ Mandelbrot Demos + JavaCL Mandelbrot Demos Olivier Chafik (demo adapted from Bob Boothby's) - Mandelbrot Demo for JavaCL-BridJ (Object-Oriented OpenCL Library for Java) + Mandelbrot Demo for JavaCL (Object-Oriented OpenCL Library for Java) - + @@ -19,13 +19,12 @@ - - - + + + - OpenCL4Java-BridJ + OpenCL4Java Olivier Chafik - OpenCL-BridJ bindings for Java + OpenCL bindings for Java + OpenCL4Java HardwareReport - + diff --git a/Core/src/main/jnlp/ParticlesDemo.jnlp b/Core/src/main/jnlp/ParticlesDemo.jnlp index f9f4a520..6a228a6a 100644 --- a/Core/src/main/jnlp/ParticlesDemo.jnlp +++ b/Core/src/main/jnlp/ParticlesDemo.jnlp @@ -1,10 +1,10 @@ - JavaCL-BridJ Particles Demos + JavaCL Particles Demos Olivier Chafik Demos for JavaCL (Object-Oriented OpenCL Library for Java) @@ -19,9 +19,14 @@ - - - + + + + + + + @@ -14,8 +14,8 @@ - - + + diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/ByteOrderHack.java b/Core/src/main/velocity/com/nativelibs4java/opencl/ByteOrderHack.java deleted file mode 100644 index 36f045d1..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/ByteOrderHack.java +++ /dev/null @@ -1,107 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; - -import com.nativelibs4java.util.EnumValue; -import com.nativelibs4java.util.EnumValues; -import com.nativelibs4java.opencl.library.OpenCLLibrary; -import com.nativelibs4java.util.IOUtils; -import com.nativelibs4java.util.NIOUtils; - -import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; -import org.bridj.*; -import static org.bridj.Pointer.*; - -import java.io.IOException; -import java.nio.*; -import static com.nativelibs4java.opencl.JavaCL.*; -import static com.nativelibs4java.util.NIOUtils.*; -import java.util.*; -import static com.nativelibs4java.opencl.CLException.*; -import org.bridj.ValuedEnum; -import java.util.logging.Level; -import java.util.logging.Logger; - -class ByteOrderHack { - public static final boolean hackEnabled = - "1".equals(System.getenv("JAVACL_GUESS_ENDIANNESS")) || - "true".equals(System.getProperty("javacl.guessEndianness")); - public static ByteOrder guessByteOrderNeededForBuffers(CLDevice device) { - CLPlatform platform = device.getPlatform(); - PlatformUtils.PlatformKind knownPlatform = PlatformUtils.guessPlatformKind(platform); - if (!hackEnabled || knownPlatform != PlatformUtils.PlatformKind.AMDApp) - return device.getByteOrder(); - else - return checkByteOrderNeededForBuffers(device); - } - public static ByteOrder checkByteOrderNeededForBuffers(CLDevice device) { - CLContext context = JavaCL.createContext((Map)null, device); - CLQueue queue = context.createDefaultQueue(); - try { - int n = 16; - String testValueStr = "123456789f";//.101112f"; - float testValue = Float.parseFloat(testValueStr); - final int BIG_INDEX = 0, LITTLE_INDEX = 1; - - Pointer inPtr = Pointer.allocateFloats(n); - inPtr.order(ByteOrder.BIG_ENDIAN).set(BIG_INDEX, testValue); - inPtr.order(ByteOrder.LITTLE_ENDIAN).set(LITTLE_INDEX, testValue); - - CLBuffer inOut = context.createFloatBuffer(CLMem.Usage.InputOutput, inPtr); - CLBuffer success = context.createIntBuffer(CLMem.Usage.Output, n); - - String src = - "__kernel void compare_endiannesses(__global float *inout, __global int *success) {\n" + - "size_t i = get_global_id(0);\n" + - "success[i] = (inout[i] == " + testValueStr + ");\n" + - "inout[i] = " + testValueStr + ";\n" + - "}"; - - CLKernel test = context.createProgram(src).createKernel("compare_endiannesses"); - test.setArgs(inOut, success); - test.enqueueNDRange(queue, new int[] { n }, new int[] { 1 }); - - Pointer successPtr = Pointer.allocateInts(n); - success.read(queue, successPtr, true); - Pointer outPtr = Pointer.allocateFloats(n); - inOut.read(queue, outPtr, true); - - boolean bigOk = successPtr.get(BIG_INDEX) != 0; - boolean littleOk = successPtr.get(LITTLE_INDEX) != 0; - - int index, otherIndex; - ByteOrder order, otherOrder; - if (bigOk) { - order = ByteOrder.BIG_ENDIAN; - index = BIG_INDEX; - otherOrder = ByteOrder.LITTLE_ENDIAN; - otherIndex = LITTLE_INDEX; - } else { - order = ByteOrder.LITTLE_ENDIAN; - index = LITTLE_INDEX; - otherOrder = ByteOrder.BIG_ENDIAN; - otherIndex = BIG_INDEX; - } - float value = outPtr.order(order).get(index); - float otherValue = outPtr.order(otherOrder).get(otherIndex); - - if (JavaCL.debug) - System.out.println("[" + device + "] Endianness test: bigOk = " + bigOk + ", littleOk = " + littleOk + "; value = " + value + ", otherValue = " + otherValue); - - if (!(bigOk ^ littleOk)) - throw new RuntimeException("[" + device + "] Endianness check failed, kernel recognized both endiannesses..."); - - { - if (value != testValue || otherValue == testValue) - throw new RuntimeException("[" + device + "] Endianness double-check failed, expected " + testValue + " and found " + value + " instead for endianness " + order + " (otherValue = " + otherValue + " for " + otherOrder + ")"); - - return order; - } - } catch (Throwable ex) { - throw new RuntimeException("[" + device + "] Endianness check failed: " + ex, ex); - } finally { - queue.release(); - context.release(); - } - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLAbstractEntity.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLAbstractEntity.java deleted file mode 100644 index 69f81dc2..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLAbstractEntity.java +++ /dev/null @@ -1,124 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import org.bridj.*; -import static org.bridj.Pointer.*; - -abstract class CLAbstractEntity { - private long entityPeer; - private final boolean nullable; - - protected CLAbstractEntity(long entityPeer) { - this(entityPeer, false); - } - - protected CLAbstractEntity(long entityPeer, boolean nullable) { - this.nullable = nullable; - this.entityPeer = entityPeer; - checkNullity(entityPeer); - } - - private void checkNullity(long entityPeer) { - if (!nullable && entityPeer == 0) { - throw new IllegalArgumentException("Null OpenCL " + getClass().getSimpleName() + " !"); - } - } - - protected void setEntity(long entityPeer) { - checkNullity(entityPeer); - this.entityPeer = entityPeer; - } - - static Pointer copyNonNullEntities(CLAbstractEntity[] entities, int[] countOut, ReusablePointer tmp) { - if (entities == null) { - countOut[0] = 0; - return null; - } - int n = entities.length; - Pointer out = null; - - int count = 0; - for (int i = 0; i < n; i++) { - CLAbstractEntity entity = entities[i]; - if (entity != null && entity != CLEvent.FIRE_AND_FORGET) { - long pointer = entity.getEntity(); - if (pointer != 0) { - if (out == null) - out = tmp.allocatedBytes(Pointer.SIZE * (n - i)); - - out.setSizeTAtOffset(Pointer.SIZE * count, pointer); - - count++; - } - } - } - countOut[0] = count; - return out; - } - - /** - * Manual release of the OpenCL resources represented by this object.
    - * Note that resources are automatically released by the garbage collector, so in general there's no need to call this method.
    - * In an environment with fast allocation/deallocation of large objects, it might be safer to call release() manually, though.
    - * Note that release() does not necessarily free the object immediately : OpenCL maintains a reference count for all its objects, and an object released on the Java side might still be pointed to by running kernels or queued operations. - */ - public synchronized void release() { - if (entityPeer == 0) { - if (!nullable) - throw new RuntimeException("This " + getClass().getSimpleName() + " has already been released ! Besides, keep in mind that manual release is not necessary, as it will automatically be done by the garbage collector."); - else - return; - } - - doRelease(); - } - - public static Pointer getEntities(A[] objects, Pointer out) { - for (int i = 0, len = objects.length; i < len; i++) - out.setSizeTAtOffset(i * Pointer.SIZE, objects[i].getEntity()); - return out; - } - private void checkNullity() { - if (entityPeer == 0 && !nullable) - throw new RuntimeException("This " + getClass().getSimpleName() + " has been manually released and can't be used anymore !"); - } - - synchronized long getEntity() { - checkNullity(); - return entityPeer; - } - - synchronized void doRelease() { - if (entityPeer != 0) { - clear(); - entityPeer = 0; - } - } - @Override - protected void finalize() throws Throwable { - doRelease(); - } - - protected abstract void clear(); - - /** - * Underyling implementation pointer-based hashCode computation - */ - @Override - public int hashCode() { - return entityPeer == 0 - ? 0 - : Long.valueOf(entityPeer).hashCode(); - } - - /** - * Underyling implementation pointer-based equality test - */ - @Override - public boolean equals(Object obj) { - if (!getClass().isInstance(obj)) - return false; - CLAbstractEntity e = (CLAbstractEntity)obj; - return getEntity() == e.getEntity(); - } - -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java index d30051f7..a2e716de 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuffer.java @@ -1,31 +1,51 @@ -#parse("main/Header.vm") - -#macro (documentMapFlags) - * @param flags Map flags. -#end - +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; -import com.nativelibs4java.util.Pair; import static com.nativelibs4java.opencl.CLException.error; -import static com.nativelibs4java.opencl.JavaCL.*; +import static com.nativelibs4java.opencl.JavaCL.CL; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; +import static com.nativelibs4java.util.JNAUtils.toNS; import static com.nativelibs4java.util.NIOUtils.directBytes; import static com.nativelibs4java.util.NIOUtils.directCopy; -import java.nio.ByteBuffer; +import java.nio.*; import com.nativelibs4java.opencl.library.cl_buffer_region; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import org.bridj.*; -import java.nio.ByteOrder; -import java.nio.Buffer; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; import com.nativelibs4java.util.NIOUtils; -import org.bridj.util.Utils; -import static org.bridj.Pointer.*; -import static com.nativelibs4java.opencl.proxy.PointerUtils.*; - +import com.ochafik.util.listenable.Pair; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; /** * OpenCL Memory Buffer Object.
    @@ -35,131 +55,50 @@ * @author Olivier Chafik */ public class CLBuffer extends CLMem { - final Object owner; - final PointerIO io; - - CLBuffer(CLContext context, long byteCount, long entityPeer, Object owner, PointerIO io) { - super(context, byteCount, entityPeer); - this.owner = owner; - this.io = io; + /// Buffer to retain a reference to (because it's being copied asynchronously to the underlying OpenCL buffer) + Buffer buffer; + final int elementSize; + final Class typedBufferClass; + final Class elementClass; + CLBuffer(CLContext context, long byteCount, cl_mem entity, Buffer buffer, int elementSize, Class typedBufferClass) { + super(context, byteCount, entity); + this.buffer = buffer; + this.elementSize = elementSize; + this.typedBufferClass = typedBufferClass; + this.elementClass = (Class)NIOUtils.getPrimitiveClass(typedBufferClass); } + public Class getBufferClass() { + return typedBufferClass; + } public Class getElementClass() { - return Utils.getClass(io.getTargetType()); + return elementClass; } public int getElementSize() { - return (int)io.getTargetSize(); + return elementSize; } public long getElementCount() { return getByteCount() / getElementSize(); } - /** -#documentCallsFunction("clEnqueueMapBuffer") -#documentQueue() -#documentMapFlags() -#documentEventsToWaitForAndReturn() - */ - public Pointer map(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { - return map(queue, flags, 0, getElementCount(), true, eventsToWaitFor).getFirst(); + public B map(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { + return (B)map(queue, flags, 0, getElementCount(), true, eventsToWaitFor).getFirst(); } - /** -#documentCallsFunction("clEnqueueMapBuffer") -#documentQueue() -#documentMapFlags() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) -#documentEventsToWaitForAndReturn() - */ - public Pointer map(CLQueue queue, MapFlags flags, long offset, long length, CLEvent... eventsToWaitFor) throws CLException.MapFailure { - return map(queue, flags, offset, length, true, eventsToWaitFor).getFirst(); + public B map(CLQueue queue, MapFlags flags, long offset, long length, CLEvent... eventsToWaitFor) throws CLException.MapFailure { + return (B)map(queue, flags, offset, length, true, eventsToWaitFor).getFirst(); } - - /** -#documentCallsFunction("clEnqueueMapBuffer") -#documentQueue() -#documentMapFlags() -#documentEventsToWaitForAndReturn() - */ - public Pair, CLEvent> mapLater(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { + public Pair mapLater(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { return map(queue, flags, 0, getElementCount(), false, eventsToWaitFor); } - /** -#documentCallsFunction("clEnqueueMapBuffer") -#documentQueue() -#documentMapFlags() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) -#documentEventsToWaitForAndReturn() - */ - public Pair, CLEvent> mapLater(CLQueue queue, MapFlags flags, long offset, long length, CLEvent... eventsToWaitFor) throws CLException.MapFailure { + public Pair mapLater(CLQueue queue, MapFlags flags, long offset, long length, CLEvent... eventsToWaitFor) throws CLException.MapFailure { return map(queue, flags, offset, length, false, eventsToWaitFor); } - - /** -#documentCallsFunction("clEnqueueFillBuffer") -#documentQueue() - * @param pattern Data pattern to fill the buffer with. -#documentEventsToWaitForAndReturn() - */ - public CLEvent fillBuffer(CLQueue queue, Pointer pattern, CLEvent... eventsToWaitFor) { - return fillBuffer(queue, pattern, pattern.getValidElements(), 0, getElementCount(), eventsToWaitFor); - } - - /** -#documentCallsFunction("clEnqueueFillBuffer") - * @param pattern Data pattern to fill the buffer with. - * @param patternLength Length in elements (not in bytes) of the pattern to use. - * @param offset Offset in elements where to start filling the pattern. - * @param length Length in elements of the fill (must be a multiple of patternLength). -#documentEventsToWaitForAndReturn() - */ - public CLEvent fillBuffer(CLQueue queue, Pointer pattern, long patternLength, long offset, long length, CLEvent... eventsToWaitFor) { - context.getPlatform().requireMinVersionValue("clEnqueueFillBuffer", 1.2); - checkBounds(offset, length); - check(pattern != null, "Null pattern!"); - long validPatternElements = pattern.getValidElements(); - check(validPatternElements < 0 || patternLength <= validPatternElements, - "Pattern length exceeds the valid pattern elements count (%d > %d)", - patternLength, validPatternElements); - check(length % patternLength == 0, "Fill length must be a multiple of pattern length"); - - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueFillBuffer( - queue.getEntity(), - getEntity(), - getPeer(pattern), - patternLength * getElementSize(), - offset * getElementSize(), - length * getElementSize(), - #eventsInOutArgsRaw() - )); - #returnEventOut("queue") - } - - /** - * Returns a pointer to native memory large enough for this buffer's data, and with a compatible byte ordering. - */ - public Pointer allocateCompatibleMemory(CLDevice device) { - return allocateArray(io, getElementCount()).order(device.getKernelsDefaultByteOrder()); - } - - public PointerIO getIO() { - return io; - } - - /** -#documentCallsFunction("clEnqueueReadBuffer") - */ - public Pointer read(CLQueue queue, CLEvent... eventsToWaitFor) { - Pointer out = allocateCompatibleMemory(queue.getDevice()); + public B read(CLQueue queue, CLEvent... eventsToWaitFor) { + B out = (B)typedBuffer(directBytes((int)getByteCount(), queue.getDevice().getKernelsDefaultByteOrder())); read(queue, out, true, eventsToWaitFor); return out; } - /** -#documentCallsFunction("clEnqueueReadBuffer") - */ - public Pointer read(CLQueue queue, long offset, long length, CLEvent... eventsToWaitFor) { - Pointer out = allocateCompatibleMemory(queue.getDevice()); + public B read(CLQueue queue, long offset, long length, CLEvent... eventsToWaitFor) { + B out = (B)typedBuffer(directBytes((int)getByteCount(), queue.getDevice().getKernelsDefaultByteOrder())); read(queue, offset, length, out, true, eventsToWaitFor); return out; } @@ -170,44 +109,50 @@ protected void checkBounds(long offset, long length) { } /** -#documentCallsFunction("clCreateSubBuffer") * Can be used to create a new buffer object (referred to as a sub-buffer object) from an existing buffer object. * @param usage is used to specify allocation and usage information about the image memory object being created and is described in table 5.3 of the OpenCL spec. * @param offset - * @param length length in bytes + * @param length * @since OpenCL 1.1 * @return sub-buffer that is a "window" of this buffer starting at the provided offset, with the provided length */ public CLBuffer createSubBuffer(Usage usage, long offset, long length) { - context.getPlatform().requireMinVersionValue("clCreateSubBuffer", 1.1); - int s = getElementSize(); - cl_buffer_region region = new cl_buffer_region().origin(s * offset).size(s * length); - #declareReusablePtrsAndPErr() - long mem = CL.clCreateSubBuffer(getEntity(), usage.getIntFlags(), CL_BUFFER_CREATE_TYPE_REGION, getPeer(getPointer(region)), getPeer(pErr)); - #checkPErr() - return mem == 0 ? null : new CLBuffer(context, length * s, mem, null, io); + try { + int s = getElementSize(); + cl_buffer_region region = new cl_buffer_region(toNS(s * offset), toNS(s * length)); + IntByReference pErr = new IntByReference(); + cl_mem mem = CL.clCreateSubBuffer(getEntity(), usage.getIntFlags(), CL_BUFFER_CREATE_TYPE_REGION, region.getPointer(), pErr); + error(pErr.getValue()); + return mem == null ? null : createBuffer(mem); + } catch (Throwable th) { + // TODO check if supposed to handle OpenCL 1.1 + throw new UnsupportedOperationException("Cannot create sub-buffer (OpenCL 1.1 feature).", th); + } } /** * enqueues a command to copy a buffer object identified by src_buffer to another buffer object identified by destination. - * @param destination destination buffer object -#documentEventsToWaitForAndReturn() + * @param queue + * @param destination + * @param eventsToWaitFor + * @return event which indicates the copy operation has completed */ public CLEvent copyTo(CLQueue queue, CLMem destination, CLEvent... eventsToWaitFor) { return copyTo(queue, 0, getElementCount(), destination, 0, eventsToWaitFor); } /** -#documentCallsFunction("clEnqueueCopyBuffer") * enqueues a command to copy a buffer object identified by src_buffer to another buffer object identified by destination. -#documentQueue() + * @param queue * @param srcOffset - * @param length length in bytes - * @param destination destination buffer object + * @param length + * @param destination * @param destOffset -#documentEventsToWaitForAndReturn() + * @param eventsToWaitFor + * @return event which indicates the copy operation has completed */ public CLEvent copyTo(CLQueue queue, long srcOffset, long length, CLMem destination, long destOffset, CLEvent... eventsToWaitFor) { + cl_event[] eventOut = CLEvent.new_event_out(eventsToWaitFor); long byteCount = getByteCount(), destByteCount = destination.getByteCount(), @@ -225,356 +170,201 @@ public CLEvent copyTo(CLQueue queue, long srcOffset, long length, CLMem destinat ) throw new IndexOutOfBoundsException("Invalid copy parameters : srcOffset = " + srcOffset + ", destOffset = " + destOffset + ", length = " + length + " (element size = " + eltSize + ", source byte count = " + byteCount + ", destination byte count = " + destByteCount + ")"); - #declareReusablePtrsAndEventsInOut() + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); error(CL.clEnqueueCopyBuffer( queue.getEntity(), getEntity(), destination.getEntity(), - actualSrcOffset, - actualDestOffset, - actualLength, - #eventsInOutArgsRaw() + toNS(actualSrcOffset), + toNS(actualDestOffset), + toNS(actualLength), + evts == null ? 0 : evts.length, evts, + eventOut )); - #returnEventOut("queue") + return CLEvent.createEvent(queue, eventOut); } - /** -#documentCallsFunction("clEnqueueMapBuffer") - */ - protected Pair, CLEvent> map(CLQueue queue, MapFlags flags, long offset, long length, boolean blocking, CLEvent... eventsToWaitFor) { - if (flags == MapFlags.WriteInvalidateRegion) { - context.getPlatform().requireMinVersionValue("CL_MAP_WRITE_INVALIDATE_REGION", 1.2); - } + protected Pair map(CLQueue queue, MapFlags flags, long offset, long length, boolean blocking, CLEvent... eventsToWaitFor) { checkBounds(offset, length); - #declareReusablePtrsAndEventsInOutBlockable() - #declarePErr() - long mappedPeer = CL.clEnqueueMapBuffer( - queue.getEntity(), - getEntity(), - blocking ? CL_TRUE : CL_FALSE, + cl_event[] eventOut = blocking ? null : CLEvent.new_event_out(eventsToWaitFor); + IntByReference pErr = new IntByReference(); + + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + Pointer p = CL.clEnqueueMapBuffer(queue.getEntity(), getEntity(), blocking ? CL_TRUE : CL_FALSE, flags.value(), - offset * getElementSize(), - length * getElementSize(), - #eventsInOutArgsRaw(), - getPeer(pErr) + toNS(offset * getElementSize()), + toNS(length * getElementSize()), + evts == null ? 0 : evts.length, evts, + eventOut, + pErr ); - #checkPErr() - if (mappedPeer == 0) - return null; - return new Pair, CLEvent>( - pointerToAddress(mappedPeer, io).validElements(length).order(queue.getDevice().getKernelsDefaultByteOrder()), - #eventOutWrapper("queue") + error(pErr.getValue()); + return new Pair( + (B)typedBuffer(p.getByteBuffer(0, length * getElementSize()).order(queue.getDevice().getKernelsDefaultByteOrder())), + CLEvent.createEvent(queue, eventOut) ); } - /** -#documentCallsFunction("clEnqueueUnmapMemObject") -#documentQueue() - * @param buffer -#documentEventsToWaitForAndReturn() - */ - public CLEvent unmap(CLQueue queue, Pointer buffer, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOut(); - error(CL.clEnqueueUnmapMemObject(queue.getEntity(), getEntity(), getPeer(buffer), #eventsInOutArgsRaw())); - #returnEventOut("queue") + public CLEvent unmap(CLQueue queue, B buffer, CLEvent... eventsToWaitFor) { + typedBufferClass.cast(buffer); + cl_event[] eventOut = CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); + error(CL.clEnqueueUnmapMemObject(queue.getEntity(), getEntity(), Native.getDirectBufferPointer(buffer), evts == null ? 0 : evts.length, evts, eventOut)); + return CLEvent.createEvent(queue, eventOut); } - /** -#documentCallsFunction("clEnqueueReadBuffer") - * @deprecated use {@link CLBuffer#read(CLQueue, Pointer, boolean, CLEvent[])} instead -#documentQueue() - * @param out output buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - @Deprecated - public CLEvent read(CLQueue queue, Buffer out, boolean blocking, CLEvent... eventsToWaitFor) { - return read(queue, 0, -1, out, blocking, eventsToWaitFor); - } - - /** -#documentCallsFunction("clEnqueueReadBuffer") -#documentQueue() - * @param out output buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - public CLEvent read(CLQueue queue, Pointer out, boolean blocking, CLEvent... eventsToWaitFor) { - return read(queue, 0, -1, out, blocking, eventsToWaitFor); + public CLEvent read(CLQueue queue, B out, boolean blocking, CLEvent... eventsToWaitFor) { + typedBufferClass.cast(out); + long length; + if (isGL) { + length = out.capacity(); + } else { + length = getElementCount(); + long s = out.capacity(); + if (length > s) + length = s; + } + return read(queue, 0, length, out, blocking, eventsToWaitFor); } - /** -#documentCallsFunction("clEnqueueReadBuffer") - * @deprecated use {@link CLBuffer#read(CLQueue, long, long, Pointer, boolean, CLEvent[])} instead -#documentQueue() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) - * @param out output buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - @Deprecated public CLEvent read(CLQueue queue, long offset, long length, Buffer out, boolean blocking, CLEvent... eventsToWaitFor) { - if (out == null) - throw new IllegalArgumentException("Null output buffer !"); - - if (out.isReadOnly()) + typedBufferClass.cast(out); + if (out.isReadOnly()) throw new IllegalArgumentException("Output buffer for read operation is read-only !"); - boolean indirect = !out.isDirect(); - Pointer ptr = null; - if (indirect) { - ptr = allocateArray(io, length).order(queue.getDevice().getKernelsDefaultByteOrder()); - blocking = true; - } else { - ptr = (Pointer)pointerToBuffer(out); + Buffer originalOut = null; + if (!out.isDirect()) { + originalOut = out; + out = typedBuffer(directBytes((int)(length * getElementSize()), queue.getDevice().getKernelsDefaultByteOrder())); + blocking = true; } - CLEvent ret = read(queue, offset, length, ptr, blocking, eventsToWaitFor); - if (indirect) - NIOUtils.put(ptr.getBuffer(), out); - - return ret; - } - - /** -#documentCallsFunction("clEnqueueReadBuffer") -#documentQueue() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) - * @param out output buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - public CLEvent read(CLQueue queue, long offset, long length, Pointer out, boolean blocking, CLEvent... eventsToWaitFor) { - if (out == null) - throw new IllegalArgumentException("Null output pointer !"); - - if (length < 0) { - if (isGL) { - length = out.getValidElements(); - } - if (length < 0) { - length = getElementCount(); - long s = out.getValidElements(); - if (length > s && s >= 0) - length = s; - } - } - - #declareReusablePtrsAndEventsInOutBlockable() + cl_event[] eventOut = blocking ? null : CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); error(CL.clEnqueueReadBuffer( queue.getEntity(), getEntity(), blocking ? CL_TRUE : 0, - offset * getElementSize(), - length * getElementSize(), - getPeer(out), - #eventsInOutArgsRaw() + toNS(offset * getElementSize()), + toNS(length * getElementSize()), + Native.getDirectBufferPointer(out), + evts == null ? 0 : evts.length, evts, + eventOut )); - #returnEventOut("queue") + if (originalOut != null) + NIOUtils.put(out, originalOut); + return CLEvent.createEvent(queue, eventOut); } - - /** -#documentCallsFunction("clEnqueueWriteBuffer") - * @deprecated use {@link CLBuffer#write(CLQueue, Pointer, boolean, CLEvent[])} instead -#documentQueue() - * @param in input buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - @Deprecated + public CLEvent write(CLQueue queue, Buffer in, boolean blocking, CLEvent... eventsToWaitFor) { - return write(queue, 0, -1, in, blocking, eventsToWaitFor); - } - - /** -#documentCallsFunction("clEnqueueWriteBuffer") -#documentQueue() - * @param in input buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - public CLEvent write(CLQueue queue, Pointer in, boolean blocking, CLEvent... eventsToWaitFor) { - return write(queue, 0, -1, in, blocking, eventsToWaitFor); + typedBufferClass.cast(in); + long length; + if (isGL) { + length = in.capacity(); + } else { + length = getElementCount(); + long s = in.capacity(); + if (length > s) + length = s; + } + return write(queue, 0, length, in, blocking, eventsToWaitFor); } - /** -#documentCallsFunction("clEnqueueWriteBuffer") - * @deprecated use {@link CLBuffer#write(CLQueue, long, long, Pointer, boolean, CLEvent[])} instead -#documentQueue() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) - * @param in input buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - @Deprecated public CLEvent write(CLQueue queue, long offset, long length, Buffer in, boolean blocking, CLEvent... eventsToWaitFor) { - if (in == null) - throw new IllegalArgumentException("Null input buffer !"); - - boolean indirect = !in.isDirect(); - Pointer ptr = null; - if (indirect) { - ptr = allocateArray(io, length).order(queue.getDevice().getKernelsDefaultByteOrder()); - ptr.setValues(in); - blocking = true; - } else { - ptr = (Pointer)pointerToBuffer(in); + typedBufferClass.cast(in); + + if (!in.isDirect()) { + blocking = true; + in = typedBuffer(directCopy(in, queue.getDevice().getKernelsDefaultByteOrder())); } - return write(queue, offset, length, ptr, blocking, eventsToWaitFor); - } - - /** -#documentCallsFunction("clEnqueueWriteBuffer") -#documentQueue() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) - * @param in input buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - public CLEvent write(CLQueue queue, long offset, long length, Pointer in, boolean blocking, CLEvent... eventsToWaitFor) { - if (length == 0) - return null; - - if (in == null) - throw new IllegalArgumentException("Null input pointer !"); - - if (length < 0) { - if (isGL) - length = in.getValidElements(); - if (length < 0) { - length = getElementCount(); - long s = in.getValidElements(); - if (length > s && s >= 0) - length = s; - } - } - - #declareReusablePtrsAndEventsInOutBlockable() + + cl_event[] eventOut = blocking ? null : CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); error(CL.clEnqueueWriteBuffer( queue.getEntity(), getEntity(), blocking ? CL_TRUE : CL_FALSE, - offset * getElementSize(), - length * getElementSize(), - getPeer(in), - #eventsInOutArgsRaw() + toNS(offset * getElementSize()), + toNS(length * getElementSize()), + Native.getDirectBufferPointer(in), + evts == null ? 0 : evts.length, evts, + eventOut )); - #returnEventOut("queue") + return CLEvent.createEvent(queue, eventOut); } - /** -#documentCallsFunction("clEnqueueWriteBuffer") -#documentQueue() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) - * @param in input buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - public CLEvent writeBytes(CLQueue queue, long offset, long length, ByteBuffer in, boolean blocking, CLEvent... eventsToWaitFor) { - return writeBytes(queue, offset, length, pointerToBuffer(in), blocking, eventsToWaitFor); - } - /** -#documentCallsFunction("clEnqueueWriteBuffer") -#documentQueue() - * @param offset offset in the {@link CLBuffer} - * @param length length to write (in bytes) - * @param in input buffer - * @param blocking whether the operation should be blocking (and return null), or non-blocking (and return a completion event) -#documentEventsToWaitForAndReturn() - */ - public CLEvent writeBytes(CLQueue queue, long offset, long length, Pointer in, boolean blocking, CLEvent... eventsToWaitFor) { - if (in == null) - throw new IllegalArgumentException("Null input pointer !"); - - #declareReusablePtrsAndEventsInOutBlockable() + public CLEvent writeBytes(CLQueue queue, long offset, long length, ByteBuffer in, boolean blocking, CLEvent... eventsToWaitFor) { + if (!in.isDirect()) { + blocking = true; + in = directCopy(in, queue.getDevice().getKernelsDefaultByteOrder()); + } + + cl_event[] eventOut = blocking ? null : CLEvent.new_event_out(eventsToWaitFor); + cl_event[] evts = CLEvent.to_cl_event_array(eventsToWaitFor); error(CL.clEnqueueWriteBuffer( queue.getEntity(), getEntity(), blocking ? CL_TRUE : 0, - offset, - length, - getPeer(in), - #eventsInOutArgsRaw() + toNS(offset), + toNS(length), + Native.getDirectBufferPointer(in), + evts == null ? 0 : evts.length, evts, + eventOut )); - #returnEventOut("queue") + return CLEvent.createEvent(queue, eventOut); } + public ByteBuffer readBytes(CLQueue queue, long offset, long length, CLEvent... eventsToWaitFor) { + ByteBuffer out = directBytes((int)getByteCount(), queue.getDevice().getKernelsDefaultByteOrder()); + Buffer tout = typedBuffer(out); + read(queue, offset, tout.capacity(), tout, true, eventsToWaitFor); + return out; + } + private T copyGLMark(T mem) { mem.isGL = this.isGL; return mem; } - + public CLBuffer emptyClone(CLMem.Usage usage) { - return (CLBuffer)getContext().createBuffer(usage, io, getElementCount()); + return (CLBuffer)getContext().createBuffer(usage, typedBufferClass, getElementCount()); } + protected CLBuffer createBuffer(cl_mem mem) { + + //return new CLBuffer(getContext(), -1, mem, null, getElementSize(), typedBufferClass); + + #foreach ($prim in $primitivesNoBool) + + if (typedBufferClass == ${prim.BufferName}.class) + return (CLBuffer)new CL${prim.BufferName}(getContext(), -1, mem, null); + + #end + + throw new RuntimeException("Unable to create an OpenCL buffer for type " + typedBufferClass.getName()); + } + + protected B typedBuffer(ByteBuffer b) { + #foreach ($prim in $primitivesNoBool) + + if (typedBufferClass == ${prim.BufferName}.class) + #if ($prim.Name == "byte") + return (B)b; + #else + return (B)b.as${prim.BufferName}(); + #end + + #end + + throw new RuntimeException("Unable to create a typed buffer for type " + typedBufferClass.getName()); + } + #foreach ($prim in $primitivesNoBool) - public CLBuffer<${prim.WrapperName}> asCL${prim.BufferName}() { - return as(${prim.WrapperName}.class); + public CL${prim.BufferName} asCL${prim.BufferName}() { + cl_mem mem = getEntity(); + CL.clRetainMemObject(getEntity()); + return copyGLMark(new CL${prim.BufferName}(context, getByteCount(), mem, buffer)); } #end - - public CLBuffer as(Class newTargetType) { - long mem = getEntity(); - assert mem != 0; - error(CL.clRetainMemObject(mem)); - PointerIO newIO = PointerIO.getInstance(newTargetType); - return copyGLMark(new CLBuffer(context, getByteCount(), mem, owner, newIO)); - } - - /** -#documentCallsFunction("clEnqueueCopyBuffer") -#documentQueue() - * @param destination destination buffer object -#documentEventsToWaitForAndReturn() - */ - public CLEvent copyTo(CLQueue queue, CLBuffer destination, CLEvent... eventsToWaitFor) { - return copyBytesTo(queue, destination, 0, 0, getByteCount(), eventsToWaitFor); - } - - /** -#documentCallsFunction("clEnqueueCopyBuffer") -#documentQueue() - * @param destination destination buffer object - * @param sourceByteOffset byte offset in the source - * @param destinationByteOffset byte offset in the destination - * @param byteCount number of bytes to copy -#documentEventsToWaitForAndReturn() - */ - public CLEvent copyBytesTo(CLQueue queue, CLBuffer destination, long sourceByteOffset, long destinationByteOffset, long byteCount, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueCopyBuffer( - queue.getEntity(), - getEntity(), - destination.getEntity(), - sourceByteOffset, - destinationByteOffset, - byteCount, - #eventsInOutArgsRaw())); - #returnEventOut("queue") - } - - /** -#documentCallsFunction("clEnqueueCopyBuffer") -#documentQueue() - * @param destination destination buffer object - * @param sourceElementOffset element offset in the source - * @param destinationElementOffset element offset in the destination - * @param elementCount number of elements to copy -#documentEventsToWaitForAndReturn() - */ - public CLEvent copyElementsTo(CLQueue queue, CLBuffer destination, long sourceElementOffset, long destinationElementOffset, long elementCount, CLEvent... eventsToWaitFor) { - long elementSize = getElementSize(); - return copyBytesTo(queue, destination, - sourceElementOffset * elementSize, - destinationElementOffset * elementSize, - elementCount * elementSize, - eventsToWaitFor); - } - + } diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuildException.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuildException.java deleted file mode 100644 index 423ef208..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLBuildException.java +++ /dev/null @@ -1,21 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; - -import com.ochafik.util.string.StringUtils; -import java.util.Collection; - -/** - * OpenCL program build exception - * @author ochafik - */ -@SuppressWarnings("serial") -public class CLBuildException extends CLException { - final CLProgram program; - CLBuildException(CLProgram program, String string, Collection errors) { - super(string + "\n" + StringUtils.implode(errors, "\n"), -1); - this.program = program; - } - public CLProgram getProgram() { - return program; - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLContext.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLContext.java index 4b22f5ab..867cf135 100644 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLContext.java +++ b/Core/src/main/velocity/com/nativelibs4java/opencl/CLContext.java @@ -1,14 +1,44 @@ -#parse("main/Header.vm") +/* + * JavaCL - Java API and utilities for OpenCL + * http://javacl.googlecode.com/ + * + * Copyright (c) 2009-2015, Olivier Chafik (http://ochafik.com/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Olivier Chafik nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY OLIVIER CHAFIK AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package com.nativelibs4java.opencl; -import com.nativelibs4java.util.Pair; +import com.ochafik.util.listenable.Pair; import static com.nativelibs4java.opencl.CLException.error; import static com.nativelibs4java.opencl.CLException.failedForLackOfMemory; import static com.nativelibs4java.opencl.JavaCL.CL; import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event; import static com.nativelibs4java.util.ImageUtils.getImageIntPixels; +import static com.nativelibs4java.util.JNAUtils.toNS; +import static com.nativelibs4java.util.JNAUtils.toNSArray; import static com.nativelibs4java.util.NIOUtils.getSizeInBytes; import java.awt.Image; @@ -23,8 +53,6 @@ import java.nio.LongBuffer; import java.nio.ShortBuffer; import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicReference; import java.util.List; import java.util.logging.*; @@ -34,133 +62,55 @@ import com.nativelibs4java.opencl.ImageIOUtils.ImageInfo; import com.nativelibs4java.opencl.library.OpenGLContextUtils; import com.nativelibs4java.opencl.library.cl_image_format; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_context; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_device_id; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_sampler; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem; +import com.nativelibs4java.opencl.library.OpenCLLibrary.cl_sampler; import com.nativelibs4java.util.EnumValue; import com.nativelibs4java.util.EnumValues; import com.nativelibs4java.util.NIOUtils; -import org.bridj.*; -import static org.bridj.Pointer.*; -import static com.nativelibs4java.opencl.proxy.PointerUtils.*; +import com.nativelibs4java.util.ValuedEnum; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.sun.jna.Memory; +import com.sun.jna.Native; +import com.sun.jna.Platform; +import com.sun.jna.Pointer; +import com.sun.jna.ptr.IntByReference; import java.io.InputStream; import java.util.Arrays; import java.util.Map; - /** * OpenCL context.
    * An OpenCL context is created with one or more devices.
    * Contexts are used by the OpenCL runtime for managing objects such as command-queues, memory, program and kernel objects and for executing kernels on one or more devices specified in the context. * @author Olivier Chafik */ -public class CLContext extends CLAbstractEntity { +public class CLContext extends CLAbstractEntity { #macro (docCreateBufferCopy $bufferType $details) /** -#documentCallsFunction("clCreateBuffer") - * Create a $bufferType OpenCL buffer $details with the provided initial values.
    + * Create a $bufferType OpenCL buffer $details with the provided initial values.
    * If copy is true (see CL_MEM_COPY_HOST_PTR), then the buffer will be hosted in OpenCL and will have the best performance, but any change done to the OpenCL buffer won't be propagated to the original data pointer.
    - * If copy is false (see CL_MEM_USE_HOST_PTR), then the provided data pointer will be used for storage of the OpenCL buffer. OpenCL might still cache the data in the OpenCL land, so careful use of {@link CLBuffer#map(CLQueue, CLMem.MapFlags, CLEvent...) CLBuffer#map(CLQueue, MapFlags, CLEvent...)} is then necessary to ensure the data is properly synchronized with the buffer. - * @param usage Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. - * @param data Pointer to the initial values, must have known bounds (see {@link Pointer#getValidElements()}). - * @param data Data buffer. - * @param copy Whether to copy the input data. - * @return A new buffer allocated on this context. + * If copy is false (see CL_MEM_USE_HOST_PTR), then the provided data pointer will be used for storage of the OpenCL buffer. OpenCL might still cache the data in the OpenCL land, so careful use of {@link CLBuffer#map(CLQueue, MapFlags, CLEvent[])} is then necessary to ensure the data is properly synchronized with the buffer. + * @param kind Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. + * @param data Buffer that contains the initial values. It must be direct for the non-copy mode, but indirect buffers should be avoided in all cases for performance reasons. */ #end #macro (docCreateBuffer $bufferType $type $insertParam $exampleOfLength) /** -#documentCallsFunction("clCreateBuffer") - * Create a $bufferType OpenCL buffer big enough to hold 'length' values of type $type. - * @param usage Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. - $insertParam - * @param elementCount Length of the buffer expressed in elements $exampleOfLength - * @return A new buffer allocated on this context. - */ -#end -#macro (docCreateBufferPointer $bufferType $type $insertParam $exampleOfLength) - /** -#documentCallsFunction("clCreateBuffer") - * Create a $bufferType OpenCL buffer big enough to hold the valid $type values of the provided data pointer. - * @param usage Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. - * @param data Host data to copy to the buffer - * @return A new buffer allocated on this context. - */ + * Create a $bufferType OpenCL buffer big enough to hold 'length' values of type $type. + * @param kind Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. + $insertParam + * @param elementCount Length of the buffer expressed in elements $exampleOfLength + */ #end #macro (docCreateBufferPrim $bufferType $prim) #docCreateBuffer($bufferType, $prim.Name, "", "(for instance, a $bufferType of length 10 will actually contain 10 * ${prim.Size} bytes, as ${prim.Name}s are ${prim.Size}-bytes-long)") #end -#macro (docCreateImage) - * @param usage Usage intended for the image. - * @param format Format of the image. - * @param width Image width - * @param height Image height - * @return A new image allocated on this context. -#end - -#macro (documentCreateImage2D) -#documentCallsFunction("clCreateImage2D") -#docCreateImage() -#end - -#macro (documentCreateImage3D) -#documentCallsFunction("clCreateImage3D") -#docCreateImage() - * @param depth Image depth -#end - -#macro (documentRowPitch) - * @param rowPitch Row pitch. -#end - -#macro (documentSlicePitch) - * @param slicePitch Slice pitch. -#end - -#macro (documentCopiableImageBuffer) - * @param buffer Image data buffer. - * @param copy Whether to copy the input buffer. -#end - - private final AtomicReference> propertiesMapRef = - new AtomicReference>(); - - public Object getClientProperty(Object key) { - ConcurrentHashMap propertiesMap = propertiesMapRef.get(); - return propertiesMap == null ? null : propertiesMap.get(key); - } - public Object putClientProperty(Object key, Object value) { - ConcurrentHashMap propertiesMap = propertiesMapRef.get(); - if (propertiesMap == null) { - propertiesMap = new ConcurrentHashMap(); - if (!propertiesMapRef.compareAndSet(null, propertiesMap)) - propertiesMap = propertiesMapRef.get(); - } - return propertiesMap.put(key, value); - } - - private volatile long maxMemAllocSize = -1; - - /** - * Max size of memory object allocation in bytes. The minimum value is max (1/4th of CL_DEVICE_GLOBAL_MEM_SIZE , 128*1024*1024) - */ - public long getMaxMemAllocSize() { - if (maxMemAllocSize < 0) { - long min = Long.MAX_VALUE; - for (CLDevice device : getDevices()) { - long m = device.getMaxMemAllocSize(); - if (m < min) - min = m; - } - maxMemAllocSize = min; - } - return maxMemAllocSize; - } - - volatile Boolean cacheBinaries; + volatile Boolean cacheBinaries; /** * Change whether program binaries are automatically cached or not.
    @@ -173,7 +123,7 @@ public synchronized void setCacheBinaries(boolean cacheBinaries) { } /** * Says whether program binaries are automatically cached or not.
    - * By default it is true, it can be set to false with the "javacl.cacheBinaries" Java property, the "JAVACL_CACHE_BINARIES" environment variable (when set to "0") or the {@link CLContext#setCacheBinaries(boolean) } method.
    + * By default it is true, it can be set to false with the "javacl.cacheBinaries" Java property, the "JAVACL_CACHE_BINARIES" environment variable (when set to "0") or the {@link JavaCL#setCacheBinaries(boolean) } method.
    * Each program can be set to be cached or not using {@link CLProgram#setCached(boolean) }.
    * Caching of binaries might be disabled by default on some platforms (ATI Stream, for instance). */ @@ -185,19 +135,28 @@ public synchronized boolean getCacheBinaries() { else if ("false".equals(prop) || "0".equals(env)) cacheBinaries = false; else { - cacheBinaries = !PlatformUtils.PlatformKind.AMDApp.equals(PlatformUtils.guessPlatformKind(getPlatform())); + String plat = getPlatform().getName(); + cacheBinaries = + !"ATI Stream".equals(plat) && + !"AMD Accelerated Parallel Processing".equals(plat) && + true; } //System.out.println("CACHE BINARIES = " + cacheBinaries); } return cacheBinaries; } - #declareInfosGetter("infos", "CL.clGetContextInfo") - + private static CLInfoGetter infos = new CLInfoGetter() { + + @Override + protected int getInfo(cl_context entity, int infoTypeEnum, NativeSize size, Pointer out, NativeSizeByReference sizeOut) { + return CL.clGetContextInfo(entity, infoTypeEnum, size, out, sizeOut); + } + }; CLPlatform platform; - protected Pointer deviceIds; + protected cl_device_id[] deviceIds; - CLContext(CLPlatform platform, Pointer deviceIds, long context) { + CLContext(CLPlatform platform, cl_device_id[] deviceIds, cl_context context) { super(context); this.platform = platform; this.deviceIds = deviceIds; @@ -206,18 +165,22 @@ else if ("false".equals(prop) || "0".equals(env)) JavaCL.log(Level.WARNING, "The devices in this context have mismatching byte orders. This mandates the use of __attribute__((endian(host))) in kernel sources or *very* careful use of buffers to avoid facing endianness issues"); } } - + /** * Creates a user event object.
    * User events allow applications to enqueue commands that wait on a user event to finish before the command is executed by the device. * @since OpenCL 1.1 */ - public CLUserEvent createUserEvent() { - platform.requireMinVersionValue("clCreateUserEvent", 1.1); - #declareReusablePtrsAndPErr() - long evt = CL.clCreateUserEvent(getEntity(), getPeer(pErr)); - #checkPErr() - return (CLUserEvent)CLEvent.createEvent(null, evt, true); + public CLEvent createUserEvent() { + try { + IntByReference pErr = new IntByReference(); + cl_event evt = CL.clCreateUserEvent(getEntity(), pErr); + error(pErr.getValue()); + return CLEvent.createEvent(null, evt, true); + } catch (Throwable th) { + // TODO throw if supposed to handle OpenCL 1.1 + return null; + } } /** @@ -226,7 +189,7 @@ public CLUserEvent createUserEvent() { * @return new OpenCL queue */ public CLQueue createDefaultQueue(QueueProperties... queueProperties) { - return new CLDevice(platform, deviceIds.getSizeT()).createQueue(this, queueProperties); + return new CLDevice(platform, deviceIds[0]).createQueue(this, queueProperties); } /** @@ -235,7 +198,7 @@ public CLQueue createDefaultQueue(QueueProperties... queueProperties) { * @return new out-of-order OpenCL queue */ public CLQueue createDefaultOutOfOrderQueue() { - return new CLDevice(platform, deviceIds.getSizeT()).createOutOfOrderQueue(this); + return new CLDevice(platform, deviceIds[0]).createOutOfOrderQueue(this); } @@ -255,7 +218,7 @@ public String toString() { public CLQueue createDefaultOutOfOrderQueueIfPossible() { try { return createDefaultOutOfOrderQueue(); - } catch (Throwable th) {//CLException.InvalidQueueProperties ex) { + } catch (CLException.InvalidQueueProperties ex) { return createDefaultQueue(); } } @@ -266,29 +229,31 @@ public CLQueue createDefaultOutOfOrderQueueIfPossible() { * @return new profiling-enabled OpenCL queue */ public CLQueue createDefaultProfilingQueue() { - return new CLDevice(platform, deviceIds.getSizeT()).createProfilingQueue(this); + return new CLDevice(platform, deviceIds[0]).createProfilingQueue(this); } - /** -#documentCallsFunction("clGetSupportedImageFormats") - */ @SuppressWarnings("deprecation") public CLImageFormat[] getSupportedImageFormats(CLBuffer.Flags flags, CLBuffer.ObjectType imageType) { - Pointer pCount = allocateInt(); + IntByReference pCount = new IntByReference(); int memFlags = (int) flags.value(); int imTyp = (int) imageType.value(); - CL.clGetSupportedImageFormats(getEntity(), memFlags, imTyp, 0, 0, getPeer(pCount)); - //cl_image_format ft = new cl_image_format(); - //int sz = ft.size(); - int n = pCount.getInt(); + Memory memCount = new Memory(16); + pCount.setPointer(memCount); + CL.clGetSupportedImageFormats(getEntity(), memFlags, imTyp, 0, null, pCount); + cl_image_format ft = new cl_image_format(); + int sz = ft.size(); + int n = pCount.getValue(); if (n == 0) { n = 30; // There HAS to be at least one format. the spec even says even more, but in fact on Mac OS X / CPU there's only one... } - Pointer formats = allocateArray(cl_image_format.class, n); - CL.clGetSupportedImageFormats(getEntity(), memFlags, imTyp, n, getPeer(formats), 0); + Memory mem = new Memory(n * sz); + ft.use(mem); + CL.clGetSupportedImageFormats(getEntity(), memFlags, imTyp, n, ft, (IntByReference) null); List ret = new ArrayList(n); - for (cl_image_format ft : formats) { - if (ft.image_channel_data_type() == 0 && ft.image_channel_order() == 0) + for (int i = 0; i < n; i++) { + ft.use(mem, i * sz); + ft.read(); + if (ft.image_channel_data_type == 0 && ft.image_channel_order == 0) break; ret.add(new CLImageFormat(ft)); @@ -296,20 +261,11 @@ public CLImageFormat[] getSupportedImageFormats(CLBuffer.Flags flags, CLBuffer.O return ret.toArray(new CLImageFormat[ret.size()]); } - /** -#documentCallsFunction("clCreateSampler") - */ @SuppressWarnings("deprecation") public CLSampler createSampler(boolean normalized_coords, AddressingMode addressing_mode, FilterMode filter_mode) { - #declareReusablePtrsAndPErr() - long sampler = CL.clCreateSampler( - getEntity(), - normalized_coords ? CL_TRUE : CL_FALSE, - (int) addressing_mode.value(), - (int) filter_mode.value(), - getPeer(pErr) - ); - #checkPErr() + IntByReference pErr = new IntByReference(); + cl_sampler sampler = CL.clCreateSampler(getEntity(), normalized_coords ? CL_TRUE : CL_FALSE, (int) addressing_mode.value(), (int) filter_mode.value(), pErr); + error(pErr.getValue()); return new CLSampler(sampler); } @@ -323,13 +279,16 @@ public int getDeviceCount() { */ public synchronized CLDevice[] getDevices() { if (deviceIds == null) { - deviceIds = infos.getMemory(getEntity(), CL_CONTEXT_DEVICES).as(SizeT.class); + Memory ptrs = infos.getMemory(getEntity(), CL_CONTEXT_DEVICES); + int n = (int) (ptrs.getSize() / Native.POINTER_SIZE); + deviceIds = new cl_device_id[n]; + for (int i = 0; i < n; i++) { + deviceIds[i] = new cl_device_id(ptrs.getPointer(i * Native.POINTER_SIZE)); + } } - int n = (int)deviceIds.getValidElements(); - - CLDevice[] devices = new CLDevice[n]; - for (int i = n; i-- != 0;) { - devices[i] = new CLDevice(platform, deviceIds.getSizeTAtIndex(i)); + CLDevice[] devices = new CLDevice[deviceIds.length]; + for (int i = devices.length; i-- != 0;) { + devices[i] = new CLDevice(platform, deviceIds[i]); } return devices; } @@ -353,7 +312,7 @@ public CLProgram createProgram(CLDevice[] devices, String... srcs) { /** * Restore a program previously saved with {@link CLProgram#store(java.io.OutputStream) } * @param in will be closed - * @return a CLProgram object representing the previously saved program + * @return * @throws IOException */ public CLProgram loadProgram(InputStream in) throws IOException { @@ -375,35 +334,25 @@ protected void clear() { @Deprecated public CLDevice guessCurrentGLDevice() { - long[] props = platform.getContextProps(CLPlatform.getGLContextProperties(getPlatform())); - Pointer propsRef = pointerToSizeTs(props); - - Pointer pCount = allocateSizeT(); - Pointer> mem = allocatePointer(); - if (Platform.isMacOSX()) - error(CL.clGetGLContextInfoAPPLE( - getEntity(), - getPeer(OpenGLContextUtils.CGLGetCurrentContext()), - CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, - Pointer.SIZE, - getPeer(mem), - getPeer(pCount))); + long[] props = CLPlatform.getContextProps(CLPlatform.getGLContextProperties(getPlatform())); + Memory propsMem = toNSArray(props); + NativeSizeByReference propsRef = new NativeSizeByReference(); + propsRef.setPointer(propsMem); + + NativeSizeByReference pCount = new NativeSizeByReference(); + Memory mem = new Memory(Pointer.SIZE); + if (Platform.isMac()) + error(CL.clGetGLContextInfoAPPLE(getEntity(), OpenGLContextUtils.INSTANCE.CGLGetCurrentContext(), CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, toNS(Pointer.SIZE), mem, pCount)); else - error(CL.clGetGLContextInfoKHR( - getPeer(propsRef), - CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, - Pointer.SIZE, - getPeer(mem), - getPeer(pCount) - )); - - if (pCount.getSizeT() != Pointer.SIZE) - throw new RuntimeException("Not a device : len = " + pCount.get().intValue()); - - Pointer p = mem.getPointer(); + error(CL.clGetGLContextInfoKHR(propsRef, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, toNS(Pointer.SIZE), mem, pCount)); + + if (pCount.getValue().intValue() != Pointer.SIZE) + throw new RuntimeException("Not a device : len = " + pCount.getValue().intValue()); + + Pointer p = mem.getPointer(0); if (p.equals(Pointer.NULL)) return null; - return new CLDevice(null, getPeer(p)); + return new CLDevice(null, new cl_device_id(p)); } private static T markAsGL(T mem) { @@ -412,61 +361,47 @@ private static T markAsGL(T mem) { } /** -#documentCallsFunction("clCreateFromGLBuffer") * Makes an OpenGL Vertex Buffer Object (VBO) visible to OpenCL as a buffer object.
    * Note that memory objects shared with OpenGL must be acquired / released before / after use from OpenCL. * see {@link CLMem#acquireGLObject(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLEvent[]) } * see {@link CLMem#releaseGLObject(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLEvent[]) } - * @param usage flags * @param openGLBufferObject Identifier of a VBO, as generated by glGenBuffers */ @SuppressWarnings("deprecation") - public CLBuffer createBufferFromGLBuffer(CLMem.Usage usage, int openGLBufferObject) { - #declareReusablePtrsAndPErr() - long mem; + public CLByteBuffer createBufferFromGLBuffer(CLMem.Usage usage, int openGLBufferObject) { + IntByReference pErr = new IntByReference(); + cl_mem mem; int previousAttempts = 0; do { - mem = CL.clCreateFromGLBuffer( - getEntity(), - usage.getIntFlags(), - openGLBufferObject, - getPeer(pErr) - ); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); - return markAsGL(new CLBuffer(this, -1, mem, null, PointerIO.getByteInstance())); + mem = CL.clCreateFromGLBuffer(getEntity(), usage.getIntFlags(), openGLBufferObject, pErr); + } while (failedForLackOfMemory(pErr.getValue(), previousAttempts++)); + return markAsGL(new CLByteBuffer(this, -1, mem, null)); } /** -#documentCallsFunction("clCreateFromGLRenderbuffer") * Makes an OpenGL Render Buffer visible to OpenCL as a 2D image.
    * Note that memory objects shared with OpenGL must be acquired / released before / after use from OpenCL. * see {@link CLMem#acquireGLObject(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLEvent[]) } * see {@link CLMem#releaseGLObject(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLEvent[]) } - * @param openGLRenderBuffer Identifier of an OpenGL render buffer + * @param openGLBufferObject Identifier of an OpenGL render buffer */ @SuppressWarnings("deprecation") public CLImage2D createImage2DFromGLRenderBuffer(CLMem.Usage usage, int openGLRenderBuffer) { - #declareReusablePtrsAndPErr() - long mem; + IntByReference pErr = new IntByReference(); + cl_mem mem; int previousAttempts = 0; do { - mem = CL.clCreateFromGLRenderbuffer( - getEntity(), - usage.getIntFlags(), - openGLRenderBuffer, - getPeer(pErr) - ); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); + mem = CL.clCreateFromGLRenderbuffer(getEntity(), usage.getIntFlags(), openGLRenderBuffer, pErr); + } while (failedForLackOfMemory(pErr.getValue(), previousAttempts++)); return markAsGL(new CLImage2D(this, mem, null)); } /** -#documentCallsFunction("clCreateFromGLTexture2D") * Creates an OpenCL 2D image object from an OpenGL 2D texture object, or a single face of an OpenGL cubemap texture object.
    * Note that memory objects shared with OpenGL must be acquired / released before / after use from OpenCL. * @param usage * @param textureTarget Must be one of GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, or GL_TEXTURE_RECTANGLE47. texture_target is used only to define the image type of texture. No reference to a bound GL texture object is made or implied by this parameter. - * @param mipLevel Mipmap level to be used (Implementations may return CL_INVALID_OPERATION for miplevel values > 0) + * @param mipLevel Mipmap level to be used (Implementations may return CL_INVALID_OPERATION for miplevel values > 0) * @param texture Name of a GL 2D, cubemap or rectangle texture object. The texture object must be a complete texture as per OpenGL rules on texture completeness. The texture format and dimensions defined by OpenGL for the specified miplevel of the texture will be used to create the 2D image object. Only GL texture objects with an internal format that maps to appropriate image channel order and data type specified in tables 5.4 and 5.5 may be used to create a 2D image object. * @return valid OpenCL image object if the image object is created successfully * @throws CLException.InvalidMipLevel if miplevel is less than the value of levelbase (for OpenGL implementations) or zero (for OpenGL ES implementations); or greater than the value of q (for both OpenGL and OpenGL ES). levelbase and q are defined for the texture in section 3.8.10 (Texture Completeness) of the OpenGL 2.1 specification and section 3.7.10 of the OpenGL ES 2.0, or if miplevel is greather than zero and the OpenGL implementation does not support creating from non-zero mipmap levels. @@ -475,20 +410,12 @@ public CLImage2D createImage2DFromGLRenderBuffer(CLMem.Usage usage, int openGLRe */ @SuppressWarnings("deprecation") public CLImage2D createImage2DFromGLTexture2D(CLMem.Usage usage, GLTextureTarget textureTarget, int texture, int mipLevel) { - platform.requireMinVersionValue("clCreateFromGLTexture2D", 1.1, 1.2); - #declareReusablePtrsAndPErr() - long mem; + IntByReference pErr = new IntByReference(); + cl_mem mem; int previousAttempts = 0; do { - mem = CL.clCreateFromGLTexture2D( - getEntity(), - usage.getIntFlags(), - (int)textureTarget.value(), - mipLevel, - texture, - getPeer(pErr) - ); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); + mem = CL.clCreateFromGLTexture2D(getEntity(), usage.getIntFlags(), (int)textureTarget.value(), mipLevel, texture, pErr); + } while (failedForLackOfMemory(pErr.getValue(), previousAttempts++)); return markAsGL(new CLImage2D(this, mem, null)); } @@ -508,7 +435,7 @@ public CLPlatform getPlatform() { } - public enum GLTextureTarget implements com.nativelibs4java.util.ValuedEnum { + public enum GLTextureTarget implements ValuedEnum { Texture2D(GL_TEXTURE_2D), //Texture3D(GL_TEXTURE_3D), @@ -528,11 +455,10 @@ public enum GLTextureTarget implements com.nativelibs4java.util.ValuedEnum { } /** -#documentCallsFunction("clCreateFromGLTexture3D") * Creates an OpenCL 3D image object from an OpenGL 3D texture object
    * Note that memory objects shared with OpenGL must be acquired / released before / after use from OpenCL. * @param usage - * @param mipLevel Mipmap level to be used (Implementations may return CL_INVALID_OPERATION for miplevel values > 0) + * @param mipLevel Mipmap level to be used (Implementations may return CL_INVALID_OPERATION for miplevel values > 0) * @param texture Name of a GL 3D texture object. The texture object must be a complete texture as per OpenGL rules on texture completeness. The texture format and dimensions defined by OpenGL for the specified miplevel of the texture will be used to create the 3D image object. Only GL texture objects with an internal format that maps to appropriate image channel order and data type specified in tables 5.4 and 5.5 can be used to create the 3D image object. * @return valid OpenCL image object if the image object is created successfully * @throws CLException.InvalidMipLevel if miplevel is less than the value of levelbase (for OpenGL implementations) or zero (for OpenGL ES implementations); or greater than the value of q (for both OpenGL and OpenGL ES). levelbase and q are defined for the texture in section 3.8.10 (Texture Completeness) of the OpenGL 2.1 specification and section 3.7.10 of the OpenGL ES 2.0, or if miplevel is greather than zero and the OpenGL implementation does not support creating from non-zero mipmap levels. @@ -541,20 +467,12 @@ public enum GLTextureTarget implements com.nativelibs4java.util.ValuedEnum { */ @SuppressWarnings("deprecation") public CLImage3D createImage3DFromGLTexture3D(CLMem.Usage usage, int texture, int mipLevel) { - platform.requireMinVersionValue("clCreateFromGLTexture3D", 1.1, 1.2); - #declareReusablePtrsAndPErr() - long mem; + IntByReference pErr = new IntByReference(); + cl_mem mem; int previousAttempts = 0; do { - mem = CL.clCreateFromGLTexture3D( - getEntity(), - usage.getIntFlags(), - GL_TEXTURE_3D, - mipLevel, - texture, - getPeer(pErr) - ); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); + mem = CL.clCreateFromGLTexture3D(getEntity(), usage.getIntFlags(), GL_TEXTURE_3D, mipLevel, texture, pErr); + } while (failedForLackOfMemory(pErr.getValue(), previousAttempts++)); return markAsGL(new CLImage3D(this, mem, null)); } @@ -574,231 +492,190 @@ public CLImage2D createImage2D(CLMem.Usage usage, Image image, boolean allowUnop true); } - /** -#documentCreateImage2D() -#documentRowPitch() -#documentCopiableImageBuffer() - */ @SuppressWarnings("deprecation") public CLImage2D createImage2D(CLMem.Usage usage, CLImageFormat format, long width, long height, long rowPitch, Buffer buffer, boolean copy) { - platform.requireMinVersionValue("clCreateImage2D", 1.1, 1.2); - long memFlags = usage.getIntFlags(); if (buffer != null) { memFlags |= copy ? CL_MEM_COPY_HOST_PTR : CL_MEM_USE_HOST_PTR; } - #declareReusablePtrsAndPErr() - Pointer pImageFormat = getPointer(format.to_cl_image_format()); - Pointer pBuffer = buffer == null ? null : pointerToBuffer(buffer); - long mem; + IntByReference pErr = new IntByReference(); + cl_mem mem; int previousAttempts = 0; do { mem = CL.clCreateImage2D( getEntity(), memFlags, - getPeer(pImageFormat), - width, - height, - rowPitch, - getPeer(pBuffer), - getPeer(pErr)); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); + format.to_cl_image_format(), + toNS(width), + toNS(height), + toNS(rowPitch), + buffer == null ? null : Native.getDirectBufferPointer(buffer), + pErr); + } while (failedForLackOfMemory(pErr.getValue(), previousAttempts++)); return new CLImage2D(this, mem, format); } - /** -#documentCreateImage2D() -#documentRowPitch() - */ - public CLImage2D createImage2D(CLMem.Usage usage, CLImageFormat format, long width, long height, long rowPitch) { + public CLImage2D createImage2D(CLMem.Usage usage, CLImageFormat format, long width, long height, long rowPitch) { return createImage2D(usage, format, width, height, rowPitch, null, false); } - /** -#documentCreateImage2D() - */ - public CLImage2D createImage2D(CLMem.Usage usage, CLImageFormat format, long width, long height) { + public CLImage2D createImage2D(CLMem.Usage usage, CLImageFormat format, long width, long height) { return createImage2D(usage, format, width, height, 0, null, false); } - /** -#documentCreateImage3D() -#documentRowPitch() -#documentSlicePitch() -#documentCopiableImageBuffer() - */ - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") public CLImage3D createImage3D(CLMem.Usage usage, CLImageFormat format, long width, long height, long depth, long rowPitch, long slicePitch, Buffer buffer, boolean copy) { - platform.requireMinVersionValue("clCreateImage3D", 1.1, 1.2); long memFlags = usage.getIntFlags(); if (buffer != null) { memFlags |= copy ? CL_MEM_COPY_HOST_PTR : CL_MEM_USE_HOST_PTR; } - #declareReusablePtrsAndPErr() - Pointer pImageFormat = getPointer(format.to_cl_image_format()); - Pointer pBuffer = buffer == null ? null : pointerToBuffer(buffer); - long mem; + IntByReference pErr = new IntByReference(); + cl_mem mem; int previousAttempts = 0; do { mem = CL.clCreateImage3D( getEntity(), memFlags, - getPeer(pImageFormat), - width, - height, - depth, - rowPitch, - slicePitch, - getPeer(pBuffer), - getPeer(pErr)); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); + format.to_cl_image_format(), + toNS(width), + toNS(height), + toNS(depth), + toNS(rowPitch), + toNS(slicePitch), + buffer == null ? null : Native.getDirectBufferPointer(buffer), + pErr); + } while (failedForLackOfMemory(pErr.getValue(), previousAttempts++)); + return new CLImage3D(this, mem, format); } - /** -#documentCreateImage3D() -#documentRowPitch() -#documentSlicePitch() - */ - public CLImage3D createImage3D(CLMem.Usage usage, CLImageFormat format, long width, long height, long depth, long rowPitch, long slicePitch) { + public CLImage3D createImage3D(CLMem.Usage usage, CLImageFormat format, long width, long height, long depth, long rowPitch, long slicePitch) { return createImage3D(usage, format, width, height, depth, rowPitch, slicePitch, null, false); } - /** -#documentCreateImage3D() - */ - public CLImage3D createImage3D(CLMem.Usage usage, CLImageFormat format, long width, long height, long depth) { + public CLImage3D createImage3D(CLMem.Usage usage, CLImageFormat format, long width, long height, long depth) { return createImage3D(usage, format, width, height, depth, 0, 0, null, false); } #foreach ($prim in $primitivesNoBool) -#docCreateBufferCopy("CLBuffer<${prim.WrapperName}>", "") - public CLBuffer<${prim.WrapperName}> create${prim.BufferName}(CLMem.Usage usage, #if ($prim.Name == "byte") Buffer #else ${prim.BufferName} #end data, boolean copy) { +#docCreateBufferCopy("CLBuffer<${prim.WrapperName}>", " (of concrete type {@link com.nativelibs4java.opencl.CL${prim.BufferName}}) ") + public > B create${prim.BufferName}(CLMem.Usage kind, #if ($prim.Name == "byte") Buffer #else ${prim.BufferName} #end data, boolean copy) { + if (!data.isDirect()) { + if (!copy) + throw new IllegalArgumentException("Cannot create an OpenCL buffer object out of a non-direct NIO buffer without copy."); + if (kind == CLMem.Usage.Output) + throw new IllegalArgumentException("Output NIO buffers must be direct."); + data = NIOUtils.directCopy(data, getKernelsDefaultByteOrder()); + } + CLBuffer ret = createBuffer(data, -1, kind.getIntFlags() | (copy ? CL_MEM_COPY_HOST_PTR : CL_MEM_USE_HOST_PTR), copy); #if ($prim.Name == "byte") - return createBuffer(usage, Pointer.pointerToBuffer(data).as(Byte.class), copy); + return (B)ret; #else - return createBuffer(usage, Pointer.pointerTo${prim.CapName}s(data), copy); + return (B)ret.asCL${prim.BufferName}(); #end } -#docCreateBufferPointer("CLBuffer<${prim.WrapperName}>", "") - public CLBuffer<${prim.WrapperName}> create${prim.BufferName}(CLMem.Usage usage, Pointer<${prim.WrapperName}> data) { - return create${prim.BufferName}(usage, data, true); - } -#docCreateBufferCopy("CLBuffer<${prim.WrapperName}>", "") - public CLBuffer<${prim.WrapperName}> create${prim.BufferName}(CLMem.Usage usage, Pointer<${prim.WrapperName}> data, boolean copy) { - return createBuffer(usage, data, copy); - } - #docCreateBufferPrim("CLBuffer<${prim.WrapperName}>", $prim) - public CLBuffer<${prim.WrapperName}> create${prim.BufferName}(CLMem.Usage usage, long elementCount) { - return createBuffer(usage, ${prim.WrapperName}.class, elementCount); + public > B create${prim.BufferName}(CLMem.Usage kind, long elementCount) { +#if ($prim.Name == "byte") + return (B)createBuffer(null, elementCount, kind.getIntFlags(), false); +#else + return (B)createByteBuffer(kind, elementCount * ${prim.Size}).asCL${prim.BufferName}(); +#end } - + #end /** -#documentCallsFunction("clCreateBuffer") * Create an OpenCL buffer with the provided initial values, in copy mode (see CL_MEM_COPY_HOST_PTR). - * @param usage Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. - * @param data Pointer to the initial values, must have known bounds (see {@link Pointer#getValidElements()}) + * @param kind Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. + * @param data Buffer that contains the initial values. Indirect buffers should be avoided for performance reasons. */ - public CLBuffer createBuffer(CLMem.Usage usage, Pointer data) { - return createBuffer(usage, data, true); + public CLBuffer createBuffer(CLMem.Usage kind, Buffer data) { + return createBuffer(kind, data, true); } #docCreateBufferCopy("CLBuffer<N>", "") - public CLBuffer createBuffer(CLMem.Usage usage, Pointer data, boolean copy) { - return createBuffer(data.getIO(), data, data.getValidBytes(), usage.getIntFlags() | (copy ? CL_MEM_COPY_HOST_PTR : CL_MEM_USE_HOST_PTR), copy); + @SuppressWarnings("unchecked") + public CLBuffer createBuffer(CLMem.Usage kind, Buffer data, boolean copy) { + Class bufferClass = data.getClass(); + #foreach ($prim in $primitivesNoBool) + if (${prim.BufferName}.class.isAssignableFrom(bufferClass)) + return (CLBuffer)create${prim.BufferName}(kind, (${prim.BufferName})data, copy); + #end + + throw new UnsupportedOperationException("Cannot create OpenCL buffers of Java type " + bufferClass.getName()); } #docCreateBuffer("CLBuffer<N>", "T", "* @param elementClass Primitive type of the buffer. For instance a buffer of 'int' values can be created with elementClass being Integer.class or int.class indifferently.", "") - public CLBuffer createBuffer(CLMem.Usage usage, Class elementClass, long elementCount) { - PointerIO io = PointerIO.getInstance(elementClass); - if (io == null) - throw new IllegalArgumentException("Unknown target type : " + elementClass.getName()); - return createBuffer(usage, io, elementCount); - } + @SuppressWarnings("unchecked") + public CLBuffer createBuffer(CLMem.Usage kind, Class elementClass, long elementCount) { + #foreach ($prim in $primitivesNoBool) + if (${prim.WrapperName}.class.isAssignableFrom(elementClass)) + return (CLBuffer)create${prim.BufferName}(kind, elementCount); + #end - /** -#documentCallsFunction("clCreateBuffer") - * Create an OpenCL buffer big enough to hold the provided amount of values of the specified type. - * @param usage Usage intended for the pointer in OpenCL kernels : a pointer created with {@link CLMem.Usage#Input} cannot be written to in a kernel. - * @param io Delegate responsible for reading and writing values. - * @param elementCount Length of the buffer expressed in elements (for instance, a CLBuffer<Integer> of length 4 will actually contain 4 * 4 bytes, as ints are 4-bytes-long) - * @deprecated Intended for advanced uses in conjunction with BridJ. - */ - @Deprecated - public CLBuffer createBuffer(CLMem.Usage usage, PointerIO io, long elementCount) { - return createBuffer(io, null, io.getTargetSize() * elementCount, usage.getIntFlags(), false); + throw new UnsupportedOperationException("Cannot create OpenCL buffers of Java primitive type " + elementClass.getName()); } - /** -#documentCallsFunction("clCreateBuffer") - */ @SuppressWarnings("deprecation") - private CLBuffer createBuffer(PointerIO io, Pointer data, long byteCount, final int CLBufferFlags, final boolean retainBufferReference) { - if (byteCount <= 0) + private CLByteBuffer createBuffer(final Buffer buffer, long byteCount, final int CLBufferFlags, final boolean retainBufferReference) { + if (buffer != null) { + byteCount = getSizeInBytes(buffer); + } else if (retainBufferReference) { + throw new IllegalArgumentException("Cannot retain reference to null pointer !"); + } + + if (byteCount <= 0) { throw new IllegalArgumentException("Buffer size must be greater than zero (asked for size " + byteCount + ")"); - - if (byteCount > getMaxMemAllocSize()) - throw new OutOfMemoryError("Requested size for buffer allocation is more than the maximum for this context : " + byteCount + " > " + getMaxMemAllocSize()); + } - if (data != null) { + if (buffer != null) { ByteOrder contextOrder = getByteOrder(); - ByteOrder dataOrder = data.order(); - if (contextOrder != null && !dataOrder.equals(contextOrder) && data.getTargetSize() > 1) - throw new IllegalArgumentException("Byte order of this context is " + contextOrder + ", but was given pointer to data with order " + dataOrder + ". Please create a pointer with correct byte order (Pointer.order(CLContext.getByteOrder()))."); - } + ByteOrder dataOrder = NIOUtils.getByteOrder(buffer); + if (contextOrder != null && !dataOrder.equals(contextOrder)) + throw new IllegalArgumentException("Byte order of this context is " + contextOrder + ", but was given pointer to data with order " + dataOrder + ". Please create a buffer with correct byte order (XyzBuffer.order(CLContext.getKernelsDefaultByteOrder()))."); + } - #declareReusablePtrsAndPErr() - long mem; + IntByReference pErr = new IntByReference(); + //IntBuffer errBuff = IntBuffer.wrap(new int[1]); + cl_mem mem; int previousAttempts = 0; do { mem = CL.clCreateBuffer( getEntity(), CLBufferFlags, - byteCount, - getPeer(data), - getPeer(pErr)); - } while (failedForLackOfMemory(pErr.getInt(), previousAttempts++)); - return new CLBuffer(this, byteCount, mem, retainBufferReference ? data : null, io); + toNS(byteCount), + buffer == null ? null : Native.getDirectBufferPointer(buffer), + pErr); + } while (failedForLackOfMemory(pErr.getValue(), previousAttempts++)); + + return new CLByteBuffer(this, byteCount, mem, buffer); } + /** + * @deprecated Use {@link CLContext#getByteOrder()} + */ + @Deprecated public ByteOrder getKernelsDefaultByteOrder() { - if (kernelsDefaultByteOrder == null) { - ByteOrder order = null; - for (CLDevice device : getDevices()) { - ByteOrder devOrder = device.getKernelsDefaultByteOrder(); - if (order != null && devOrder != order) - return null; - order = devOrder; - } - kernelsDefaultByteOrder = order; - } - return kernelsDefaultByteOrder; + return getByteOrder(); } - private volatile ByteOrder byteOrder, kernelsDefaultByteOrder; - /** * Get the endianness common to all devices of this context, or null if the devices have mismatching endiannesses. */ public ByteOrder getByteOrder() { - if (byteOrder == null) { - ByteOrder order = null; - for (CLDevice device : getDevices()) { - ByteOrder devOrder = device.getByteOrder(); - if (order != null && devOrder != order) - return null; - order = devOrder; - } - byteOrder = order; - } - return byteOrder; + ByteOrder order = null; + for (CLDevice device : getDevices()) { + ByteOrder devOrder = device.getByteOrder(); + if (order != null && devOrder != order) + return null; + order = devOrder; + } + return order; } private volatile int addressBits = -2; @@ -826,57 +703,28 @@ public int getAddressBits() { return addressBits; } - private volatile Boolean doubleSupported; - - /** + /** * Whether all the devices in this context support any double-precision numbers (see {@link CLDevice#isDoubleSupported()}). */ public boolean isDoubleSupported() { - if (doubleSupported == null) { - boolean supported = true; - for (CLDevice device : getDevices()) { - if (!device.isDoubleSupported()) { - supported = false; - break; - } - } - doubleSupported = supported; - } - return doubleSupported; + for (CLDevice device : getDevices()) + if (!device.isDoubleSupported()) + return false; + return true; } - - private volatile Boolean halfSupported; - - /** + /** * Whether all the devices in this context support half-precision numbers (see {@link CLDevice#isHalfSupported()}). */ public boolean isHalfSupported() { - if (halfSupported == null) { - boolean supported = true; - for (CLDevice device : getDevices()) { - if (!device.isHalfSupported()) { - supported = false; - break; - } - } - halfSupported = supported; - } - return halfSupported; - } - - private volatile Boolean byteAddressableStoreSupported; - - public boolean isByteAddressableStoreSupported() { - if (byteAddressableStoreSupported == null) { - boolean supported = true; - for (CLDevice device : getDevices()) { - if (!device.isByteAddressableStoreSupported()) { - supported = false; - break; - } - } - byteAddressableStoreSupported = supported; - } - return byteAddressableStoreSupported; + for (CLDevice device : getDevices()) + if (!device.isHalfSupported()) + return false; + return true; + } + public boolean isByteAddressableStoreSupported() { + for (CLDevice device : getDevices()) + if (!device.isByteAddressableStoreSupported()) + return false; + return true; } } diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage.java deleted file mode 100644 index 28c55b97..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage.java +++ /dev/null @@ -1,259 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import static com.nativelibs4java.opencl.CLException.error; -import static com.nativelibs4java.opencl.JavaCL.CL; -import static com.nativelibs4java.opencl.JavaCL.check; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_FALSE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_ELEMENT_SIZE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_FORMAT; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_TRUE; -import static com.nativelibs4java.util.NIOUtils.directCopy; - -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.IntBuffer; - -import com.nativelibs4java.opencl.library.cl_image_format; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import com.nativelibs4java.util.NIOUtils; - -import com.nativelibs4java.util.Pair; -import org.bridj.*; -import static org.bridj.Pointer.*; - - -/** - * OpenCL Image Memory Object.
    - * An image object is used to store a two- or three- dimensional texture, frame-buffer or image
    - * An image object is used to represent a buffer that can be used as a texture or a frame-buffer. The elements of an image object are selected from a list of predefined image formats. - * @author Oliveir Chafik - */ -public abstract class CLImage extends CLMem { - - CLImageFormat format; - CLImage(CLContext context, long entityPeer, CLImageFormat format) { - super(context, -1, entityPeer); - this.format = format; - } - - protected abstract long[] getDimensions(); - - /** - * Return image format descriptor specified when image is created with CLContext.create{Input|Output|InputOutput}{2D|3D}. - */ - @InfoName("CL_IMAGE_FORMAT") - public CLImageFormat getFormat() { - if (format == null) { - format = new CLImageFormat(new cl_image_format(infos.getMemory(getEntity(), CL_IMAGE_FORMAT))); - } - return format; - } - - /** - * Return size of each element of the image memory object given by image.
    - * An element is made up of n channels. The value of n is given in cl_image_format descriptor. - */ - @InfoName("CL_IMAGE_ELEMENT_SIZE") - public long getElementSize() { - return infos.getIntOrLong(getEntity(), CL_IMAGE_ELEMENT_SIZE); - } - - /** -#documentCallsFunction("clEnqueueReadImage") - */ - protected CLEvent read(CLQueue queue, Pointer origin, Pointer region, long rowPitch, long slicePitch, Buffer out, boolean blocking, CLEvent... eventsToWaitFor) { - return read(queue, origin, region, rowPitch, slicePitch, pointerToBuffer(out), blocking, eventsToWaitFor); - } - /** -#documentCallsFunction("clEnqueueReadImage") - */ - protected CLEvent read(CLQueue queue, Pointer origin, Pointer region, long rowPitch, long slicePitch, Pointer out, boolean blocking, CLEvent... eventsToWaitFor) { - /*if (!out.isDirect()) { - - }*/ - #declareReusablePtrsAndEventsInOutBlockable() - error(CL.clEnqueueReadImage( - queue.getEntity(), - getEntity(), - blocking ? CL_TRUE : CL_FALSE, - getPeer(origin), - getPeer(region), - rowPitch, - slicePitch, - getPeer(out), - #eventsInOutArgsRaw() - )); - #returnEventOut("queue") - } - - /** -#documentCallsFunction("clEnqueueWriteImage") - */ - protected CLEvent write(CLQueue queue, Pointer origin, Pointer region, long rowPitch, long slicePitch, Buffer in, boolean blocking, CLEvent... eventsToWaitFor) { - return write(queue, origin, region, rowPitch, slicePitch, pointerToBuffer(in), blocking, eventsToWaitFor); - } - /** -#documentCallsFunction("clEnqueueWriteImage") - */ - protected CLEvent write(CLQueue queue, Pointer origin, Pointer region, long rowPitch, long slicePitch, Pointer in, boolean blocking, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOutBlockable() - error(CL.clEnqueueWriteImage( - queue.getEntity(), - getEntity(), - blocking ? CL_TRUE : CL_FALSE, - getPeer(origin), - getPeer(region), - rowPitch, - slicePitch, - getPeer(in), - #eventsInOutArgsRaw() - )); - CLEvent evt = #eventOutWrapper("queue"); - - if (!blocking) { - final Pointer toHold = in; - evt.invokeUponCompletion(new Runnable() { - public void run() { - // Make sure the GC held a reference to directData until the write was completed ! - toHold.order(); - } - }); - } - - return evt; - } - - /** -#documentCallsFunction("clEnqueueFillImage") - * @param queue - * @param queue Queue on which to enqueue this fill buffer command. - * @param color Color components to fill the buffer with. -#documentEventsToWaitForAndReturn() - */ - public CLEvent fillImage(CLQueue queue, Object color, CLEvent... eventsToWaitFor) { - long[] region = getDimensions(); - long[] origin = new long[region.length]; - return fillImage(queue, color, origin, region, eventsToWaitFor); - } - - /** -#documentCallsFunction("clEnqueueFillImage") - * @param queue - * @param queue Queue on which to enqueue this fill buffer command. - * @param color Color components to fill the buffer with. - * @param origin Origin point. - * @param region Size of the region to fill. -#documentEventsToWaitForAndReturn() - */ - public CLEvent fillImage(CLQueue queue, Object color, long[] origin, long[] region, CLEvent... eventsToWaitFor) { - context.getPlatform().requireMinVersionValue("clEnqueueFillImage", 1.2); - Pointer pColor; - if (color instanceof int[]) { - pColor = pointerToInts((int[]) color); - } else if (color instanceof float[]) { - pColor = pointerToFloats((float[]) color); - } else { - throw new IllegalArgumentException("Color should be an int[] or a float[] with 4 elements."); - } - check(pColor.getValidElements() == 4, "Color should have 4 elements."); - - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueFillImage( - queue.getEntity(), - getEntity(), - getPeer(pColor), - getPeer(writeOrigin(origin, ptrs.sizeT3_1)), - getPeer(writeRegion(region, ptrs.sizeT3_2)), - #eventsInOutArgsRaw() - )); - #returnEventOut("queue") - } - - // clEnqueueFillImage ( cl_command_queue command_queue, - // cl_mem image, - // const void *fill_color, - // const size_t *origin, - // const size_t *region, - // cl_uint num_events_in_wait_list, - // const cl_event *event_wait_list, - // cl_event *event) - - protected Pair map(CLQueue queue, MapFlags flags, - Pointer offset3, Pointer length3, - Long imageRowPitch, - Long imageSlicePitch, - boolean blocking, CLEvent... eventsToWaitFor) - { - if (flags == MapFlags.WriteInvalidateRegion) { - context.getPlatform().requireMinVersionValue("CL_MAP_WRITE_INVALIDATE_REGION", 1.2); - } - #declareReusablePtrsAndEventsInOutBlockable() - #declarePErr() - long mappedPeer = CL.clEnqueueMapImage( - queue.getEntity(), - getEntity(), - blocking ? CL_TRUE : CL_FALSE, - flags.value(), - getPeer(offset3), - getPeer(length3), - imageRowPitch == null ? 0 : getPeer(ptrs.sizeT3_1.pointerToSizeTs((long)imageRowPitch)), - imageSlicePitch == null ? 0 : getPeer(ptrs.sizeT3_2.pointerToSizeTs((long)imageSlicePitch)), - #eventsInOutArgsRaw(), - getPeer(pErr) - ); - #checkPErr() - return new Pair( - pointerToAddress(mappedPeer).getByteBuffer(getByteCount()), - #eventOutWrapper("queue") - ); - } - - /** -#documentCallsFunction("clEnqueueUnmapMemObject") - * see {@link CLImage2D#map(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLMem.MapFlags, com.nativelibs4java.opencl.CLEvent[]) } - * see {@link CLImage3D#map(com.nativelibs4java.opencl.CLQueue, com.nativelibs4java.opencl.CLMem.MapFlags, com.nativelibs4java.opencl.CLEvent[]) } - * @param queue - * @param buffer -#documentEventsToWaitForAndReturn() - */ - public CLEvent unmap(CLQueue queue, ByteBuffer buffer, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOut() - Pointer pBuffer = pointerToBuffer(buffer); - error(CL.clEnqueueUnmapMemObject(queue.getEntity(), getEntity(), getPeer(pBuffer), #eventsInOutArgsRaw())); - #returnEventOut("queue") - } - - protected abstract Pointer writeOrigin(long[] origin, ReusablePointer out); - protected abstract Pointer writeRegion(long[] region, ReusablePointer out); - - /** -#documentCallsFunction("clEnqueueCopyImage") - * @param queue -#documentEventsToWaitForAndReturn() - */ - public CLEvent copyTo(CLQueue queue, CLImage destination, CLEvent... eventsToWaitFor) { - long[] region = getDimensions(); - long[] origin = new long[region.length]; - return copyTo(queue, destination, origin, origin, region, eventsToWaitFor); - } - - /** -#documentCallsFunction("clEnqueueCopyImage") - * @param queue -#documentEventsToWaitForAndReturn() - */ - public CLEvent copyTo(CLQueue queue, CLImage destination, long[] sourceOrigin, long[] destinationOrigin, long[] region, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueCopyImage( - queue.getEntity(), - getEntity(), - destination.getEntity(), - getPeer(writeOrigin(sourceOrigin, ptrs.sizeT3_1)), - getPeer(writeOrigin(destinationOrigin, ptrs.sizeT3_2)), - getPeer(writeRegion(region, ptrs.sizeT3_3)), - #eventsInOutArgsRaw())); - #returnEventOut("queue") - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage3D.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage3D.java deleted file mode 100644 index a3cea076..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLImage3D.java +++ /dev/null @@ -1,95 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_DEPTH; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_SLICE_PITCH; - -import java.nio.Buffer; -import java.nio.ByteBuffer; - -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import com.nativelibs4java.util.Pair; -import org.bridj.Pointer; - -import static org.bridj.Pointer.*; -import org.bridj.SizeT; -/** - * OpenCL 3D Image Memory Object
    - * see {@link CLContext#createImage3D(com.nativelibs4java.opencl.CLMem.Usage, com.nativelibs4java.opencl.CLImageFormat, long, long, long) } - * see {@link CLContext#createImage3D(com.nativelibs4java.opencl.CLMem.Usage, com.nativelibs4java.opencl.CLImageFormat, long, long, long, long, long) } - * see {@link CLContext#createImage3D(com.nativelibs4java.opencl.CLMem.Usage, com.nativelibs4java.opencl.CLImageFormat, long, long, long, long, long, java.nio.Buffer, boolean) } - * see {@link CLContext#createImage3DFromGLTexture3D(com.nativelibs4java.opencl.CLMem.Usage, int, int) } - * @author Olivier Chafik - */ -public class CLImage3D extends CLImage2D { - CLImage3D(CLContext context, long entityPeer, CLImageFormat format) { - super(context, entityPeer, format); - } - - /** - * Return size in bytes of a 2D slice for this 3D image object.
    - */ - @InfoName("CL_IMAGE_SLICE_PITCH") - public long getSlicePitch() { - return infos.getIntOrLong(getEntity(), CL_IMAGE_SLICE_PITCH); - } - - /** - * Return depth of the image in pixels. - */ - @InfoName("CL_IMAGE_DEPTH") - public long getDepth() { - return infos.getIntOrLong(getEntity(), CL_IMAGE_DEPTH); - } - - @Override - protected long[] getDimensions() { - return new long[] { getWidth(), getHeight(), getDepth() }; - } - - @Override - protected Pointer writeOrigin(long[] origin, ReusablePointer out) { - assert(origin.length == 3); - return out.pointerToSizeTs(origin); - } - - @Override - protected Pointer writeRegion(long[] region, ReusablePointer out) { - assert(region.length == 3); - return out.pointerToSizeTs(region); - } - - /** -#documentEventsToWaitForAndReturn() - */ - public CLEvent read(CLQueue queue, long minX, long minY, long minZ, long width, long height, long depth, long rowPitch, long slicePitch, Buffer out, boolean blocking, CLEvent... eventsToWaitFor) { - return read(queue, pointerToSizeTs(minX, minY, minZ), pointerToSizeTs(width, height, depth), rowPitch, slicePitch, out, blocking, eventsToWaitFor); - } - - /** -#documentEventsToWaitForAndReturn() - */ - public CLEvent write(CLQueue queue, long minX, long minY, long minZ, long width, long height, long depth, long rowPitch, long slicePitch, Buffer in, boolean blocking, CLEvent... eventsToWaitFor) { - return write(queue, pointerToSizeTs(minX, minY, minZ), pointerToSizeTs(width, height, depth), rowPitch, slicePitch, in, blocking, eventsToWaitFor); - } - - public ByteBuffer map(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) { - return map(queue, flags, 0, 0, 0, getWidth(), getHeight(), getDepth(), getWidth(), getHeight(), true, eventsToWaitFor); - } - /** -#documentEventsToWaitForAndPairReturn("mapped data") - */ - public Pair mapLater(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) { - return map(queue, flags, pointerToSizeTs(0, 0, 0), pointerToSizeTs(getWidth(), getHeight(), getDepth()), getWidth(), getHeight(), true, eventsToWaitFor); - } - - public ByteBuffer map(CLQueue queue, MapFlags flags, long offsetX, long offsetY, long offsetZ, long lengthX, long lengthY, long lengthZ, long rowPitch, long slicePitch, boolean blocking, CLEvent... eventsToWaitFor) { - return map(queue, flags, pointerToSizeTs(offsetX, offsetY, offsetZ), pointerToSizeTs(lengthX, lengthY, lengthZ), rowPitch, slicePitch, true, eventsToWaitFor).getFirst(); - } - /** -#documentEventsToWaitForAndPairReturn("mapped data") - */ - public Pair mapLater(CLQueue queue, MapFlags flags, long offsetX, long offsetY, long offsetZ, long lengthX, long lengthY, long lengthZ, long rowPitch, long slicePitch, CLEvent... eventsToWaitFor) { - return map(queue, flags, pointerToSizeTs(offsetX, offsetY, offsetZ), pointerToSizeTs(lengthX, lengthY, lengthZ), rowPitch, slicePitch, true, eventsToWaitFor); - } - -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLInfoGetter.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLInfoGetter.java deleted file mode 100644 index 742296b5..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLInfoGetter.java +++ /dev/null @@ -1,125 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; - -import static com.nativelibs4java.opencl.CLException.error; - -import org.bridj.*; -import static org.bridj.Pointer.*; - -import org.bridj.ann.Ptr; - -/** - * - * @author ochafik - */ -abstract class CLInfoGetter { - - protected abstract int getInfo(long entity, int infoTypeEnum, long size, Pointer out, Pointer sizeOut); - - public String getString(@Ptr long entity, int infoName) { - #declareReusablePtrs() - Pointer pLen = ptrs.sizeT1; - error(getInfo(entity, infoName, 0, null, pLen)); - - long len = pLen.getSizeT(); - if (len == 0) { - return ""; - } - Pointer buffer = allocateBytes(len + 1); - error(getInfo(entity, infoName, len, buffer, null)); - String s = buffer.getCString(); - buffer.release(); - return s; - } - - public Pointer getPointer(@Ptr long entity, int infoName) { - #declareReusablePtrs() - Pointer pLen = ptrs.sizeT1; - Pointer> mem = ptrs.ptr1; - error(getInfo(entity, infoName, Pointer.SIZE, mem, pLen)); - if (pLen.getSizeT() != Pointer.SIZE) { - throw new RuntimeException("Not a pointer : len = " + pLen.get()); - } - return mem.get(); - } - - public Pointer getMemory(@Ptr long entity, int infoName) { - #declareReusablePtrs() - Pointer pLen = ptrs.sizeT1; - error(getInfo(entity, infoName, 0, null, pLen)); - - int len = (int)pLen.getSizeT(); - Pointer buffer = allocateBytes(len); - error(getInfo(entity, infoName, len, buffer, null)); - - return buffer; - } - - public long[] getNativeSizes(@Ptr long entity, int infoName, int n) { - long nBytes = SizeT.SIZE * n; - #declareReusablePtrs() - Pointer pLen = ptrs.sizeT3_1.pointerToSizeTs(nBytes); - Pointer mem = ptrs.sizeT3_2.allocatedSizeTs(n); - error(getInfo(entity, infoName, nBytes, mem, pLen)); - - int actualLen = (int)pLen.getSizeT(); - if (actualLen != nBytes) { - throw new RuntimeException("Not a Size[" + n + "] : len = " + actualLen); - } - return mem.getSizeTs(n); - } - - public int getOptionalFeatureInt(@Ptr long entity, int infoName) { - try { - return getInt(entity, infoName); - } catch (CLException.InvalidValue ex) { - throw new UnsupportedOperationException("Cannot get value " + infoName, ex); - } catch (CLException.InvalidOperation ex) { - throw new UnsupportedOperationException("Cannot get value " + infoName, ex); - } - } - public int getInt(@Ptr long entity, int infoName) { - return (int)getIntOrLong(entity, infoName); - } - - public boolean getBool(@Ptr long entity, int infoName) { - #declareReusablePtrs() - Pointer pLen = ptrs.sizeT1; - Pointer mem = ptrs.sizeT3_1.allocatedBytes(8); - error(getInfo(entity, infoName, 8, mem, pLen)); - - long len = pLen.getSizeT(); - switch ((int)len) { - case 1: - return mem.getByte() != 0; - case 2: - return mem.getShort() != 0; - case 4: - return mem.getInt() != 0; - case 8: - return mem.getLong() != 0; - case 0: - // HACK to accommodate ATI Stream on Linux 32 bits (CLPlatform.isAvailable()) - //if (JNI.isLinux()) - return true; - default: - throw new RuntimeException("Not a BOOL : len = " + len); - } - } - - public long getIntOrLong(@Ptr long entity, int infoName) { - #declareReusablePtrs() - Pointer pLen = ptrs.sizeT1; - Pointer mem = ptrs.long1; - error(getInfo(entity, infoName, 8, mem, pLen)); - - switch ((int)pLen.getSizeT()) { - case 4: - return mem.getInt(); - case 8: - return mem.getLong(); - default: - throw new RuntimeException("Not a native long : len = " + pLen.get()); - } - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLQueue.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLQueue.java deleted file mode 100644 index 4f61f45b..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLQueue.java +++ /dev/null @@ -1,265 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import static com.nativelibs4java.opencl.CLException.error; -import static com.nativelibs4java.opencl.JavaCL.CL; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_FALSE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_QUEUE_PROPERTIES; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_TRUE; - -import java.util.EnumSet; - -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_command_queue; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import org.bridj.*; -import static org.bridj.Pointer.*; - -/** - * OpenCL command queue.
    - * OpenCL objects such as memory, program and kernel objects are created using a context.
    - * Operations on these objects are performed using a command-queue.
    - * The command-queue can be used to queue a set of operations (referred to as commands) in order.
    - * Having multiple command-queues allows applications to queue multiple independent commands without requiring synchronization.
    - * Note that this should work as long as these objects are not being shared.
    - * Sharing of objects across multiple command-queues will require the application to perform appropriate synchronization.
    - *
    - * A queue is bound to a single device. - * see {@link CLDevice#createQueue(com.nativelibs4java.opencl.CLContext, com.nativelibs4java.opencl.CLDevice.QueueProperties[]) } - * see {@link CLDevice#createOutOfOrderQueue(com.nativelibs4java.opencl.CLContext) } - * see {@link CLDevice#createProfilingQueue(com.nativelibs4java.opencl.CLContext) } - * see {@link CLContext#createDefaultQueue(com.nativelibs4java.opencl.CLDevice.QueueProperties[]) } - * see {@link CLContext#createDefaultOutOfOrderQueue() } - * see {@link CLContext#createDefaultProfilingQueue() } - * @author Olivier Chafik - * - */ -public class CLQueue extends CLAbstractEntity { - - #declareInfosGetter("infos", "CL.clGetCommandQueueInfo") - - final CLContext context; - final CLDevice device; - - CLQueue(CLContext context, long entity, CLDevice device) { - super(entity); - this.context = context; - this.device = device; - } - - public CLContext getContext() { - return context; - } - public CLDevice getDevice() { - return device; - } - - volatile Boolean outOfOrder; - public synchronized boolean isOutOfOrder() { - if (outOfOrder == null) - outOfOrder = getProperties().contains(CLDevice.QueueProperties.OutOfOrderExecModeEnable); - return outOfOrder; - } - - @InfoName("CL_QUEUE_PROPERTIES") - public EnumSet getProperties() { - return CLDevice.QueueProperties.getEnumSet(infos.getIntOrLong(getEntity(), CL_QUEUE_PROPERTIES)); - } - - @SuppressWarnings("deprecation") - public void setProperty(CLDevice.QueueProperties property, boolean enabled) { - context.getPlatform().requireMinVersionValue("clSetCommandQueueProperty", 1.0, 1.1); - error(CL.clSetCommandQueueProperty(getEntity(), property.value(), enabled ? CL_TRUE : CL_FALSE, 0)); - } - - - @Override - protected void clear() { - error(CL.clReleaseCommandQueue(getEntity())); - } - - /** -#documentCallsFunction("clFinish") - * Blocks until all previously queued OpenCL commands in this queue are issued to the associated device and have completed.
    - * finish() does not return until all queued commands in this queue have been processed and completed.
    - * finish() is also a synchronization point. - */ - public void finish() { - error(CL.clFinish(getEntity())); - } - - /** -#documentCallsFunction("clFlush") - * Issues all previously queued OpenCL commands in this queue to the device associated with this queue.
    - * flush() only guarantees that all queued commands in this queue get issued to the appropriate device.
    - * There is no guarantee that they will be complete after flush() returns. - */ - public void flush() { - error(CL.clFlush(getEntity())); - } - - /** -#documentCallsFunction("clEnqueueWaitForEvents") - * Enqueues a wait for a specific event or a list of events to complete before any future commands queued in the this queue are executed. - */ - public void enqueueWaitForEvents(CLEvent... eventsToWaitFor) { - context.getPlatform().requireMinVersionValue("clEnqueueWaitForEvents", 1.1, 1.2); - #declareReusablePtrs() - #declareEventsIn() - if (eventsIn == null) - return; - error(CL.clEnqueueWaitForEvents(getEntity(), #eventsInArgsRaw())); - } - - - /** -#documentCallsFunction("clEnqueueMigrateMemObjects") - * Enqueues a command to indicate which device a set of memory objects should be associated with. - */ - public CLEvent enqueueMigrateMemObjects(CLMem[] memObjects, EnumSet flags, CLEvent... eventsToWaitFor) { - context.getPlatform().requireMinVersionValue("clEnqueueMigrateMemObjects", 1.2); - #declareReusablePtrsAndEventsInOut() - int[] n = ptrs.int1Array; - Pointer pMems = pointerToEntities(memObjects, n); - error(CL.clEnqueueMigrateMemObjects( - getEntity(), - n[0], - getPeer(pMems), - CLMem.Migration.getValue(flags), - #eventsInOutArgsRaw() - )); - #returnEventOut("this") - } - - // - public interface NativeKernel { - void execute(Pointer[] bufferPointers); - } - - private static Pointer pointerToEntities(CLAbstractEntity[] entities, int[] n) { - int nn = 0; - Pointer pEntities = allocateSizeTs(entities.length); - for (CLAbstractEntity entity : entities) { - if (entity != null) { - pEntities.setSizeTAtIndex(nn++, entity.getEntity()); - } - } - n[0] = nn; - return pEntities; - } - /** -#documentCallsFunction("clEnqueueNativeKernel") - * Enqueues a command to execute a Java callback with direct access to buffer memory. - */ - /* - public CLEvent enqueueNativeKernel(NativeKernel kernel, CLMem[] buffers, CLEvent... eventsToWaitFor) { - // TODO check 1.1 or 1.2? - context.getPlatform().requireMinVersionValue("clEnqueueNativeKernel", 1.2); - #declareReusablePtrsAndEventsInOut() - int[] n = ptrs.int1Array; - Pointer pMems = pointerToEntities(buffers, n); - error(CL.clEnqueueNativeKernel( - getEntity(), - n[0], - getPeer(pMems), - CLMem.Migration.getValue(flags), - #eventsInOutArgsRaw() - )); - #returnEventOut("this") - } - */ - - /** -#documentCallsFunction("clEnqueueBarrierWithWaitList") - * Enqueue a barrier operation.
    - * The enqueueBarrier() command ensures that all queued commands in command_queue have finished execution before the next batch of commands can begin execution.
    - * enqueueBarrier() is a synchronization point. -#documentEventsToWaitForAndReturn() - */ - public CLEvent enqueueBarrier(CLEvent... eventsToWaitFor) { - if (context.getPlatform().getVersionValue() >= 1.2 || - eventsToWaitFor != null && eventsToWaitFor.length > 0) - { - context.getPlatform().requireMinVersionValue("clEnqueueBarrierWithWaitList", 1.2); - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueBarrierWithWaitList( - getEntity(), - #eventsInOutArgsRaw() - )); - #returnEventOut("this") - } else { - context.getPlatform().requireMinVersionValue("clEnqueueBarrier", 1.1, 1.2); - error(CL.clEnqueueBarrier(getEntity())); - return null; - } - } - - /** -#documentCallsFunction("clEnqueueMarkerWithWaitList") - * Enqueue a marker command to command_queue.
    - * The marker command returns an event which can be used by to queue a wait on this marker event i.e. wait for all commands queued before the marker command to complete. -#documentEventsToWaitForAndReturn() - */ - @Deprecated - public CLEvent enqueueMarker(CLEvent... eventsToWaitFor) { - if (context.getPlatform().getVersionValue() >= 1.2 || - eventsToWaitFor != null && eventsToWaitFor.length > 0) - { - context.getPlatform().requireMinVersionValue("clEnqueueMarkerWithWaitList", 1.2); - #declareReusablePtrsAndEventsInOut() - error(CL.clEnqueueMarkerWithWaitList( - getEntity(), - #eventsInOutArgsRaw() - )); - #returnEventOut("this") - } else { - context.getPlatform().requireMinVersionValue("clEnqueueMarker", 1.1, 1.2); - #declareReusablePtrs() - Pointer eventOut = ptrs.event_out; - error(CL.clEnqueueMarker(getEntity(), getPeer(eventOut))); - #returnEventOut("this") - } - } - - /** -#documentCallsFunction("clEnqueueAcquireGLObjects") - * Used to acquire OpenCL memory objects that have been created from OpenGL objects.
    - * These objects need to be acquired before they can be used by any OpenCL commands queued to a command-queue.
    - * The OpenGL objects are acquired by the OpenCL context associated with this queue and can therefore be used by all command-queues associated with the OpenCL context. - * @param objects CL memory objects that correspond to GL objects. -#documentEventsToWaitForAndReturn() - */ - public CLEvent enqueueAcquireGLObjects(CLMem[] objects, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOut() - Pointer mems = allocateSizeTs(objects.length); - for (int i = 0; i < objects.length; i++) { - mems.setSizeTAtIndex(i, objects[i].getEntity()); - } - error(CL.clEnqueueAcquireGLObjects( - getEntity(), - objects.length, - getPeer(mems), - #eventsInOutArgsRaw() - )); - #returnEventOut("this") - } - - /** -#documentCallsFunction("clEnqueueReleaseGLObjects") - * Used to release OpenCL memory objects that have been created from OpenGL objects.
    - * These objects need to be released before they can be used by OpenGL.
    - * The OpenGL objects are released by the OpenCL context associated with this queue. - * @param objects CL memory objects that correpond to GL objects. -#documentEventsToWaitForAndReturn() - */ - public CLEvent enqueueReleaseGLObjects(CLMem[] objects, CLEvent... eventsToWaitFor) { - #declareReusablePtrsAndEventsInOut() - Pointer mems = getEntities(objects, (Pointer)allocateSizeTs(objects.length)); - error(CL.clEnqueueReleaseGLObjects( - getEntity(), - objects.length, - getPeer(mems), - #eventsInOutArgsRaw() - )); - #returnEventOut("this") - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLSampler.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLSampler.java deleted file mode 100644 index d059c658..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLSampler.java +++ /dev/null @@ -1,100 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import static com.nativelibs4java.opencl.CLException.error; -import static com.nativelibs4java.opencl.JavaCL.CL; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_ADDRESS_CLAMP; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_ADDRESS_CLAMP_TO_EDGE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_ADDRESS_NONE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_ADDRESS_REPEAT; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_FILTER_LINEAR; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_FILTER_NEAREST; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_SAMPLER_ADDRESSING_MODE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_SAMPLER_FILTER_MODE; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_SAMPLER_NORMALIZED_COORDS; - -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_sampler; -import com.nativelibs4java.util.EnumValue; -import com.nativelibs4java.util.EnumValues; -import org.bridj.*; -import static org.bridj.Pointer.*; - -/** - * OpenCL sampler object.
    - * A sampler object describes how to sample an image when the image is read in the kernel.
    - * The built-in functions to read from an image in a kernel take a sampler as an argument.
    - * The sampler arguments to the image read function can be sampler objects created using OpenCL functions and passed as argument values to the kernel or can be samplers declared inside a kernel. - *
    - * see {@link CLContext#createSampler(boolean, com.nativelibs4java.opencl.CLSampler.AddressingMode, com.nativelibs4java.opencl.CLSampler.FilterMode) } - * @author Olivier Chafik - */ -public class CLSampler extends CLAbstractEntity { - - #declareInfosGetter("infos", "CL.clGetSamplerInfo") - - CLSampler(long entity) { - super(entity); - } - - @Override - protected void clear() { - error(CL.clReleaseSampler(getEntity())); - } - - /** - * Values for CL_SAMPLER_ADDRESSING_MODE
    - * How out-of-range image coordinates are handled when reading from an image - */ - public enum AddressingMode implements com.nativelibs4java.util.ValuedEnum { - Repeat(CL_ADDRESS_REPEAT), - ClampToEdge(CL_ADDRESS_CLAMP_TO_EDGE), - Clamp(CL_ADDRESS_CLAMP), - None(CL_ADDRESS_NONE); - - AddressingMode(long value) { this.value = value; } - long value; - @Override - public long value() { return value; } - public static AddressingMode getEnum(long v) { return EnumValues.getEnum(v, AddressingMode.class); } - } - - /** - * Return the value specified by addressing_mode argument to CLContext.createSampler. - */ - @InfoName("CL_SAMPLER_ADDRESSING_MODE") - public AddressingMode getAddressingMode() { - return AddressingMode.getEnum(infos.getInt(getEntity(), CL_SAMPLER_ADDRESSING_MODE)); - } - - /** - * Values for CL_SAMPLER_FILTER_MODE
    - * Type of filter that must be applied when reading an image - */ - public enum FilterMode implements com.nativelibs4java.util.ValuedEnum { - Nearest(CL_FILTER_NEAREST), - Linear(CL_FILTER_LINEAR); - - FilterMode(long value) { this.value = value; } - long value; - @Override - public long value() { return value; } - public static FilterMode getEnum(int v) { return EnumValues.getEnum(v, FilterMode.class); } - } - /** - * Return the value specified by filter_mode argument to CLContext.createSampler. - */ - @InfoName("CL_SAMPLER_FILTER_MODE") - public FilterMode getFilterMode() { - return FilterMode.getEnum(infos.getInt(getEntity(), CL_SAMPLER_FILTER_MODE)); - } - - /** - * Return the value specified by normalized_coords argument to CLContext.createSampler. - */ - @InfoName("CL_SAMPLER_NORMALIZED_COORDS") - public boolean getNormalizedCoords() { - return infos.getBool(getEntity(), CL_SAMPLER_NORMALIZED_COORDS); - } - - - -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/CLUserEvent.java b/Core/src/main/velocity/com/nativelibs4java/opencl/CLUserEvent.java deleted file mode 100644 index 3cef43e7..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/CLUserEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; - - -import static com.nativelibs4java.opencl.JavaCL.CL; -import static com.nativelibs4java.opencl.CLException.error; -import static com.nativelibs4java.opencl.library.OpenCLLibrary.*; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; - -public class CLUserEvent extends CLEvent { - CLUserEvent(CLQueue queue, long evt) { - super(queue, evt); - } - /** -#documentCallsFunction("clSetUserEventStatus") - * Sets the execution status of a this event object. - * NOTE: Enqueued commands that specify user events in the event_wait_list argument of clEnqueue*** commands must ensure that the status of these user events being waited on are set using clSetUserEventStatus before any OpenCL APIs that release OpenCL objects except for event objects are called; otherwise the behavior is undefined. More details in the OpenCL specifications at section 5.9. - * @param executionStatus specifies the new execution status to be set and can be CL_COMPLETE or a negative integer value to indicate an error. A negative integer value causes all enqueued commands that wait on this user event to be terminated. setStatus can only be called once to change the execution status of event. - */ - public void setStatus(int executionStatus) { - error(CL.clSetUserEventStatus(getEntity(), executionStatus)); - } - - /** - * Calls setStatus(CL_COMPLETE) - */ - public void setComplete() { - setStatus(CL_COMPLETE); - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/InfoName.java b/Core/src/main/velocity/com/nativelibs4java/opencl/InfoName.java deleted file mode 100644 index 9044aead..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/InfoName.java +++ /dev/null @@ -1,17 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Tagging annotation to indicate the name of an OpenCL information in the OpenCL specifications. - * @author ochafik - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface InfoName { - String value(); -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/JavaCL.java b/Core/src/main/velocity/com/nativelibs4java/opencl/JavaCL.java deleted file mode 100644 index e993179b..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/JavaCL.java +++ /dev/null @@ -1,357 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; - -import static com.nativelibs4java.opencl.CLException.error; -import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; - -import java.io.File; -import java.io.IOException; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.logging.*; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -import com.nativelibs4java.opencl.library.OpenCLLibrary; -import com.nativelibs4java.opencl.library.IOpenCLLibrary; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_platform_id; -import org.bridj.*; -import org.bridj.ann.Ptr; - -import org.bridj.util.ProcessUtils; -import org.bridj.util.StringUtils; -import static org.bridj.Pointer.*; - -/** - * Entry point class for the OpenCL4Java Object-oriented wrappers around the OpenCL API.
    - * @author Olivier Chafik - */ -public class JavaCL { - - static final boolean debug = "true".equals(System.getProperty("javacl.debug")) || "1".equals(System.getenv("JAVACL_DEBUG")); - static final boolean verbose = debug || "true".equals(System.getProperty("javacl.verbose")) || "1".equals(System.getenv("JAVACL_VERBOSE")); - static final boolean logCalls = "true".equals(System.getProperty("javacl.logCalls")) || "1".equals(System.getenv("JAVACL_LOG_CALLS")); - static final int minLogLevel = Level.WARNING.intValue(); - - static final String JAVACL_DEBUG_COMPILER_FLAGS_PROP = "JAVACL_DEBUG_COMPILER_FLAGS"; - static List DEBUG_COMPILER_FLAGS; - - static boolean shouldLog(Level level) { - return verbose || level.intValue() >= minLogLevel; - } - static boolean log(Level level, String message, Throwable ex) { - if (!shouldLog(level)) - return true; - Logger.getLogger(JavaCL.class.getSimpleName()).log(level, message, ex); - return true; - } - - static boolean log(Level level, String message) { - log(level, message, null); - return true; - } - - static void check(boolean test, String message, Object... formatArgs) { - if (!test) throw new RuntimeException(String.format(message, formatArgs)); - } - - private static int getPlatformIDs(int count, Pointer out, Pointer pCount) { - assert (count == 0) ^ (pCount == null); - assert (count == 0) == (out == null); - if (hasIcd == null || hasIcd.booleanValue()) { - try { - int ret = CL.clIcdGetPlatformIDsKHR(count, getPeer(out), getPeer(pCount)); - if (hasIcd == null) - hasIcd = true; - return ret; - } catch (Throwable th) { - hasIcd = false; - return CL.clGetPlatformIDs(count, getPeer(out), getPeer(pCount)); - } - } else { - return CL.clGetPlatformIDs(count, getPeer(out), getPeer(pCount)); - } - } - - @org.bridj.ann.Library("OpenCLProbe") - @org.bridj.ann.Convention(org.bridj.ann.Convention.Style.StdCall) - public static class OpenCLProbeLibrary { - @org.bridj.ann.Optional - public native static synchronized int clGetPlatformIDs(int cl_uint1, Pointer cl_platform_idPtr1, Pointer cl_uintPtr1); - @org.bridj.ann.Optional - public native static synchronized int clIcdGetPlatformIDsKHR(int cl_uint1, Pointer cl_platform_idPtr1, Pointer cl_uintPtr1); - @org.bridj.ann.Optional - public native static int clGetPlatformInfo(@Ptr long cl_platform_id1, int cl_platform_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - - #declareInfosGetter("infos", "clGetPlatformInfo") - - private static int getPlatformIDs(int count, Pointer out, Pointer pCount) { - try { - return clIcdGetPlatformIDsKHR(count, out, pCount); - } catch (Throwable th) { - return clGetPlatformIDs(count, out, pCount); - } - } - private static Pointer getPlatformIDs() { - Pointer pCount = allocateInt(); - error(getPlatformIDs(0, null, pCount)); - - int nPlats = pCount.getInt(); - if (nPlats == 0) - return null; - - Pointer ids = allocateTypedPointers(cl_platform_id.class, nPlats); - error(getPlatformIDs(nPlats, ids, null)); - return ids; - } - public static boolean hasOpenCL1_0() { - Pointer ids = getPlatformIDs(); - if (ids == null) - return false; - - for (cl_platform_id id : ids) - if (isOpenCL1_0(id)) - return true; - return false; - } - public static boolean isOpenCL1_0(cl_platform_id platform) { - String version = infos.getString(getPeer(platform), OpenCLLibrary.CL_PLATFORM_VERSION); - return version.matches("OpenCL 1\\.0.*"); - } - public static boolean isValid() { - try { - Pointer ids = getPlatformIDs(); - return ids != null; - } catch (Throwable th) { - return false; - } - } - } - - static final IOpenCLLibrary CL; - static Boolean hasIcd; - static { - if (Platform.isLinux()) { - String amdAppBase = "/opt/AMDAPP/lib"; - BridJ.addLibraryPath(amdAppBase + "/" + (Platform.is64Bits() ? "x86_64" : "x86")); - BridJ.addLibraryPath(amdAppBase); - } - boolean needsAdditionalSynchronization = false; - { - OpenCLProbeLibrary probe = null; - try { - try { - BridJ.setNativeLibraryActualName("OpenCLProbe", "OpenCL"); - BridJ.register(); - } catch (Throwable th) {} - - probe = new OpenCLProbeLibrary(); - - if (!probe.isValid()) { - BridJ.unregister(OpenCLProbeLibrary.class); - //BridJ.setNativeLibraryActualName("OpenCLProbe", "OpenCL"); - String alt; - if (Platform.is64Bits() && (BridJ.getNativeLibraryFile(alt = "atiocl64") != null || BridJ.getNativeLibraryFile(alt = "amdocl64") != null) || - BridJ.getNativeLibraryFile(alt = "atiocl32") != null || - BridJ.getNativeLibraryFile(alt = "atiocl") != null || - BridJ.getNativeLibraryFile(alt = "amdocl32") != null || - BridJ.getNativeLibraryFile(alt = "amdocl") != null) - { - log(Level.INFO, "Hacking around ATI's weird driver bugs (using atiocl/amdocl library instead of OpenCL)", null); - BridJ.setNativeLibraryActualName("OpenCL", alt); - } - BridJ.register(OpenCLProbeLibrary.class); - } - - - if (probe.hasOpenCL1_0()) { - needsAdditionalSynchronization = true; - log(Level.WARNING, "At least one OpenCL platform uses OpenCL 1.0, which is not thread-safe: will use (slower) synchronized low-level bindings."); - } - } finally { - if (probe != null) - BridJ.unregister(OpenCLProbeLibrary.class); - probe = null; - } - } - - if (debug) { - String debugArgs = System.getenv(JAVACL_DEBUG_COMPILER_FLAGS_PROP); - if (debugArgs != null) - DEBUG_COMPILER_FLAGS = Arrays.asList(debugArgs.split(" ")); - else if (Platform.isMacOSX()) - DEBUG_COMPILER_FLAGS = Arrays.asList("-g"); - else - DEBUG_COMPILER_FLAGS = Arrays.asList("-O0", "-g"); - - int pid = ProcessUtils.getCurrentProcessId(); - log(Level.INFO, "Debug mode enabled with compiler flags \"" + StringUtils.implode(DEBUG_COMPILER_FLAGS, " ") + "\" (can be overridden with env. var. JAVACL_DEBUG_COMPILER_FLAGS_PROP)"); - log(Level.INFO, "You can debug your kernels with GDB using one of the following commands :\n" - + "\tsudo gdb --tui --pid=" + pid + "\n" - + "\tsudo ddd --debugger \"gdb --pid=" + pid + "\"\n" - + "More info here :\n" - + "\thttp://code.google.com/p/javacl/wiki/DebuggingKernels"); - - - } - Class libraryClass = OpenCLLibrary.class; - if (needsAdditionalSynchronization) { - try { - libraryClass = BridJ.subclassWithSynchronizedNativeMethods(libraryClass); - } catch (Throwable ex) { - throw new RuntimeException("Failed to create a synchronized version of the OpenCL API bindings: " + ex, ex); - } - } - BridJ.register(libraryClass); - try { - IOpenCLLibrary cl = libraryClass.newInstance(); - CL = logCalls ? wrapWithLogs(cl) : cl; - } catch (Throwable ex) { - throw new RuntimeException("Failed to instantiate library " + libraryClass.getName() + ": " + ex, ex); - } - } - - private static IOpenCLLibrary wrapWithLogs(final IOpenCLLibrary cl) { - return (IOpenCLLibrary) Proxy.newProxyInstance(JavaCL.class.getClassLoader(), new Class[] { IOpenCLLibrary.class }, new InvocationHandler() { - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - log(Level.WARNING, method.getName() + "(" + StringUtils.implode(args, ", ") + ")"); - Object ret = method.invoke(cl, args); - log(Level.WARNING, "\t" + method.getName() + " -> " + ret); - return ret; - } - }); - } - - /** - * List the OpenCL implementations that contain at least one GPU device. - */ - public static CLPlatform[] listGPUPoweredPlatforms() { - CLPlatform[] platforms = listPlatforms(); - List out = new ArrayList(platforms.length); - for (CLPlatform platform : platforms) { - if (platform.listGPUDevices(true).length > 0) - out.add(platform); - } - return out.toArray(new CLPlatform[out.size()]); - } - /** - * Lists all available OpenCL implementations. - */ - public static CLPlatform[] listPlatforms() { - Pointer pCount = allocateInt(); - error(getPlatformIDs(0, null, pCount)); - - int nPlats = pCount.getInt(); - if (nPlats == 0) - return new CLPlatform[0]; - - Pointer ids = allocateTypedPointers(cl_platform_id.class, nPlats); - - error(getPlatformIDs(nPlats, ids, null)); - CLPlatform[] platforms = new CLPlatform[nPlats]; - - for (int i = 0; i < nPlats; i++) { - platforms[i] = new CLPlatform(ids.getSizeTAtIndex(i)); - } - return platforms; - } - - /** - * Creates an OpenCL context formed of the provided devices.
    - * It is generally not a good idea to create a context with more than one device, - * because much data is shared between all the devices in the same context. - * @param devices devices that are to form the new context - * @return new OpenCL context - */ - public static CLContext createContext(Map contextProperties, CLDevice... devices) { - return devices[0].getPlatform().createContext(contextProperties, devices); - } - - /** - * Allows the implementation to release the resources allocated by the OpenCL compiler.
    - * This is a hint from the application and does not guarantee that the compiler will not be used in the future or that the compiler will actually be unloaded by the implementation.
    - * Calls to Program.build() after unloadCompiler() will reload the compiler, if necessary, to build the appropriate program executable. - */ - public static void unloadCompiler() { - error(CL.clUnloadCompiler()); - } - - /** - * Returns the "best" OpenCL device (currently, the one that has the largest amount of compute units).
    - * For more control on what is to be considered a better device, please use the {@link JavaCL#getBestDevice(CLPlatform.DeviceFeature[]) } variant.
    - * This is currently equivalent to getBestDevice(MaxComputeUnits) - */ - public static CLDevice getBestDevice() { - return getBestDevice(CLPlatform.DeviceFeature.MaxComputeUnits); - } - /** - * Returns the "best" OpenCL device based on the comparison of the provided prioritized device feature.
    - * The returned device does not necessarily exhibit the features listed in preferredFeatures, but it has the best ordered composition of them.
    - * For instance on a system with a GPU and a CPU device, JavaCL.getBestDevice(CPU, MaxComputeUnits) will return the CPU device, but on another system with two GPUs and no CPU device it will return the GPU that has the most compute units. - */ - public static CLDevice getBestDevice(CLPlatform.DeviceFeature... preferredFeatures) { - List devices = new ArrayList(); - for (CLPlatform platform : listPlatforms()) - devices.addAll(Arrays.asList(platform.listAllDevices(true))); - return CLPlatform.getBestDevice(Arrays.asList(preferredFeatures), devices); - } - /** - * Creates an OpenCL context with the "best" device (see {@link JavaCL#getBestDevice() }) - */ - public static CLContext createBestContext() { - return createBestContext(DeviceFeature.MaxComputeUnits); - } - - /** - * Creates an OpenCL context with the "best" device based on the comparison of the provided - * prioritized device feature (see {@link JavaCL#getBestDevice(CLPlatform.DeviceFeature...) }) - */ - public static CLContext createBestContext(CLPlatform.DeviceFeature... preferredFeatures) { - CLDevice device = getBestDevice(preferredFeatures); - return device.getPlatform().createContext(null, device); - } - - /** - * Creates an OpenCL context able to share entities with the current OpenGL context. - * @throws RuntimeException if JavaCL is unable to create an OpenGL-shared OpenCL context. - */ - public static CLContext createContextFromCurrentGL() { - RuntimeException first = null; - for (CLPlatform platform : listPlatforms()) { - try { - CLContext ctx = platform.createContextFromCurrentGL(); - if (ctx != null) - return ctx; - } catch (RuntimeException ex) { - if (first == null) - first = ex; - - } - } - throw new RuntimeException("Failed to create an OpenCL context based on the current OpenGL context", first); - } - - static File userJavaCLDir = new File(new File(System.getProperty("user.home")), ".javacl"); - static File userCacheDir = new File(userJavaCLDir, "cache"); - - static synchronized File createTempFile(String prefix, String suffix, String category) { - File dir = new File(userJavaCLDir, category); - dir.mkdirs(); - try { - return File.createTempFile(prefix, suffix, dir); - } catch (IOException ex) { - throw new RuntimeException("Failed to create a temporary directory for category '" + category + "' in " + userJavaCLDir + ": " + ex.getMessage(), ex); - } - } - static synchronized File createTempDirectory(String prefix, String suffix, String category) { - File file = createTempFile(prefix, suffix, category); - file.delete(); - file.mkdir(); - return file; - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/LocalSize.java b/Core/src/main/velocity/com/nativelibs4java/opencl/LocalSize.java deleted file mode 100644 index 54e39b2a..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/LocalSize.java +++ /dev/null @@ -1,36 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import org.bridj.*; -import org.bridj.util.*; -import java.lang.reflect.Type; -/** - * Size in bytes of a __local argument. - */ -public class LocalSize { - long size; - public LocalSize(long size) { - this.size = size; - } - - #foreach ($prim in $primitivesNoBool) - - /** - * Returns the size in bytes of an array of ${prim.Name} values of the specified length.
    - * @return arrayLength * sizeof(${prim.Name}) = arrayLength * ${prim.Size} - */ - public static LocalSize of${prim.CapName}Array(long arrayLength) { - return new LocalSize(arrayLength * ${prim.Size}); - } - - #end - - /** - * Returns the size in bytes of an array of T values of the specified length.
    - */ - public static LocalSize ofArray(long arrayLength, Type componentType) { - PointerIO io = PointerIO.getInstance(componentType); - if (io == null) - throw new RuntimeException("Unsupported type : " + Utils.toString(componentType)); - return new LocalSize(arrayLength * io.getTargetSize()); - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/PlatformUtils.java b/Core/src/main/velocity/com/nativelibs4java/opencl/PlatformUtils.java deleted file mode 100644 index 17512b1b..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/PlatformUtils.java +++ /dev/null @@ -1,26 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; - -class PlatformUtils { - public enum PlatformKind { - AMDApp, - NVIDIA, - Apple, - Intel - } - public static PlatformKind guessPlatformKind(CLPlatform p) { - String name = p.getName(); - if (name != null) { - if (name.equals("Apple")) - return PlatformKind.Apple; - else if (name.equals("ATI Stream") || name.equals("AMD Accelerated Parallel Processing")) - return PlatformKind.AMDApp; - else { - String vendor = p.getVendor().toLowerCase(); - if (vendor.contains("nvidia")) - return PlatformKind.NVIDIA; - } - } - return null; - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java b/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java deleted file mode 100644 index 3b5c2a7c..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointer.java +++ /dev/null @@ -1,68 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import org.bridj.*; - -/** - * - * @author ochafik - */ -final class ReusablePointer { - private final Pointer pointer; - private final long bytesCapacity; - - public ReusablePointer(long bytesCapacity) { - this.bytesCapacity = bytesCapacity; - this.pointer = allocateAlignedBytes(bytesCapacity).withoutValidityInformation(); - } - - static Pointer allocateAlignedBytes(long count) { - // Allocate memory aligned to 128 bytes to match alignment of cl_double16. - return Pointer.allocateAlignedBytes(null /* io */, count, 128 /* alignment */, null /* beforeDeallocation */); - } - - public Pointer pointerToInts(int... values) { - if (values == null) - return null; - long needed = 4 * values.length; - if (needed > bytesCapacity) { - return Pointer.pointerToInts(values); - } else { - return (Pointer)pointer.setInts(values); - } - } - public Pointer pointerToSizeTs(long... values) { - if (values == null) - return null; - long needed = SizeT.SIZE * values.length; - if (needed > bytesCapacity) { - return Pointer.pointerToSizeTs(values); - } else { - return (Pointer)pointer.setSizeTs(values); - } - } - public Pointer pointerToSizeTs(int... values) { - if (values == null) - return null; - long needed = SizeT.SIZE * values.length; - if (needed > bytesCapacity) { - return Pointer.pointerToSizeTs(values); - } else { - return (Pointer)pointer.setSizeTs(values); - } - } - public Pointer allocatedBytes(int needed) { - if (needed == 0) - return null; - if (needed > bytesCapacity) { - return (Pointer)allocateAlignedBytes(needed); - } else { - return (Pointer)pointer; - } - } - public Pointer allocatedSizeTs(int needed) { - return allocatedBytes(needed * SizeT.SIZE); - } - public Pointer allocatedInts(int needed) { - return allocatedBytes(needed * 4); - } -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointers.java b/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointers.java deleted file mode 100644 index 2850a56f..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/ReusablePointers.java +++ /dev/null @@ -1,58 +0,0 @@ -#parse("main/Header.vm") -package com.nativelibs4java.opencl; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; -import org.bridj.*; -import static org.bridj.Pointer.*; -/** - * - * @author ochafik - */ -final class ReusablePointers { - public final int[] int1Array = new int[1]; - - public final ReusablePointer - sizeT3_1 = new ReusablePointer(3 * SizeT.SIZE), - sizeT3_2 = new ReusablePointer(3 * SizeT.SIZE), - sizeT3_3 = new ReusablePointer(3 * SizeT.SIZE); - - public final Pointer - int1 = allocateInt().withoutValidityInformation(), - int2 = allocateInt().withoutValidityInformation(); - - public final Pointer - sizeT1 = allocateSizeT().withoutValidityInformation(); - - public final Pointer - long1 = allocateLong().withoutValidityInformation(); - - public final Pointer> - ptr1 = allocatePointer().withoutValidityInformation(); - - public final ReusablePointer - int3_1 = new ReusablePointer(4 * 3); - - public final ReusablePointer - kernelArg = new ReusablePointer(8 * 16); // double16 arguments ! - - public final Pointer event_out = allocateTypedPointer(cl_event.class).withoutValidityInformation(); - - public final Pointer pErr = allocateInt().withoutValidityInformation(); - - public final int[] event_count = new int[1]; - public final ReusablePointer events_in = new ReusablePointer(Pointer.SIZE * 10); - - private ReusablePointers() {} - - public static ReusablePointers get() { - return local.get(); - } - private static final ThreadLocal local = new ThreadLocal() { - - @Override - protected ReusablePointers initialValue() { - return new ReusablePointers(); - } - - }; - -} diff --git a/Core/src/main/velocity/com/nativelibs4java/opencl/package-info.java b/Core/src/main/velocity/com/nativelibs4java/opencl/package-info.java deleted file mode 100644 index f3fa96ce..00000000 --- a/Core/src/main/velocity/com/nativelibs4java/opencl/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -#parse("main/Header.vm") -/** - * Object-oriented wrappers around the OpenCL API ({@link com.nativelibs4java.opencl.JavaCL}, {@link com.nativelibs4java.opencl.CLPlatform}, {@link com.nativelibs4java.opencl.CLContext}, {@link com.nativelibs4java.opencl.CLProgram}, {@link com.nativelibs4java.opencl.CLKernel}, {@link com.nativelibs4java.opencl.CLBuffer}...)
    - * Also see the low-level bindings : {@link com.nativelibs4java.opencl.library.OpenCLLibrary} - */ -package com.nativelibs4java.opencl; diff --git a/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java b/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java index 4957d898..328292d0 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/AbstractCommon.java @@ -8,17 +8,12 @@ import org.junit.Before; import org.junit.BeforeClass; -import java.util.ArrayList; -import java.util.List; -import org.junit.After; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import com.nativelibs4java.test.MiscTestUtils; /** * * @author ochafik */ -@RunWith(Parameterized.class) public abstract class AbstractCommon { CLPlatform platform; @@ -26,14 +21,34 @@ public abstract class AbstractCommon { CLQueue queue; CLDevice device; CLImageFormat[] formatsRead2D, formatsRead3D, formatsWrite2D, formatsWrite3D, formatsReadWrite2D, formatsReadWrite3D; + + @BeforeClass + public static void setup() { + MiscTestUtils.protectJNI(); + } + static String chosenPlatformName = System.getProperty("javacl.test.platform", System.getenv("JAVACL_TEST_PLATFORM")); static boolean listedPlatforms; - AbstractCommon(CLDevice device) { - this.device = device; - platform = device.getPlatform(); - context = platform.createContext(null, device); - queue = context.createDefaultQueue(); + @Before + public void setUp() { + CLPlatform chosenPlatform = null; + for (CLPlatform platform : JavaCL.listPlatforms()) { + if (!listedPlatforms) + System.out.println("Platform Detected : \"" + platform.getName() + "\""); + if (chosenPlatformName != null && platform.getName().contains(chosenPlatformName)) { + chosenPlatform = platform; + } + } + listedPlatforms = true; + if (chosenPlatform != null) { + platform = chosenPlatform; + context = platform.createContext(null, platform.getBestDevice()); + } else { + context = JavaCL.createBestContext(); + platform = context.getPlatform(); + } + queue = context.createDefaultQueue(); device = context.getDevices()[0]; formatsRead2D = context.getSupportedImageFormats(CLMem.Flags.ReadOnly, CLMem.ObjectType.Image2D); formatsWrite2D = context.getSupportedImageFormats(CLMem.Flags.WriteOnly, CLMem.ObjectType.Image2D); @@ -42,23 +57,6 @@ public abstract class AbstractCommon { formatsReadWrite2D = context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image2D); formatsReadWrite3D = context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image3D); } - - @Parameterized.Parameters - public static List getDeviceParameters() { - List ret = new ArrayList(); - for (CLPlatform platform : JavaCL.listPlatforms()) - for (CLDevice device : platform.listAllDevices(true)) - ret.add(new Object[] { device }); - return ret; - } - /* - @After - public void cleanup() { - queue.finish(); - queue.release(); - context.release(); - device.release(); - platform.release(); - } - */ -} + + +} \ No newline at end of file diff --git a/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java b/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java index d8d9a74b..fec9d4a3 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/BinaryKernelTest.java @@ -1,29 +1,26 @@ package com.nativelibs4java.opencl; +import static com.nativelibs4java.util.NIOUtils.directBuffer; import java.util.Map; import static org.junit.Assert.assertEquals; +import java.nio.IntBuffer; + import org.junit.BeforeClass; import org.junit.Test; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; -import java.util.List; -import org.junit.Ignore; -import org.junit.runners.Parameterized; +import com.nativelibs4java.test.MiscTestUtils; /** + * * @author Kazo Csaba */ @SuppressWarnings("unchecked") public class BinaryKernelTest extends AbstractCommon { - public BinaryKernelTest(CLDevice device) { - super(device); - } - - @Parameterized.Parameters - public static List getDeviceParameters() { - return AbstractCommon.getDeviceParameters(); + + @BeforeClass + public static void setup() { + MiscTestUtils.protectJNI(); } @Test @@ -39,45 +36,27 @@ public void simpleTest() throws CLBuildException { "} "); program.build(); Map binaries = program.getBinaries(); - String src = program.getSource(); program.release(); CLProgram binaryProgram = context.createProgram(binaries, null); CLKernel kernel = binaryProgram.createKernel("copy"); - CLBuffer a=context.createBuffer(CLMem.Usage.Input, Integer.class, 4); - CLBuffer b=context.createBuffer(CLMem.Usage.Output, Integer.class, 4); + CLIntBuffer a=context.createIntBuffer(CLMem.Usage.Input, 4); + CLIntBuffer b=context.createIntBuffer(CLMem.Usage.Output, 4); - Pointer source = allocateInts(4).order(context.getByteOrder()); + IntBuffer source = directBuffer(4, context.getByteOrder(), IntBuffer.class); for (int i=0; i<4; i++) - source.set(i, 3*i+10); + source.put(i, 3*i+10); a.write(queue, source, true); kernel.setArgs(a, b); kernel.enqueueNDRange(queue, new int[]{4}).waitFor(); - Pointer target = b.read(queue); + IntBuffer target = b.read(queue); - assertEquals(target.getValidElements(), source.getValidElements()); + assertEquals(target.capacity(), source.capacity()); for (int i=0; i<4; i++) assertEquals(source.get(i), target.get(i)); } - - /** - * Test from issue https://github.com/ochafik/nativelibs4java/issues/453 - */ - @Test - public void cachingTest() { - CLContext clcontext = JavaCL.createBestContext(); - CLProgram ap = clcontext.createProgram("__kernel void add(int a, int b, __global int* c) { *c = a + b; }"); - ap.createKernel("add"); - Map addBins = ap.getBinaries(); - Map subBins = clcontext.createProgram("__kernel void sub(int a, int b, __global int* c) { *c = a - b; }").getBinaries(); - CLProgram ap2 = clcontext.createProgram(addBins, "__kernel void add(int a, int b, __global int* c) { *c = a + b; }"); - ap2.createKernel("add"); - CLProgram sp2 = clcontext.createProgram(subBins, "__kernel void sub(int a, int b, __global int* c) { *c = a - b; }"); - sp2.setCached(true); // set to false and it works - sp2.createKernel("sub"); - } -} +} \ No newline at end of file diff --git a/Core/src/test/java/com/nativelibs4java/opencl/BufferReadTest.java b/Core/src/test/java/com/nativelibs4java/opencl/BufferReadTest.java index df4ed5ab..32cf8767 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/BufferReadTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/BufferReadTest.java @@ -12,11 +12,11 @@ import com.nativelibs4java.opencl.CLDevice; import com.nativelibs4java.opencl.CLEvent; import com.nativelibs4java.opencl.CLKernel; +import com.nativelibs4java.opencl.CLLongBuffer; import com.nativelibs4java.opencl.CLMem; import com.nativelibs4java.opencl.CLProgram; import com.nativelibs4java.opencl.CLQueue; import com.nativelibs4java.opencl.JavaCL; -import org.bridj.Pointer; public class BufferReadTest extends TestCase { @@ -49,13 +49,13 @@ protected void tearDown() throws Exception { public void testBufferRead() throws Exception { int size = 50; CLKernel kernel = program.createKernel("testLongRead"); - CLBuffer clInBuff = context.createLongBuffer(CLMem.Usage.Input, size); - CLBuffer clOutBuff = context.createLongBuffer(CLMem.Usage.Output, size); + CLLongBuffer clInBuff = context.createLongBuffer(CLMem.Usage.Input, size); + CLLongBuffer clOutBuff = context.createLongBuffer(CLMem.Usage.Output, size); long[] longArray = new long[size]; for(int i = 0; i < longArray.length ; i ++) { longArray[i] = i; } - clInBuff.write(q, Pointer.pointerToLongs(longArray), true); + clInBuff.write(q, LongBuffer.wrap(longArray), true); kernel.setArg(0, clInBuff); kernel.setArg(1, clOutBuff); CLEvent completion = kernel.enqueueNDRange(q, new int[] {size}); @@ -69,13 +69,13 @@ public void testBufferRead() throws Exception { //and since the LongBuffer is wrapped around the outPrim, it would update the values as soon as it is read. long[] outPrim = new long[size]; if (false) { - Pointer outBuffJava = Pointer.pointerToLongs(outPrim); + LongBuffer outBuffJava = LongBuffer.wrap(outPrim); clOutBuff.read(q, 0, size,outBuffJava, true); } else { - Pointer outBuffJava = Pointer.allocateLongs(size).order(context.getByteOrder()); + LongBuffer outBuffJava = NIOUtils.directLongs(size, context.getByteOrder()); clOutBuff.read(q, 0, size,outBuffJava, true); //LongBuffer outBuffJava = clOutBuff.read(q, 0, size); - outBuffJava.getLongs(outPrim); + outBuffJava.get(outPrim); } System.out.println("test1:\nThese should read 1, 2, 3, 4, 5"); for(int i = 0 ; i < 5 ; i ++) { @@ -88,9 +88,9 @@ public void testBufferRead() throws Exception { //////////////////////////////////////////////////// //this is the way that we know works, but it creates a new LongBuffer every read, and we also have to do a //outBuffJava2.get(), which forces us to separate the outPrim2 from the java LongBuffer, and require us to create a new array. - Pointer outBuffJava2 = clOutBuff.read(q); + LongBuffer outBuffJava2 = clOutBuff.read(q); long[] outPrim2 = new long[size]; - outBuffJava2.getLongs(outPrim2); + outBuffJava2.get(outPrim2, 0, size); System.out.println("test2:\nThese should read 1, 2, 3, 4, 5"); for(int i = 0 ; i < 5 ; i ++) { System.out.print(outPrim2[i] + ", "); diff --git a/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java b/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java index 79337db1..8894aae2 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/BufferTest.java @@ -6,22 +6,21 @@ package com.nativelibs4java.opencl; import static com.nativelibs4java.util.NIOUtils.directBuffer; +import static com.nativelibs4java.util.NIOUtils.getPrimitiveClass; +import static com.nativelibs4java.util.NIOUtils.getBufferClass; import static com.nativelibs4java.util.NIOUtils.get; import static com.nativelibs4java.util.NIOUtils.put; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import java.nio.*; import org.junit.BeforeClass; import org.junit.Test; +import com.nativelibs4java.test.MiscTestUtils; import com.nativelibs4java.util.NIOUtils; -import org.bridj.*; +import com.sun.jna.Native; import java.nio.ByteOrder; -import static org.bridj.Pointer.*; -import java.nio.ByteOrder; -import java.util.List; -import org.junit.runners.Parameterized; /** * @@ -29,97 +28,68 @@ */ @SuppressWarnings("unchecked") public class BufferTest extends AbstractCommon { - public BufferTest(CLDevice device) { - super(device); - } - - @Parameterized.Parameters - public static List getDeviceParameters() { - return AbstractCommon.getDeviceParameters(); - } - static ByteOrder otherOrder(ByteOrder o) { - return o.equals(ByteOrder.BIG_ENDIAN) ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN; - } - - @Test(expected = IllegalArgumentException.class) - public void testMismatchingOrder() { - context.createBuffer(CLMem.Usage.InputOutput, allocateFloats(10).order(otherOrder(context.getByteOrder()))); - } - @Test - public void testMismatchingByteOrder() { - context.createBuffer(CLMem.Usage.InputOutput, allocateBytes(10).order(otherOrder(context.getByteOrder()))); + @BeforeClass + public static void setup() { + MiscTestUtils.protectJNI(); } - + @Test public void testReadWrite() { - for (Class bufferClass : bufferClasses) - testReadWrite(bufferClass, 10, 3, 3); + for (Class primClass : primClasses) + testReadWrite(primClass, 10, 3, 3); } - public void testReadWrite(Class bufferClass, int n, int zeroOffset, int zeroLength) { - CLBuffer buf = context.createBuffer(CLMem.Usage.InputOutput, bufferClass, n); + public void testReadWrite(Class primClass, int n, int zeroOffset, int zeroLength) { + Class bufferClass = getBufferClass(primClass); + CLBuffer buf = context.createBuffer(CLMem.Usage.InputOutput, primClass, n); assertEquals(n, buf.getElementCount()); - Pointer initial = allocateArray(bufferClass, n).order(context.getByteOrder()); - Pointer zeroes = allocateArray(bufferClass, n).order(context.getByteOrder()); + Buffer initial = directBuffer(n, context.getByteOrder(), bufferClass); + Buffer zeroes = directBuffer(n, context.getByteOrder(), bufferClass); for (int i = 0; i < n; i++) { - int v = i + 1; - Object value = null; - if (bufferClass == Integer.class) - value = (Object)v; - else if (bufferClass == Long.class) - value = (Object)(long)v; - else if (bufferClass == Short.class) - value = (Object)(short)v; - else if (bufferClass == Byte.class) - value = (Object)(byte)v; - else if (bufferClass == Double.class) - value = (Object)(double)v; - else if (bufferClass == Float.class) - value = (Object)(float)v; - else if (bufferClass == Boolean.class) - value = (Object)(v != 0); - else if (bufferClass == Character.class) - value = (Object)(char)v; - else - throw new RuntimeException(); - initial.set(i, (B)value); + put(initial, i, i + 1); + put(zeroes, i, 0); } buf.write(queue, initial, true); - Pointer retrieved = buf.read(queue); - assertEquals(buf.getElementCount(), retrieved.getValidElements()); + Buffer retrieved = buf.read(queue); + assertEquals(buf.getElementCount(), retrieved.capacity()); + + retrieved.rewind(); + initial.rewind(); for (int i = 0; i < n; i++) - assertEquals(bufferClass.getName(), initial.get(i), retrieved.get(i)); + assertEquals(bufferClass.getName(), get(initial, i), get(retrieved, i)); buf.write(queue, zeroOffset, zeroLength, zeroes, true); - boolean direct = true; + for (boolean direct : new boolean[] { true, false }) { String type = direct ? "read to direct buffer" : "read to indirect buffer"; - Pointer readBuffer; - //if (direct) + Buffer readBuffer; + if (direct) readBuffer = retrieved; - //else - // readBuffer = NIOUtils.indirectBuffer(n, bufferClass); + else + readBuffer = NIOUtils.indirectBuffer(n, bufferClass); buf.read(queue, readBuffer, true); for (int i = 0; i < n; i++) { if (i >= zeroOffset && i < (zeroOffset + zeroLength)) - assertEquals(bufferClass.getName(), zeroes.get(i), readBuffer.get(i)); + assertEquals(bufferClass.getName(), get(zeroes, i), get(readBuffer, i)); else - assertEquals(bufferClass.getName(), initial.get(i), readBuffer.get(i)); + assertEquals(bufferClass.getName(), get(initial, i), get(readBuffer, i)); } + } } - Class[] bufferClasses = new Class[] { - Integer.class, - Long.class, - Short.class, - Byte.class, - Double.class, - Float.class + Class[] bufferClasses = new Class[] { + IntBuffer.class, + LongBuffer.class, + ShortBuffer.class, + ByteBuffer.class, + DoubleBuffer.class, + CharBuffer.class, + FloatBuffer.class }; Class[] primClasses = new Class[] { Integer.class, @@ -132,53 +102,16 @@ else if (bufferClass == Character.class) }; @Test public void testMap() { - for (Class bufferClass : bufferClasses) + for (Class bufferClass : bufferClasses) testMap(bufferClass); } - public void testMap(Class bufferClass) { + public void testMap(Class bufferClass) { int size = 10; - Pointer data = allocateBytes(size).order(context.getByteOrder()); - CLBuffer buf = context.createBuffer(CLMem.Usage.Input, data, false).as(bufferClass); - Pointer mapped = buf.map(queue, CLMem.MapFlags.Read); - - assertEquals(data, mapped); - } - - @Test - public void testFill() { - Pointer pattern = pointerToInts(1, 2, 3, 4); - int n = 12; - CLBuffer buf = context.createIntBuffer(CLMem.Usage.InputOutput, n); - CLEvent e = buf.fillBuffer(queue, pattern); - assertNotNull(e); - Pointer data = buf.read(queue, e); - for (int i = 0; i < n; i++) { - int expectedValue = (i % 4) + 1; - assertEquals(expectedValue, data.getIntAtIndex(i)); - } - try { - buf.fillBuffer(queue, pattern, pattern.getValidElements(), 0, n - 1); - fail("Expected fill length failure"); - } catch (Throwable th) {} - try { - buf.fillBuffer(queue, pattern, pattern.getValidElements() + 1, 0, n); - fail("Expected pattern length failure"); - } catch (Throwable th) {} - } - @Test - public void testCopyTo_full() { - CLBuffer b = context.createIntBuffer(CLMem.Usage.InputOutput, pointerToInts(1, 2, 3, 4, 5, 6)); - CLBuffer out = context.createIntBuffer(CLMem.Usage.InputOutput, 6); + ByteBuffer data = NIOUtils.directBytes(size, context.getByteOrder()); + CLBuffer buf = context.createBuffer(CLMem.Usage.Input, data, false); + ByteBuffer mapped = buf.map(queue, CLMem.MapFlags.Read); - CLEvent e = b.copyTo(queue, out); - assertArrayEquals(new int[] { 1, 2, 3, 4, 5, 6 }, out.read(queue, e).getInts()); + assertEquals(Native.getDirectBufferPointer(data), Native.getDirectBufferPointer(mapped)); } - @Test - public void testCopyTo_partial() { - CLBuffer b = context.createIntBuffer(CLMem.Usage.InputOutput, pointerToInts(1, 2, 3, 4, 5, 6)); - CLBuffer out = context.createIntBuffer(CLMem.Usage.InputOutput, 6); - CLEvent e = b.copyElementsTo(queue, out, 2, 1, 2); - assertArrayEquals(new int[] { 3, 4 }, out.read(queue, e).next().validElements(2).getInts()); - } -} +} \ No newline at end of file diff --git a/Core/src/test/java/com/nativelibs4java/opencl/ByteOrderHackTest.java b/Core/src/test/java/com/nativelibs4java/opencl/ByteOrderHackTest.java deleted file mode 100644 index 46cdc3b1..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/ByteOrderHackTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.nativelibs4java.opencl; - -import java.util.Map; -import static org.junit.Assert.assertEquals; - -import org.junit.BeforeClass; -import org.junit.Test; - -import org.bridj.Pointer; -import static org.bridj.Pointer.*; -import java.util.List; -import org.junit.runners.Parameterized; - -@SuppressWarnings("unchecked") -public class ByteOrderHackTest extends AbstractCommon { - public ByteOrderHackTest(CLDevice device) { - super(device); - } - - @Parameterized.Parameters - public static List getDeviceParameters() { - return AbstractCommon.getDeviceParameters(); - } - - @Test - public void test() { - if (!ByteOrderHack.hackEnabled) - return; - for (CLPlatform platform : JavaCL.listPlatforms()) { - for (CLDevice device : platform.listAllDevices(true)) { - assertEquals(device.getByteOrder(), ByteOrderHack.checkByteOrderNeededForBuffers(device)); - } - } - } -} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/CLPlatformTest.java b/Core/src/test/java/com/nativelibs4java/opencl/CLPlatformTest.java deleted file mode 100644 index cb759057..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/CLPlatformTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.nativelibs4java.opencl; -import static com.nativelibs4java.opencl.JavaCL.*; - -import java.util.*; - -import static org.junit.Assert.*; -import org.junit.*; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Parameterized.class) -public class CLPlatformTest { - final CLPlatform platform; - - public CLPlatformTest(CLPlatform platform) { - this.platform = platform; - } - @Test - public void ensureHasDevices() { - CLDevice[] devices = platform.listAllDevices(false); - assertTrue("No device in platform " + platform, devices.length > 0); - } - @Parameters - public static List readParameters() { - List data = new ArrayList(); - - for (CLPlatform platform : JavaCL.listPlatforms()) { - data.add(new Object[] { platform }); - } - - return data; - } -} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/CLTestUtils.java b/Core/src/test/java/com/nativelibs4java/opencl/CLTestUtils.java index 48bfff52..35d97fdf 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/CLTestUtils.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/CLTestUtils.java @@ -4,10 +4,6 @@ import java.nio.Buffer; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; - - -import org.bridj.*; -import static org.bridj.Pointer.*; /** * @author ochafik */ @@ -26,7 +22,7 @@ public static interface Action3 { void call(X x, Y y, Z z); } /// Calculate the average relative error of operations between two result buffers - public static double avgError(FloatBuffer a, Pointer b, int dataSize) { + public static double avgError(FloatBuffer a, FloatBuffer b, int dataSize) { double tot = 0; for (int i = 0; i < dataSize; i++) { float va = a.get(i), vb = b.get(i); @@ -43,7 +39,7 @@ public static double avgError(FloatBuffer a, Pointer b, int dataSize) { } return tot / dataSize; } - public static double avgError(DoubleBuffer a, Pointer b, int dataSize) { + public static double avgError(DoubleBuffer a, DoubleBuffer b, int dataSize) { double tot = 0; for (int i = 0; i < dataSize; i++) { double va = a.get(i), vb = b.get(i); @@ -61,26 +57,18 @@ public static double avgError(DoubleBuffer a, Pointer b, int dataSize) { return tot / dataSize; } - public static void fillBuffersWithSomeDataf(FloatBuffer a, FloatBuffer b) { - fillBuffersWithSomeDataf((Pointer)pointerToBuffer(a), (Pointer)pointerToBuffer(b)); - } - public static void fillBuffersWithSomeDatad(DoubleBuffer a, DoubleBuffer b) { - fillBuffersWithSomeDatad((Pointer)pointerToBuffer(a), (Pointer)pointerToBuffer(b)); - } - public static void fillBuffersWithSomeDataf(Pointer a, Pointer b) { - int s = (int)a.getValidElements(); + public static void fillBuffersWithSomeData(FloatBuffer a, FloatBuffer b) { + int s = a.capacity(); for (int i = 0; i < s; i++) { - float v = i; - a.set(i, v); - b.set(i, v); + a.put(i, i); + b.put(i, i); } } - public static void fillBuffersWithSomeDatad(Pointer a, Pointer b) { - int s = (int)a.getValidElements(); + public static void fillBuffersWithSomeData(DoubleBuffer a, DoubleBuffer b) { + int s = a.capacity(); for (int i = 0; i < s; i++) { - double v = i; - a.set(i, v); - b.set(i, v); + a.put(i, i); + b.put(i, i); } } @@ -97,7 +85,7 @@ public static CLDevice[] getDevices(Target target) { throw new IllegalArgumentException("Unknown target : " + target); } } - public static class ExecResult { + public static class ExecResult { public B buffer; public double unitTimeNano; public ExecResult(B buffer, double unitTimeNano) { diff --git a/Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java b/Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java deleted file mode 100644 index fe2b8518..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl; - -import static com.nativelibs4java.util.NIOUtils.directBuffer; -import static com.nativelibs4java.util.NIOUtils.get; -import static com.nativelibs4java.util.NIOUtils.put; -import static org.junit.Assert.*; - -import java.nio.*; - -import org.junit.*; - -import com.nativelibs4java.util.NIOUtils; -import org.bridj.*; -import java.nio.ByteOrder; -import static org.bridj.Pointer.*; -import java.nio.ByteOrder; -import java.util.*; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -/** - * - * @author ochafik - */ -@RunWith(Parameterized.class) -public class DeviceTest { - private final CLDevice device; - - public DeviceTest(CLDevice device) { - this.device = device; - - System.out.println(device); - System.out.println("\tmax sub-devices: " + device.getPartitionMaxSubDevices()); - System.out.println("\tpartition properties: " + device.getPartitionProperties()); - System.out.println("\tpartition domains: " + device.getPartitionAffinityDomains()); - } - - @Parameterized.Parameters - public static List getDeviceParameters() { - List ret = new ArrayList(); - for (CLPlatform platform : JavaCL.listPlatforms()) { - for (CLDevice device : platform.listAllDevices(true)) { - ret.add(new Object[] { device }); - } - } - return ret; - } - - @Test - public void testSplitEqually() { - if (!device.getPartitionProperties().contains(CLDevice.PartitionType.Equally)) return; - - int computeUnits = device.getMaxComputeUnits(); - System.out.println("computeUnits = " + computeUnits); - int subComputeUnits = computeUnits / 2; - - CLDevice[] subDevices = device.createSubDevicesEqually(subComputeUnits); - for (CLDevice subDevice : subDevices) { - assertEquals(subComputeUnits, subDevice.getMaxComputeUnits()); - checkParent(device, subDevice); - } - } - - @Test - public void testSplitByCounts() { - if (!device.getPartitionProperties().contains(CLDevice.PartitionType.ByCounts)) return; - - long[] counts = new long[] { 2, 4, 8 }; - CLDevice[] subDevices = device.createSubDevicesByCounts(counts); - assertEquals(counts.length, subDevices.length); - int i = 0; - long[] actualCounts = new long[counts.length]; - for (CLDevice subDevice : subDevices) { - actualCounts[i] = subDevice.getMaxComputeUnits(); - checkParent(device, subDevice); - i++; - } - Arrays.sort(actualCounts); - assertArrayEquals(counts, actualCounts); - } - - public void checkSplitByAffinity(CLDevice.AffinityDomain domain) { - if (!device.getPartitionProperties().contains(CLDevice.PartitionType.ByAffinityDomain)) { - System.out.println("Split by affinity is not supported by device " + device); - return; - } - if (!device.getPartitionAffinityDomains().contains(domain)) { - System.out.println("Affinity domain " + domain + " not supported by device " + device); - return; - } - - CLDevice[] subDevices = device.createSubDevicesByAffinity(domain); - assertTrue(subDevices.length > 1); - for (CLDevice subDevice : subDevices) { - checkParent(device, subDevice); - assertEquals(domain, subDevice.getPartitionAffinityDomain()); - } - } - - @Test - public void testSplitByAffinity_NUMA() { - checkSplitByAffinity(CLDevice.AffinityDomain.NUMA); - } - @Test - public void testSplitByAffinity_L4Cache() { - checkSplitByAffinity(CLDevice.AffinityDomain.L4Cache); - } - @Test - public void testSplitByAffinity_L3Cache() { - checkSplitByAffinity(CLDevice.AffinityDomain.L3Cache); - } - @Test - public void testSplitByAffinity_L2Cache() { - checkSplitByAffinity(CLDevice.AffinityDomain.L2Cache); - } - @Test - public void testSplitByAffinity_L1Cache() { - checkSplitByAffinity(CLDevice.AffinityDomain.L1Cache); - } - @Test - public void testSplitByAffinity_NextPartitionable() { - checkSplitByAffinity(CLDevice.AffinityDomain.NextPartitionable); - } - - private void checkParent(CLDevice parent, CLDevice child) { - assertSame(parent, child.getParent()); - // Force a get info CL_DEVICE_PARENT_DEVICE. - assertEquals(parent, new CLDevice(device.getPlatform(), null, child.getEntity(), false).getParent()); - } - -} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/EventTest.java b/Core/src/test/java/com/nativelibs4java/opencl/EventTest.java deleted file mode 100644 index 911ad8e1..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/EventTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.nativelibs4java.opencl; - -import java.util.Map; -import static org.junit.Assert.*; - -import org.junit.BeforeClass; -import org.junit.Test; - -import org.bridj.Pointer; -import static org.bridj.Pointer.*; -import java.util.List; -import org.junit.runners.Parameterized; - -@SuppressWarnings("unchecked") -public class EventTest extends AbstractCommon { - public EventTest(CLDevice device) { - super(device); - } - - @Parameterized.Parameters - public static List getDeviceParameters() { - return AbstractCommon.getDeviceParameters(); - } - - @Test - public void simpleTest() throws CLBuildException { - CLKernel kernel = context.createProgram( - "__kernel void copy(__global int* a, __global int* b) {\n" + - " int i = get_global_id(0);\n" + - " b[i]=a[i];\n" + - "} " - ).createKernel("copy"); - - CLBuffer - a = context.createBuffer(CLMem.Usage.Input, Integer.class, 4), - b = context.createBuffer(CLMem.Usage.Output, Integer.class, 4); - - kernel.setArgs(a, b); - - int[] globalSizes = new int[]{4}; - CLEvent e = kernel.enqueueNDRange(queue, globalSizes); - assertNotNull(e); - e.waitFor(); - assertNull(kernel.enqueueNDRange(queue, globalSizes, CLEvent.FIRE_AND_FORGET)); - } -} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/ImageTest.java b/Core/src/test/java/com/nativelibs4java/opencl/ImageTest.java index 4659e75f..1ee5cb1e 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/ImageTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/ImageTest.java @@ -1,28 +1,37 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + package com.nativelibs4java.opencl; -import org.bridj.Pointer; import com.nativelibs4java.opencl.CLImageFormat.ChannelDataType; import com.nativelibs4java.opencl.CLImageFormat.ChannelOrder; import static org.junit.Assert.*; import java.awt.image.BufferedImage; -import org.junit.*; +import java.nio.IntBuffer; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.nativelibs4java.test.MiscTestUtils; +import com.nativelibs4java.util.ImageUtils; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; import java.util.Arrays; import java.util.List; -import org.junit.runners.Parameterized; /** * * @author ochafik */ public class ImageTest extends AbstractCommon { - public ImageTest(CLDevice device) { - super(device); - } - - @Parameterized.Parameters - public static List getDeviceParameters() { - return AbstractCommon.getDeviceParameters(); + + @BeforeClass + public static void setup() { + MiscTestUtils.protectJNI(); } public boolean supportsImages() { @@ -103,23 +112,6 @@ public void testARGBShortGrayReadWrite() { assertSameImage(im, clim.read(queue)); } - @Test - public void testCopyTo() { - int width = 2, height = 2; - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - int value = 0xaabbccdd; - image.setRGB(0, 0, value); - image.setRGB(1, 1, value); - CLImage2D src = context.createImage2D(CLMem.Usage.InputOutput, image, true); - CLImage2D dest = context.createImage2D(CLMem.Usage.InputOutput, src.getFormat(), width, height); - CLEvent e = src.copyTo(queue, dest); - BufferedImage res = dest.read(queue, e); - assertEquals(value, res.getRGB(0, 0)); - assertEquals(0, res.getRGB(1, 0)); - assertEquals(value, res.getRGB(1, 1)); - assertEquals(0, res.getRGB(0, 1)); - } - @Test @@ -206,8 +198,9 @@ public void testRGBAImageSource() { //image.setRGB(i, height - 1, i); CLProgram program = context.createProgram(src).build(); - //CLBuffer cloutput = context.createBuffer(CLMem.Usage.Output, Integer.class, width * height * 4); - CLBuffer cloutput = context.createBuffer(CLMem.Usage.Output, Float.class, width * height * 4); + //CLIntBuffer cloutput = context.createIntBuffer(CLMem.Usage.Output, width * height * 4); + CLFloatBuffer cloutput = context.createFloatBuffer(CLMem.Usage.Output, width * height * 4); + CLKernel kernel = program.createKernel("test"); ChannelDataType channelDataType = CLImageFormat.INT_ARGB_FORMAT.getChannelDataType(); @@ -227,7 +220,7 @@ public void testRGBAImageSource() { //IntBuffer output = cloutput.read(queue); //IntBuffer output = cloutput.readBytes(queue, 0, width * height * 4 * 4).order(ByteOrder.BIG_ENDIAN).asIntBuffer(); - Pointer output = cloutput.read(queue); + FloatBuffer output = cloutput.read(queue); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int expected = image.getRGB(x, y); @@ -303,7 +296,7 @@ public void testRGBAImageSource() { public void testShortGrayImageSource() { if (!supportsImages()) return; - // try { + try { CLContext context = JavaCL.createBestContext(); CLQueue queue = context.createDefaultQueue(); String src = "\n" + @@ -341,7 +334,7 @@ public void testShortGrayImageSource() { image.getRaster().setDataElements(0, 0, width, height, data); CLProgram program = context.createProgram(src).build(); - CLBuffer cloutput = context.createBuffer(CLMem.Usage.Output, Float.class, width * height * 4); + CLFloatBuffer cloutput = context.createFloatBuffer(CLMem.Usage.Output, width * height * 4); CLKernel kernel = program.createKernel("test"); @@ -364,7 +357,7 @@ public void testShortGrayImageSource() { //IntBuffer output = cloutput.read(queue); //IntBuffer output = cloutput.readBytes(queue, 0, width * height * 4 * 4).order(ByteOrder.BIG_ENDIAN).asIntBuffer(); - Pointer output = cloutput.read(queue); + FloatBuffer output = cloutput.read(queue); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { float expected = 10f * (x + y) / (float)0xffff; @@ -394,29 +387,8 @@ public void testShortGrayImageSource() { } * */ - // } catch (Exception ex) { - // ex.printStackTrace(); - // } - } - - @Ignore - @Test - public void testFillImage() { - if (!supportsImages()) - return; - int width = 256, height = 256; - CLImage2D clim = context.createImage2D(CLMem.Usage.InputOutput, CLImageFormat.INT_ARGB_FORMAT, width, height); - - int red = 100, green = 110, blue = 120, alpha = 127; - int argb = alpha << 24 | red << 16 | green << 8 | blue; - CLEvent e = clim.fillImage(queue, new int[] { red, green, blue, alpha }); - BufferedImage im = clim.read(queue, e); - //int[] rgb = im.getRGB(0, 0, width, height, null, 0, width); - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - int pix = im.getRGB(x, y); - assertEquals("x = " + x + ", y = " + y, argb, pix); - } + } catch (Exception ex) { + ex.printStackTrace(); } - } -} + } +} \ No newline at end of file diff --git a/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java b/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java index 66fc54a8..2b4e51f9 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/InfoGettersTest.java @@ -4,23 +4,28 @@ */ package com.nativelibs4java.opencl; +import static com.nativelibs4java.test.MiscTestUtils.testGetters; import static org.junit.Assert.assertFalse; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Before; import org.junit.BeforeClass; +import com.nativelibs4java.test.MiscTestUtils; + /** * * @author ochafik */ public class InfoGettersTest { + + @BeforeClass + public static void setup() { + MiscTestUtils.protectJNI(); + } + @Before public void gc() { System.gc(); @@ -67,7 +72,7 @@ CLKernel createKernel() { CLEvent createEvent() { CLContext c = createContext(); - return c.createBuffer(CLMem.Usage.Input, Integer.class, 10).mapLater(c.createDefaultQueue(), CLMem.MapFlags.Read).getSecond(); + return c.createIntBuffer(CLMem.Usage.Input, 10).mapLater(c.createDefaultQueue(), CLMem.MapFlags.Read).getSecond(); } CLSampler createSampler() { @@ -92,8 +97,8 @@ public void CLKernelGetters() { @org.junit.Test public void CLMemGetters() { - testGetters(createContext().createBuffer(CLMem.Usage.Input, Byte.class, 10)); - testGetters(createContext().createBuffer(CLMem.Usage.Output, Byte.class, 10)); + testGetters(createContext().createByteBuffer(CLMem.Usage.Input, 10)); + testGetters(createContext().createByteBuffer(CLMem.Usage.Output, 10)); } @org.junit.Test @@ -125,45 +130,4 @@ public void CLEventGetters() { public void CLSamplerGetters() { testGetters(createSampler()); } - - public static void testGetters(Object instance) { - if (instance == null) - return; - Logger log = Logger.getLogger(instance.getClass().getName()); - for (Method m : instance.getClass().getDeclaredMethods()) { - if (Modifier.isStatic(m.getModifiers())) - continue; - if (!Modifier.isPublic(m.getModifiers())) - continue; - if (m.getParameterTypes().length != 0) - continue; - - String name = m.getName(); - if (name.contains("ProfilingCommand")) - continue; - - boolean isToString = name.equals("toString"); - if (name.startsWith("get") && name.length() > 3 || - name.startsWith("has") && name.length() > 3 || - name.startsWith("is") && name.length() > 2 || - isToString && !Modifier.isPublic(m.getDeclaringClass().getModifiers())) - { - String msg = "Failed to call " + m; - try { - m.invoke(instance); - } catch (IllegalAccessException ex) { - if (!isToString) - log.log(Level.WARNING, msg, ex); - } catch (InvocationTargetException ex) { - Throwable cause = ex.getCause(); - if (!(cause instanceof UnsupportedOperationException)) { - log.log(Level.SEVERE, msg, ex.getCause()); - assertFalse(msg, true); - } - } catch (Exception ex) { - log.log(Level.SEVERE, msg, ex); - } - } - } - } } diff --git a/Core/src/test/java/com/nativelibs4java/opencl/JOGLTest.java b/Core/src/test/java/com/nativelibs4java/opencl/JOGLTest.java index 94b52a61..101cf6ce 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/JOGLTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/JOGLTest.java @@ -4,7 +4,6 @@ */ package com.nativelibs4java.opencl; -import com.jogamp.opengl.util.FPSAnimator; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -24,16 +23,19 @@ import com.nativelibs4java.util.NIOUtils; import javax.media.opengl.*; -import javax.media.opengl.awt.*; import static javax.media.opengl.GL.*; import static javax.media.opengl.GL2.*; +import javax.media.opengl.awt.*; + import com.jogamp.opengl.util.*; import com.jogamp.common.nio.*; + +import com.sun.jna.Memory; +import com.sun.jna.PointerUtils; import java.nio.ByteOrder; -@org.junit.Ignore public class JOGLTest { @BeforeClass @@ -44,12 +46,7 @@ public static void initialise() { public GLCanvas createGLCanvas(int width, int height) { //GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - caps.setHardwareAccelerated(true); - caps.setDoubleBuffered(true); - GLCanvas glCanvas = new GLCanvas(caps);//new GLCapabilities(GLProfile.get(GLProfile.GL))); - //GLCapabilitiesImmutable icaps = glCanvas.getChosenGLCapabilities(); - //boolean hwa = icaps.getHardwareAccelerated(); + GLCanvas glCanvas = new GLCanvas();//new GLCapabilities(GLProfile.get(GLProfile.GL))); glCanvas.setSize( width, height ); glCanvas.setIgnoreRepaint( true ); @@ -81,7 +78,7 @@ public void init(GLAutoDrawable drawable) { //int glcontext = gl.glGet.getContext().CONTEXT_CURRENT; CLQueue queue = context.createDefaultQueue(); - System.err.println("Initializing with OpenCL context = " + context + "..."); + System.err.println("Initializing..."); int bufferSize = 1024; FloatBuffer buffer; int[] VBO = new int[1]; @@ -101,18 +98,8 @@ public void init(GLAutoDrawable drawable) { gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); int width = 2, height = 2, border = 0; - //int width = 4, height = 4, border = 0; byte bZero = (byte)0, bMin1 = (byte)0xFF; ByteBuffer texData = NIOUtils.directCopy(ByteBuffer.wrap(new byte[] { - bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, - bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, - - bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, - bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, - - bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, - bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, - bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1, bMin1,bMin1,bMin1,bMin1 }), queue.getDevice().getByteOrder()); @@ -127,14 +114,13 @@ public void init(GLAutoDrawable drawable) { //GL.GL_RGBA, GL2.GL_UNSIGNED_INT_8_8_8_8, texData ); - + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); gl.glBindTexture(GL2.GL_TEXTURE_2D, 0); gl.glFlush(); - //gl.glFinish(); - CLBuffer clbuf = context.createBufferFromGLBuffer(CLMem.Usage.Input, VBO[0]).as(Float.class); + CLFloatBuffer clbuf = context.createBufferFromGLBuffer(CLMem.Usage.Input, VBO[0]).asCLFloatBuffer(); CLImage2D climg = context.createImage2DFromGLTexture2D(CLMem.Usage.InputOutput, CLContext.GLTextureTarget.Texture2D, Texture[0], 0); assertNotNull(clbuf); diff --git a/Core/src/test/java/com/nativelibs4java/opencl/KernelTest.java b/Core/src/test/java/com/nativelibs4java/opencl/KernelTest.java deleted file mode 100644 index af3c8064..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/KernelTest.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.nativelibs4java.opencl; - -import com.nativelibs4java.opencl.CLMem.Usage; -import java.lang.reflect.Array; -import static org.junit.Assert.*; -import org.bridj.*; -import static org.bridj.Pointer.*; - -import org.junit.*; - -public class KernelTest { - - CLContext context; - CLQueue queue; - - @Before - public void setup() { - context = JavaCL.createBestContext(CLPlatform.DeviceFeature.CPU); - queue = context.createDefaultQueue(); - } - - public Pointer testArg(String type, Object value, Class targetType) { - long size = BridJ.sizeOf(targetType); - CLBuffer out = context.createByteBuffer(Usage.Output, size) ; - CLKernel k = context.createProgram( -// "#if __OPENCL_VERSION__ <= CL_VERSION_1_1\n" + - " #pragma OPENCL EXTENSION cl_khr_fp64 : enable\n" + -// "#endif\n" + - "kernel void f(" + type + " arg, global " + type + "* out, long size) {\n" + - "char* in = (char*) &arg;\n" + - "for (long i = 0; i < size; i++) {\n" + - "out[i] = in[i];\n" + - "}\n" + - "}" - ).createKernel("f", value, out, size); - CLEvent e = k.enqueueTask(queue); - return out.as(targetType).read(queue, e); - } - - public Object testArrayArg(String type, Object array, Class targetType) { - long size = BridJ.sizeOf(targetType); - long length = Array.getLength(array); - CLBuffer out = context.createByteBuffer(Usage.Output, size * length); - StringBuilder b = new StringBuilder( - "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n" + - "kernel void f(" + type + length + " arg, global " + type + "* out, long length) {\n"); - for (long i = 0; i < length; i++) { - b.append("out[" + i + "] = arg.s" + (i < 10 ? i + "" : ((char)((int)'a' + (i - 10))) + "") + ";\n"); - } - b.append("}\n"); - System.out.println(b); - CLKernel k = context.createProgram(b.toString()).createKernel("f", array, out, length); - CLEvent e = k.enqueueTask(queue); - return out.as(targetType).read(queue, e).getArray(); - } - - @Test - public void nullArg() { - CLBuffer out = context.createByteBuffer(Usage.InputOutput, 2) ; - CLKernel isInputNull = context.createProgram( - "kernel void isInputNull(global int* in, global bool* out) {\n" + - "*out = !in;\n" + - "}" - ).createKernel("isInputNull"); - - isInputNull.setArgs(CLKernel.NULL_POINTER_KERNEL_ARGUMENT, out); - assertTrue(out.read(queue, isInputNull.enqueueTask(queue)).as(Boolean.class).get()); - - isInputNull.setArgs(out, out); - assertFalse(out.read(queue, isInputNull.enqueueTask(queue)).as(Boolean.class).get()); - } - - byte[] byteTup(int n) { - byte[] a = new byte[n]; - for (int i = 0; i < n; i++) a[i] = (byte)(i + 1); - return a; - } - @Test - public void byteArg() { - assertArrayEquals(new byte[] { 2 }, testArg("char", (byte) 2, byte.class).getBytes()); - for (byte[] tup : new byte[][] { byteTup(2), byteTup(3), byteTup(4), byteTup(8), byteTup(16) }) { - assertArrayEquals(tup, (byte[]) testArrayArg("char", tup, byte.class)); - } - } - - short[] shortTup(int n) { - short[] a = new short[n]; - for (int i = 0; i < n; i++) a[i] = (short)(i + 1); - return a; - } - @Test - public void shortArg() { - assertArrayEquals(new short[] { 2 }, testArg("short", (short) 2, short.class).getShorts()); - for (short[] tup : new short[][] { shortTup(2), shortTup(3), shortTup(4), shortTup(8), shortTup(16) }) { - assertArrayEquals(tup, (short[]) testArrayArg("short", tup, short.class)); - } - } - - int[] intTup(int n) { - int[] a = new int[n]; - for (int i = 0; i < n; i++) a[i] = i + 1; - return a; - } - @Test - public void intArg() { - assertArrayEquals(new int[] { 2 }, testArg("int", (int) 2, int.class).getInts()); - for (int[] tup : new int[][] { intTup(2), intTup(3), intTup(4), intTup(8), intTup(16) }) { - assertArrayEquals(tup, (int[]) testArrayArg("int", tup, int.class)); - } - } - - long[] longTup(int n) { - long[] a = new long[n]; - for (int i = 0; i < n; i++) a[i] = i + 1; - return a; - } - @Test - public void longArg() { - assertArrayEquals(new long[] { 2 }, testArg("long", (long) 2, long.class).getLongs()); - for (long[] tup : new long[][] { longTup(2), longTup(3), longTup(4), longTup(8), longTup(16) }) { - assertArrayEquals(tup, (long[]) testArrayArg("long", tup, long.class)); - } - } - - float[] floatTup(int n) { - float[] a = new float[n]; - for (int i = 0; i < n; i++) a[i] = i + 1; - return a; - } - @Ignore - @Test - public void floatArg() { - assertArrayEquals(new float[] { 2f }, testArg("float", (float) 4, float.class).getFloats(), 0); - for (float[] tup : new float[][] { floatTup(2), floatTup(3), floatTup(4), floatTup(8), floatTup(16) }) { - assertArrayEquals(tup, (float[]) testArrayArg("float", tup, float.class), 0); - } - } - - double[] doubleTup(int n) { - double[] a = new double[n]; - for (int i = 0; i < n; i++) a[i] = i + 1; - return a; - } - @Ignore - @Test - public void doubleArg() { - assertArrayEquals(new double[] { 2d }, testArg("double", (double) 8, double.class).getDoubles(), 0); - for (double[] tup : new double[][] { doubleTup(2), doubleTup(3), doubleTup(4), doubleTup(8), doubleTup(16) }) { - assertArrayEquals(tup, (double[]) testArrayArg("double", tup, double.class), 0); - } - } -// void assertArrayEquals(Object exp, Object act) { -// assertEquals(Arrays) -// } -} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java index 4af2e925..788b45c5 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBasicTest.java @@ -4,20 +4,24 @@ import static com.nativelibs4java.opencl.JavaCL.createBestContext; import static com.nativelibs4java.util.NIOUtils.directFloats; import static org.junit.Assert.assertEquals; -import org.bridj.*; -import static org.bridj.Pointer.*; import java.nio.FloatBuffer; import org.junit.BeforeClass; import org.junit.Test; +import com.nativelibs4java.test.MiscTestUtils; import com.nativelibs4java.util.NIOUtils; public class OpenCL4JavaBasicTest { - public static final double ABSOLUTE_FLOAT_ERROR_TOLERANCE = 2e-4; - public static final double RELATIVE_FLOAT_ERROR_TOLERANCE = 5e-8; + public static final double ABSOLUTE_FLOAT_ERROR_TOLERANCE = 1e-4; + public static final double RELATIVE_FLOAT_ERROR_TOLERANCE = 1e-8; + + @BeforeClass + public static void setup() { + MiscTestUtils.protectJNI(); + } @Test public void simpleTest() { @@ -40,19 +44,18 @@ public void simpleTest() { CLQueue queue = context.createDefaultQueue(); /// Create direct NIO buffers and fill them with data in the correct byte order - Pointer a = allocateFloats(dataSize).order(context.getKernelsDefaultByteOrder()); - Pointer b = allocateFloats(dataSize).order(context.getKernelsDefaultByteOrder()); + FloatBuffer a = NIOUtils.directFloats(dataSize, context.getKernelsDefaultByteOrder()); + FloatBuffer b = NIOUtils.directFloats(dataSize, context.getKernelsDefaultByteOrder()); for (int i = 0; i < dataSize; i++) { - float value = (float)i; - a.set(i, value); - b.set(i, value); + a.put(i, i); + b.put(i, i); } // Allocate OpenCL-hosted memory for inputs and output, // with inputs initialized as copies of the NIO buffers - CLBuffer memIn1 = context.createBuffer(CLMem.Usage.Input, a, true); // 'true' : copy provided data - CLBuffer memIn2 = context.createBuffer(CLMem.Usage.Input, b, true); - CLBuffer memOut = context.createBuffer(CLMem.Usage.Output, Float.class, dataSize); + CLFloatBuffer memIn1 = context.createFloatBuffer(CLMem.Usage.Input, a, true); // 'true' : copy provided data + CLFloatBuffer memIn2 = context.createFloatBuffer(CLMem.Usage.Input, b, true); + CLFloatBuffer memOut = context.createFloatBuffer(CLMem.Usage.Output, dataSize); // Bind these memory objects to the arguments of the kernel kernel.setArgs(memIn1, memIn2, memOut); @@ -65,7 +68,7 @@ public void simpleTest() { queue.finish(); // Copy the OpenCL-hosted array back to RAM - Pointer output = memOut.read(queue); + FloatBuffer output = memOut.read(queue); // Compute absolute and relative average errors wrt Java implem double totalAbsoluteError = 0, totalRelativeError = 0; diff --git a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java index d2ff6ce0..20688c26 100644 --- a/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java +++ b/Core/src/test/java/com/nativelibs4java/opencl/OpenCL4JavaBenchmarkTest.java @@ -1,27 +1,31 @@ package com.nativelibs4java.opencl; import static com.nativelibs4java.opencl.CLTestUtils.avgError; -import static com.nativelibs4java.opencl.CLTestUtils.fillBuffersWithSomeDatad; -import static com.nativelibs4java.opencl.CLTestUtils.fillBuffersWithSomeDataf; +import static com.nativelibs4java.opencl.CLTestUtils.fillBuffersWithSomeData; import static com.nativelibs4java.test.BenchmarkUtils.gc; import static com.nativelibs4java.util.NIOUtils.directBytes; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; -import java.util.Arrays; - -import java.nio.FloatBuffer; +import java.nio.ByteBuffer; import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.util.Arrays; import org.junit.BeforeClass; import org.junit.Test; import com.nativelibs4java.opencl.CLTestUtils.Action2; import com.nativelibs4java.opencl.CLTestUtils.ExecResult; +import com.nativelibs4java.test.MiscTestUtils; //import com.nativelibs4java.scalacl.*; /// @see http://ati.amd.com/technology/streamcomputing/intro_opencl.html#simple public class OpenCL4JavaBenchmarkTest { + + @BeforeClass + public static void setup() { + MiscTestUtils.protectJNI(); + } + static final boolean warmup = true; static ExecResult testJava_float_aSinB(int loops, int dataSize) throws CLBuildException { @@ -39,7 +43,7 @@ static ExecResult testJava_float_aSinB(int loops, int dataSize) thr System.out.println(); } - fillBuffersWithSomeDataf(aBuffer, bBuffer); + fillBuffersWithSomeData(aBuffer, bBuffer); gc(); long start = System.nanoTime(); @@ -66,7 +70,7 @@ static ExecResult testJava_double_aSinB(int loops, int dataSize) t System.out.println(); } - fillBuffersWithSomeDatad(aBuffer, bBuffer); + fillBuffersWithSomeData(aBuffer, bBuffer); gc(); long start = System.nanoTime(); @@ -78,47 +82,47 @@ static ExecResult testJava_double_aSinB(int loops, int dataSize) t return new ExecResult(outputBuffer, time / (loops * (double) dataSize)); } - static ExecResult> testOpenCL_float_aSinB(CLContext context, int loops, int dataSize, boolean hostInOpenCL) throws CLBuildException { + static ExecResult testOpenCL_float_aSinB(CLContext context, int loops, int dataSize, boolean hostInOpenCL) throws CLBuildException { - ExecResult> er = testOpenCL_aSinB(context, Prim.Float, loops, dataSize, hostInOpenCL, new Action2, Pointer>() { + ExecResult er = testOpenCL_aSinB(context, Prim.Float, loops, dataSize, hostInOpenCL, new Action2() { - public void call(Pointer a, Pointer b) { - fillBuffersWithSomeDataf(a.as(Float.class), b.as(Float.class)); + public void call(ByteBuffer a, ByteBuffer b) { + fillBuffersWithSomeData(a.asFloatBuffer(), b.asFloatBuffer()); } }); - return new ExecResult>(er.buffer.as(Float.class), er.unitTimeNano); + return new ExecResult(er.buffer.asFloatBuffer(), er.unitTimeNano); } - static ExecResult> testOpenCL_double_aSinB(CLContext context, int loops, int dataSize, boolean hostInOpenCL) throws CLBuildException { + static ExecResult testOpenCL_double_aSinB(CLContext context, int loops, int dataSize, boolean hostInOpenCL) throws CLBuildException { - ExecResult> er = testOpenCL_aSinB(context, Prim.Double, loops, dataSize, hostInOpenCL, new Action2, Pointer>() { + ExecResult er = testOpenCL_aSinB(context, Prim.Double, loops, dataSize, hostInOpenCL, new Action2() { - public void call(Pointer a, Pointer b) { - fillBuffersWithSomeDatad(a.as(Double.class), b.as(Double.class)); + public void call(ByteBuffer a, ByteBuffer b) { + fillBuffersWithSomeData(a.asDoubleBuffer(), b.asDoubleBuffer()); } }); - return new ExecResult>(er.buffer.as(Double.class), er.unitTimeNano); + return new ExecResult(er.buffer.asDoubleBuffer(), er.unitTimeNano); } - static ExecResult> testOpenCL_aSinB(CLContext context, Prim nativePrim, int loops, int dataSize, boolean hostInOpenCL, Action2, Pointer> fillBuffersWithSomeData) throws CLBuildException { + static ExecResult testOpenCL_aSinB(CLContext context, Prim nativePrim, int loops, int dataSize, boolean hostInOpenCL, Action2 fillBuffersWithSomeData) throws CLBuildException { CLKernel kernel = setupASinB(nativePrim, context); CLQueue queue = context.createDefaultQueue(); - Pointer input1 = null, input2 = null, output = null; - CLBuffer memIn1, memIn2, memOut; + ByteBuffer input1 = null, input2 = null, output = null; + CLByteBuffer memIn1, memIn2, memOut; if (hostInOpenCL) { - memIn1 = kernel.program.context.createBuffer(CLMem.Usage.Input, Byte.class, dataSize * nativePrim.sizeof()); - memIn2 = kernel.program.context.createBuffer(CLMem.Usage.Input, Byte.class, dataSize * nativePrim.sizeof()); - memOut = kernel.program.context.createBuffer(CLMem.Usage.Output, Byte.class, dataSize * nativePrim.sizeof()); + memIn1 = kernel.program.context.createByteBuffer(CLMem.Usage.Input, dataSize * nativePrim.sizeof()); + memIn2 = kernel.program.context.createByteBuffer(CLMem.Usage.Input, dataSize * nativePrim.sizeof()); + memOut = kernel.program.context.createByteBuffer(CLMem.Usage.Output, dataSize * nativePrim.sizeof()); } else { - input1 = allocateBytes(dataSize * nativePrim.sizeof()).order(context.getByteOrder()); - input2 = allocateBytes(dataSize * nativePrim.sizeof()).order(context.getByteOrder()); - output = allocateBytes(dataSize * nativePrim.sizeof()).order(context.getByteOrder()); + input1 = directBytes(dataSize * nativePrim.sizeof(), context.getByteOrder()); + input2 = directBytes(dataSize * nativePrim.sizeof(), context.getByteOrder()); + output = directBytes(dataSize * nativePrim.sizeof(), context.getByteOrder()); - memIn1 = kernel.program.context.createBuffer(CLMem.Usage.Input, input1, false); - memIn2 = kernel.program.context.createBuffer(CLMem.Usage.Input, input2, false); - memOut = kernel.program.context.createBuffer(CLMem.Usage.Output, output, false); + memIn1 = kernel.program.context.createByteBuffer(CLMem.Usage.Input, input1, false); + memIn2 = kernel.program.context.createByteBuffer(CLMem.Usage.Input, input2, false); + memOut = kernel.program.context.createByteBuffer(CLMem.Usage.Output, output, false); } kernel.setArgs(memIn1, memIn2, memOut); @@ -157,14 +161,15 @@ static ExecResult> testOpenCL_aSinB(CLContext context, Prim native if (hostInOpenCL) { // Copy the OpenCL-hosted array back to RAM output = memOut.map(queue, CLMem.MapFlags.Read); - // System.out.println("memOut.map = " + Long.toHexString(output.getPeer())); //queue.finish(); - Pointer b = allocateBytes(dataSize * nativePrim.sizeof()).order(context.getByteOrder()); - output.copyTo(b, dataSize); + ByteBuffer b = directBytes(dataSize * nativePrim.sizeof(), context.getByteOrder()); + b.put(output); + output.rewind(); + b.rewind(); memOut.unmap(queue, output); output = b; } - return new ExecResult>(output, time / (loops * (double) dataSize)); + return new ExecResult(output, time / (loops * (double) dataSize)); } static CLKernel setupASinB(Prim nativeType, CLContext context) throws CLBuildException { @@ -253,8 +258,8 @@ public void testBenchmark() { } else { System.out.println("#\n# [Double Operations]\n#"); ExecResult nsByJavaOp = testJava_double_aSinB(loops, dataSize); - ExecResult> nsByCLHostedOp = testOpenCL_double_aSinB(context, loops, dataSize, true); - ExecResult> nsByNativeHostedCLOp = testOpenCL_double_aSinB(context, loops, dataSize, false); + ExecResult nsByCLHostedOp = testOpenCL_double_aSinB(context, loops, dataSize, true); + ExecResult nsByNativeHostedCLOp = testOpenCL_double_aSinB(context, loops, dataSize, false); double errCLHosted = avgError(nsByJavaOp.buffer, nsByCLHostedOp.buffer, dataSize); double errNativeHosted = avgError(nsByJavaOp.buffer, nsByNativeHostedCLOp.buffer, dataSize); @@ -276,8 +281,8 @@ public void testBenchmark() { if (true) { System.out.println("#\n# [Float Operations]\n#"); ExecResult nsByJavaOp = testJava_float_aSinB(loops, dataSize); - ExecResult> nsByCLHostedOp = testOpenCL_float_aSinB(context, loops, dataSize, true); - ExecResult> nsByNativeHostedCLOp = testOpenCL_float_aSinB(context, loops, dataSize, false); + ExecResult nsByCLHostedOp = testOpenCL_float_aSinB(context, loops, dataSize, true); + ExecResult nsByNativeHostedCLOp = testOpenCL_float_aSinB(context, loops, dataSize, false); double errCLHosted = avgError(nsByJavaOp.buffer, nsByCLHostedOp.buffer, dataSize); double errNativeHosted = avgError(nsByJavaOp.buffer, nsByNativeHostedCLOp.buffer, dataSize); diff --git a/Core/src/test/java/com/nativelibs4java/opencl/OverheadTest.java b/Core/src/test/java/com/nativelibs4java/opencl/OverheadTest.java deleted file mode 100644 index 65f1fdf5..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/OverheadTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl; - -import com.nativelibs4java.opencl.library.*; -import java.util.Map; -import static org.junit.Assert.*; - -import org.junit.*; - -import org.bridj.Pointer; -import org.bridj.Platform; -import static org.bridj.Pointer.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -import java.nio.ByteBuffer; -import java.util.List; -import org.junit.runners.Parameterized; -/** - * - * @author Kazo Csaba - */ -@Ignore -@SuppressWarnings("unchecked") -public class OverheadTest extends AbstractCommon { - public OverheadTest(CLDevice device) { - super(device); - } - - @Parameterized.Parameters - public static List getDeviceParameters() { - return AbstractCommon.getDeviceParameters(); - } - static void gc() { - try { - System.gc(); - Thread.sleep(100); - System.gc(); - Thread.sleep(100); - } catch (InterruptedException ex) {} - } - static long time(String title, int n, Runnable payload, Runnable finalizer) { - gc(); - - long start = System.nanoTime(); - for (int i = 0; i < n; i++) { - payload.run(); - } - if (finalizer != null) - finalizer.run(); - long timeMillis = (System.nanoTime() - start) / 1000000; - - if (title != null) - System.out.println("Time[ " + title + " ; n = " + n + "] = " + timeMillis + " ms"); - return timeMillis; - } - @Test - public void compareVariousSetArgsPerformance() throws CLBuildException { - if (!context.getCacheBinaries()) { - System.out.println("Skipping binaries caching test"); - return; - } - CLProgram program = context.createProgram( - "__kernel void copy(__global int* a, __global int* b, short s, int i, char c, float f) {\n" + - " int idx = get_global_id(0);\n" + - " b[idx] = a[idx];\n" + - "} "); - - - program.build(); - final CLKernel kernel = program.createKernel("copy"); - - final CLBuffer a=context.createBuffer(CLMem.Usage.Input, Integer.class, 4); - final CLBuffer b=context.createBuffer(CLMem.Usage.Output, Integer.class, 4); - - int nArgs = kernel.getNumArgs(); - - Runnable setWithSetArgs = new Runnable() { public void run() { - kernel.setArgs(a, b, (short)1, 1, (byte)1, 1.0f); - }}; - Runnable setWithSpecializedSetArg = new Runnable() { public void run() { - kernel.setArg(0, a); - kernel.setArg(1, b); - kernel.setArg(2, (short)1); - kernel.setArg(3, 1); - kernel.setArg(4, (byte)1); - kernel.setArg(5, 1.0f); - }}; - /* - Runnable setWithCLAPI = new Runnable() { - private final OpenCLLibrary CL = new OpenCLLibrary(); - private final Pointer tmp = allocateBytes(8); - public void run() { - CL.clSetKernelArg(kernel.getEntity(), 0, Pointer.SIZE, a.getEntity()); - CL.clSetKernelArg(kernel.getEntity(), 1, Pointer.SIZE, b.getEntity()); - CL.clSetKernelArg(kernel.getEntity(), 2, 2L, tmp.setShort((short)1)); - CL.clSetKernelArg(kernel.getEntity(), 3, 4L, tmp.setInt(1)); - CL.clSetKernelArg(kernel.getEntity(), 4, 1L, tmp.setByte((byte)1)); - CL.clSetKernelArg(kernel.getEntity(), 5, 4L, tmp.setFloat(1)); - } - }; - */ - Runnable setWithRawCLAPI = new Runnable() { - private final long aPeer = a.getEntity(); - private final long bPeer = b.getEntity(); - private final long kEntity = kernel.getEntity(); - private final Pointer tmp = allocateBytes(8);//.withoutValidityInformation(); - private final ByteBuffer tmpBuf = tmp.getByteBuffer(); - private final long tPeer = getPeer(tmp); - private final long pointerSize = Pointer.SIZE; - private final OpenCLLibrary CL = new OpenCLLibrary(); - public void run() { - CL.clSetKernelArg(kEntity, 0, pointerSize, aPeer); - CL.clSetKernelArg(kEntity, 1, pointerSize, bPeer); - tmpBuf.putShort(0, (short)1); - CL.clSetKernelArg(kEntity, 2, 2L, tPeer); - tmpBuf.putInt(0, 1); - CL.clSetKernelArg(kEntity, 3, 4L, tPeer); - tmpBuf.put(0, (byte)1); - CL.clSetKernelArg(kEntity, 4, 1L, tPeer); - tmpBuf.putFloat(0, 1); - CL.clSetKernelArg(kEntity, 5, 4L, tPeer); - } - }; - - int nWarmup = 8000, nTest = 50000; - //time(null, nWarmup, setWithCLAPI, null); - time(null, nWarmup, setWithSetArgs, null); - time(null, nWarmup, setWithSpecializedSetArg, null); - time(null, nWarmup, setWithRawCLAPI, null); - - int nSamples = 10; - double totSetArgs = 0, totCLSetKernelArg = 0, totSetArg = 0, totCLSetKernelArgRaw = 0; - for (int i = 0; i < nSamples; i++) { - //totCLSetKernelArg += time("clSetKernelArg pointers", nTest, setWithCLAPI, null); - totSetArgs += time("CLKernel.setArgs", nTest, setWithSetArgs, null); - totSetArg += time("CLKernel.setArg", nTest, setWithSpecializedSetArg, null); - totCLSetKernelArgRaw += time("clSetKernelArg raw", nTest, setWithRawCLAPI, null); - System.out.println(); - } - - final double maxSlower = 1.4; - double slowerSetArg = totSetArg / totCLSetKernelArgRaw; - double slowerSetArgs = totSetArgs / totCLSetKernelArgRaw; - - System.out.println("CLKernel.setArg is " + slowerSetArg + "x slower than hand-optimized."); - System.out.println("CLKernel.setArgs is " + slowerSetArgs + "x slower than hand-optimized."); - final double maxMilliSecondsPerCall = Platform.is64Bits() ? 0.0025 : 0.007; - double setArgAvg = (totSetArg / (double)nTest) / nArgs; - System.out.println("CLKernel.setArg took " + setArgAvg + " ms per call in average."); - - assertTrue("CLKernel.setArg was supposed to last at most " + maxMilliSecondsPerCall + " ms in average, but was " + setArgAvg + " ms", setArgAvg < maxMilliSecondsPerCall); - assertTrue("CLKernel.setArg was supposed not to be more than " + maxSlower + "x slower than hand-optimized version, was " + slowerSetArg + "x slower.", slowerSetArg <= maxSlower); - assertTrue("CLKernel.setArgs was supposed not to be more than " + maxSlower + "x slower than hand-optimized version, was " + slowerSetArgs + "x slower.", slowerSetArgs <= maxSlower); - } -} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/StressTest.java b/Core/src/test/java/com/nativelibs4java/opencl/StressTest.java deleted file mode 100644 index 386f6462..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/StressTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl; - -import org.bridj.Pointer; -//import org.junit.Test; - -/** - - -javac -d target/classes -cp target/javacl-core-1.0-SNAPSHOT.jar:/Users/ochafik/.m2/repository/com/nativelibs4java/ochafik-util/0.12-SNAPSHOT/ochafik-util-0.12-SNAPSHOT.jar:/Users/ochafik/.m2/repository/com/nativelibs4java/opencl4java/1.0-SNAPSHOT/opencl4java-1.0-SNAPSHOT.jar:/Users/ochafik/.m2/repository/com/nativelibs4java/bridj/0.7-SNAPSHOT/bridj-0.7-SNAPSHOT.jar src/test/java/com/nativelibs4java/opencl/StressTest.java && java -cp target/classes:target/javacl-core-1.0-SNAPSHOT.jar:/Users/ochafik/.m2/repository/com/nativelibs4java/nativelibs4java-utils/1.6-SNAPSHOT/nativelibs4java-utils-1.6-SNAPSHOT.jar:/Users/ochafik/.m2/repository/com/nativelibs4java/ochafik-util/0.12-SNAPSHOT/ochafik-util-0.12-SNAPSHOT.jar:/Users/ochafik/.m2/repository/com/nativelibs4java/opencl4java/1.0-SNAPSHOT/opencl4java-1.0-SNAPSHOT.jar:/Users/ochafik/.m2/repository/com/nativelibs4java/bridj/0.7-SNAPSHOT/bridj-0.7-SNAPSHOT.jar com.nativelibs4java.opencl.StressTest - - -*/ -public class StressTest { - // @Test - public static void main(String[] args) { - CLContext context = JavaCL.createBestContext(CLPlatform.DeviceFeature.GPU); - System.out.println(context); - int n = 128;// * 128; -// Pointer p = Pointer.allocateInts(n); - for (int i = 0; i < 100000; i++) { -// if ((i & 0xff) == 0xff) - System.out.print("."); - CLQueue queue = context.createDefaultQueue(); - CLBuffer buffer = context.createByteBuffer(CLMem.Usage.Output, 4 * n).as(Integer.class);//p); - CLProgram program = context.createProgram("kernel void f(global int* input, int n) {\n" + - "int i = get_global_id(0);\n" + - "if (i >= n) return;\n" + - "input[i] = i;\n" + - "}"); - CLKernel kernel = program.createKernel("f"); - - for (int j = 0; j < 100; j++) { - kernel.setArgs(buffer, n); - kernel.enqueueNDRange(queue, new int[] { n }); - } - queue.finish(); - queue.release(); - kernel.release(); - program.release(); - buffer.release(); - } - context.release(); - } -} diff --git a/Core/src/test/java/com/nativelibs4java/opencl/SweatTest.java b/Core/src/test/java/com/nativelibs4java/opencl/SweatTest.java deleted file mode 100644 index 5d79ae4f..00000000 --- a/Core/src/test/java/com/nativelibs4java/opencl/SweatTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.nativelibs4java.opencl; - -import org.junit.Test; - -public class SweatTest { - static { - System.setProperty("bridj.debug.pointer.releases", "true"); - } - @Test - public void sweatTest() { - long tot = 0; - for (boolean cached : new boolean[] { false, true }) { - for (int time = 0; time < 100; time++) { - CLContext context = JavaCL.createBestContext(CLPlatform.DeviceFeature.GPU); - CLQueue queue = context.createDefaultQueue(); - CLProgram program = context.createProgram("kernel void f(global int* a) { a[0] = 1; }"); - program.setCached(cached); - program.build(); - CLKernel kernel = program.createKernel("f"); - kernel.release(); - program.release(); - queue.release(); - context.release(); - System.gc(); - } - } - System.out.println(tot); - } -} \ No newline at end of file diff --git a/Core/src/test/java/com/nativelibs4java/test/MiscTestUtils.java b/Core/src/test/java/com/nativelibs4java/test/MiscTestUtils.java new file mode 100644 index 00000000..b12efc84 --- /dev/null +++ b/Core/src/test/java/com/nativelibs4java/test/MiscTestUtils.java @@ -0,0 +1,66 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.nativelibs4java.test; + +import static org.junit.Assert.assertFalse; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.sun.jna.Native; + +/** + * + * @author ochafik + */ +public class MiscTestUtils { + public static void protectJNI() { + Native.setProtected(true); + } + public static void testGetters(Object instance) { + if (instance == null) + return; + Logger log = Logger.getLogger(instance.getClass().getName()); + for (Method m : instance.getClass().getDeclaredMethods()) { + if (Modifier.isStatic(m.getModifiers())) + continue; + if (!Modifier.isPublic(m.getModifiers())) + continue; + if (m.getParameterTypes().length != 0) + continue; + + String name = m.getName(); + if (name.contains("ProfilingCommand")) + continue; + + boolean isToString = name.equals("toString"); + if (name.startsWith("get") && name.length() > 3 || + name.startsWith("has") && name.length() > 3 || + name.startsWith("is") && name.length() > 2 || + isToString && !Modifier.isPublic(m.getDeclaringClass().getModifiers())) + { + String msg = "Failed to call " + m; + try { + m.invoke(instance); + } catch (IllegalAccessException ex) { + if (!isToString) + log.log(Level.WARNING, msg, ex); + } catch (InvocationTargetException ex) { + Throwable cause = ex.getCause(); + if (!(cause instanceof UnsupportedOperationException)) { + log.log(Level.SEVERE, msg, ex.getCause()); + assertFalse(msg, true); + } + } catch (Exception ex) { + log.log(Level.SEVERE, msg, ex); + } + } + } + } +} diff --git a/Demos/javacl-demos-bridj.iml b/Demos/javacl-demos-bridj.iml deleted file mode 100644 index baf0eab7..00000000 --- a/Demos/javacl-demos-bridj.iml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demos/javacl-demos.iml b/Demos/javacl-demos.iml deleted file mode 100644 index 78c89b1d..00000000 --- a/Demos/javacl-demos.iml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demos/pom.xml b/Demos/pom.xml index 35a18146..f4ad4016 100644 --- a/Demos/pom.xml +++ b/Demos/pom.xml @@ -3,30 +3,27 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.nativelibs4java - javacl-demos - JavaCL Demos / BridJ + javacl-demos-jna + JavaCL Demos / JNA http://code.google.com/p/javacl/ + 1.0.0-RC4 jar com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT + javacl-parent-jna + 1.0.0-RC4 .. - - true - com.nativelibs4java.opencl.demos.hardware.HardwareReport - - com.nativelibs4java - javacl + javacl-jna + org.swinglabs swing-layout @@ -39,23 +36,16 @@ com.nativelibs4java - maven-javacl-plugin - - - org.apache.maven.plugins - maven-shade-plugin - - - full-package - package - - shade - - - ${shadedArtifactAttached} - - - + javacl-generator-jna + + + + compile + + + + + diff --git a/Demos/src/main/java/com/nativelibs4java/opencl/demos/SetupUtils.java b/Demos/src/main/java/com/nativelibs4java/opencl/demos/SetupUtils.java index 19f71be4..7a57ea1b 100644 --- a/Demos/src/main/java/com/nativelibs4java/opencl/demos/SetupUtils.java +++ b/Demos/src/main/java/com/nativelibs4java/opencl/demos/SetupUtils.java @@ -5,11 +5,6 @@ package com.nativelibs4java.opencl.demos; -import java.net.MalformedURLException; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bridj.BridJ; -import org.bridj.JNI; import java.io.PrintWriter; import java.io.StringWriter; import java.net.URL; @@ -23,7 +18,8 @@ import javax.swing.border.TitledBorder; import com.nativelibs4java.opencl.JavaCL; -import org.bridj.Platform; +import com.ochafik.util.SystemUtils; +import com.sun.jna.Platform; /** * @@ -31,32 +27,16 @@ */ public class SetupUtils { - public enum DownloadURL { - ATI("http://developer.amd.com/tools-and-sdks/opencl-zone/amd-accelerated-parallel-processing-app-sdk"), - NVidia("http://www.nvidia.com/Download/Find.aspx"); - - public final URL url; - DownloadURL(String s) { - URL url; - try { - url = new URL(s); - } catch (MalformedURLException ex) { - Logger.getLogger(SetupUtils.class.getName()).log(Level.SEVERE, null, ex); - url = null; - } - this.url = url; - } - } public static void failWithDownloadProposalsIfOpenCLNotAvailable() { ///* try { JavaCL.listPlatforms(); return; - } catch (Throwable ex) { + } catch (UnsatisfiedLinkError ex) { ex.printStackTrace(); } //*/ String title = "JavaCL Error: OpenCL library not found"; - if (Platform.isMacOSX()) { + if (Platform.isMac()) { JOptionPane.showMessageDialog(null, "Please upgrade Mac OS X to Snow Leopard (10.6) to be able to use OpenCL.", title, JOptionPane.ERROR_MESSAGE); return; } @@ -71,29 +51,29 @@ public static void failWithDownloadProposalsIfOpenCLNotAvailable() { "You don't appear to have an OpenCL implementation properly configured.\n" + "Please choose one of the following options to proceed to the download of an appropriate OpenCL implementation :", title, JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[2]); if (option >= 0 && option != 3) { - DownloadURL url; + String urlString; if (option == 0) { /*String nvidiaVersion = "260.99"; boolean appendPlatform = true; String sys; - if (JNI.isWindows()) { + if (Platform.isWindows()) { if (System.getProperty("os.name").toLowerCase().contains("xp")) { sys = "winxp"; appendPlatform = false; } else { sys = "win7_vista"; } - urlString = "http://www.nvidia.fr/object/" + sys + "_" + nvidiaVersion + (appendPlatform ? "_" + (JNI.is64Bits() ? "64" : "32") + "bit" : "") + "_whql.html"; + urlString = "http://www.nvidia.fr/object/" + sys + "_" + nvidiaVersion + (appendPlatform ? "_" + (Platform.is64Bit() ? "64" : "32") + "bit" : "") + "_whql.html"; } else urlString = "http://developer.nvidia.com/object/opencl-download.html"; */ - url = DownloadURL.NVidia; + urlString = "http://www.nvidia.com/Download/Find.aspx"; } else - url = DownloadURL.ATI; + urlString = "http://developer.amd.com/GPU/ATISTREAMSDK/Pages/default.aspx"; try { - Platform.open(url.url); + SystemUtils.runSystemOpenURL(new URL(urlString)); } catch (Exception ex1) { exception(ex1); } diff --git a/Demos/src/main/java/com/nativelibs4java/opencl/demos/hardware/HardwareReport.java b/Demos/src/main/java/com/nativelibs4java/opencl/demos/hardware/HardwareReport.java index 628511c2..08c66b9d 100644 --- a/Demos/src/main/java/com/nativelibs4java/opencl/demos/hardware/HardwareReport.java +++ b/Demos/src/main/java/com/nativelibs4java/opencl/demos/hardware/HardwareReport.java @@ -29,11 +29,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.nativelibs4java.opencl.demos.hardware; -import org.bridj.BridJ; import com.nativelibs4java.opencl.*; import com.nativelibs4java.opencl.demos.SetupUtils; -import org.bridj.Platform; - +import com.ochafik.util.SystemUtils; import java.awt.BorderLayout; import java.awt.FileDialog; import java.awt.Frame; @@ -193,6 +191,8 @@ public static JComponent getHardwareReportComponent(CLPlatform platform) { final String fileName = "HardwareReport.html"; JButton bWrite = new JButton("Save " + fileName + "..."); bWrite.addActionListener(new ActionListener() { + + @Override public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog((Frame)null, "Save " + fileName, FileDialog.SAVE); fd.setFile(fileName); @@ -207,7 +207,7 @@ public void actionPerformed(ActionEvent e) { w.write(html); w.close(); - Platform.show(file); + SystemUtils.runSystemOpenFileParent(file); } catch (Throwable ex) { SetupUtils.exception(ex); } diff --git a/Demos/src/main/java/com/nativelibs4java/opencl/demos/mandelbrot/MandelbrotDemo.java b/Demos/src/main/java/com/nativelibs4java/opencl/demos/mandelbrot/MandelbrotDemo.java index c94563b7..723837fb 100644 --- a/Demos/src/main/java/com/nativelibs4java/opencl/demos/mandelbrot/MandelbrotDemo.java +++ b/Demos/src/main/java/com/nativelibs4java/opencl/demos/mandelbrot/MandelbrotDemo.java @@ -1,12 +1,13 @@ package com.nativelibs4java.opencl.demos.mandelbrot; +//package bbbob.gparallel.mandelbrot; import static com.nativelibs4java.opencl.JavaCL.createBestContext; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import org.bridj.Pointer; +import java.nio.IntBuffer; import javax.imageio.ImageIO; import javax.imageio.ImageWriter; @@ -25,6 +26,7 @@ import com.nativelibs4java.opencl.CLQueue; import com.nativelibs4java.opencl.demos.SetupUtils; import com.nativelibs4java.util.IOUtils; +import com.nativelibs4java.util.NIOUtils; /** @@ -67,7 +69,7 @@ public static void main(String[] args) throws IOException, CLBuildException { //Setup output buffer int size = realResolution * imaginaryResolution; - Pointer results = Pointer.allocateInts(size).order(context.getByteOrder()); + IntBuffer results = NIOUtils.directInts(size, context.getByteOrder()); //TODO use an image object directly. //CL.clCreateImage2D(context.get(), 0, OpenCLLibrary); @@ -96,8 +98,9 @@ public static void main(String[] args) throws IOException, CLBuildException { } private static BufferedImage getImage(int realResolution, int imaginaryResolution, - Pointer results) { - int[] outputResults = results.getInts(realResolution * imaginaryResolution); + IntBuffer results) { + int[] outputResults = new int[realResolution * imaginaryResolution]; + results.get(outputResults); int max = Integer.MIN_VALUE; for (int i = outputResults.length; i-- != 0;) { int v = outputResults[i]; @@ -129,7 +132,7 @@ private static void outputImage(BufferedImage image) { static boolean useAutoGenWrapper = true; private static long buildAndExecuteKernel(CLQueue queue, float realMin, float imaginaryMin, int realResolution, int imaginaryResolution, int maxIter, int magicNumber, float deltaReal, - float deltaImaginary, Pointer results, String src) throws CLBuildException, IOException { + float deltaImaginary, IntBuffer results, String src) throws CLBuildException, IOException { CLContext context = queue.getContext(); long startTime = System.nanoTime(); @@ -143,7 +146,7 @@ private static long buildAndExecuteKernel(CLQueue queue, float realMin, float im maxIter, magicNumber, realResolution, - context.createBuffer(CLMem.Usage.Output, results, false), + context.createIntBuffer(CLMem.Usage.Output, results, false), new int[]{realResolution, imaginaryResolution}, new int[]{1,1} @@ -160,7 +163,7 @@ private static long buildAndExecuteKernel(CLQueue queue, float realMin, float im maxIter, magicNumber, realResolution, - context.createBuffer(CLMem.Usage.Output, results, false) + context.createIntBuffer(CLMem.Usage.Output, results, false) ); //Enqueue and complete work using a 2D range of work groups corrsponding to individual pizels in the set. diff --git a/Demos/src/main/java/com/nativelibs4java/opencl/demos/random/ParallelRandomDemo.java b/Demos/src/main/java/com/nativelibs4java/opencl/demos/random/ParallelRandomDemo.java index 8d095d7b..439fc9d7 100644 --- a/Demos/src/main/java/com/nativelibs4java/opencl/demos/random/ParallelRandomDemo.java +++ b/Demos/src/main/java/com/nativelibs4java/opencl/demos/random/ParallelRandomDemo.java @@ -9,14 +9,15 @@ import com.nativelibs4java.opencl.CLBuildException; import com.nativelibs4java.opencl.CLContext; import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLBuffer; +import com.nativelibs4java.opencl.CLIntBuffer; import com.nativelibs4java.opencl.CLMem.MapFlags; import com.nativelibs4java.opencl.CLMem.Usage; import com.nativelibs4java.opencl.CLQueue; import com.nativelibs4java.opencl.JavaCL; +import com.nativelibs4java.util.NIOUtils; import java.io.IOException; import java.nio.ByteOrder; -import org.bridj.Pointer; +import java.nio.IntBuffer; import java.util.Random; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -30,8 +31,8 @@ */ public class ParallelRandomDemo { - private static void println(Pointer b) { - for (int i = 0, n = (int)b.getValidElements(); i < n; i++) { + private static void println(IntBuffer b) { + for (int i = 0, n = b.capacity(); i < n; i++) { if (i > 0) System.out.print(", "); System.out.print(b.get(i)); @@ -67,8 +68,8 @@ public static void main(String[] args) { int warmupSize = 16; ParallelRandom demo = new ParallelRandom(queue, warmupSize, System.currentTimeMillis()); - println(demo.getSeeds().read(queue)); - Pointer b = demo.next(); + println((IntBuffer)demo.getSeeds().read(queue)); + IntBuffer b = demo.next(); println(b); b = demo.next(); println(b); diff --git a/Demos/src/main/java/com/nativelibs4java/opencl/demos/sobelfilter/SobelFilterDemo.java b/Demos/src/main/java/com/nativelibs4java/opencl/demos/sobelfilter/SobelFilterDemo.java index 8927fd76..33a82da5 100644 --- a/Demos/src/main/java/com/nativelibs4java/opencl/demos/sobelfilter/SobelFilterDemo.java +++ b/Demos/src/main/java/com/nativelibs4java/opencl/demos/sobelfilter/SobelFilterDemo.java @@ -30,30 +30,28 @@ */ package com.nativelibs4java.opencl.demos.sobelfilter; -import org.bridj.JNI; import javax.swing.*; +import java.nio.*; import com.nativelibs4java.opencl.*; import com.nativelibs4java.opencl.util.*; import com.nativelibs4java.opencl.demos.SetupUtils; -import com.nativelibs4java.util.Pair; +import com.ochafik.util.listenable.Pair; import java.awt.image.*; import java.io.*; - -import org.bridj.Platform; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; +import java.nio.FloatBuffer; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; +import com.sun.jna.Platform; import java.awt.FileDialog; public class SobelFilterDemo { static File chooseFile() { - if (Platform.isMacOSX()) { + if (Platform.isMac()) { FileDialog d = new FileDialog((java.awt.Frame)null); d.setMode(FileDialog.LOAD); d.show(); @@ -135,16 +133,14 @@ public Pair computeSobel(BufferedImage img) throws int width = img.getWidth(), height = img.getHeight(); int dataSize = height * width; - Pointer pixels = Pointer.pointerToInts(img.getRGB(0, 0, width, height, null, 0, width)); - CLImage2D inputImage = context.createImage2D(CLMem.Usage.Input, new CLImageFormat(CLImageFormat.ChannelOrder.ARGB, CLImageFormat.ChannelDataType.UnsignedInt8), width, height, width * 4, pixels.getBuffer(), true); - //CLImage2D inputImage = context.createImage2D(CLMem.Usage.Input, img, false); + int[] pixels = img.getRGB(0, 0, width, height, null, 0, width); - CLBuffer - gradients = context.createBuffer(CLMem.Usage.InputOutput, Float.class, dataSize), - directions = context.createBuffer(CLMem.Usage.InputOutput, Float.class, dataSize); + CLFloatBuffer + gradients = context.createFloatBuffer(CLMem.Usage.InputOutput, dataSize), + directions = context.createFloatBuffer(CLMem.Usage.InputOutput, dataSize); CLEvent evt = sobel.simpleSobel(queue, - inputImage, + context.createIntBuffer(CLMem.Usage.Input, IntBuffer.wrap(pixels), true).asCLByteBuffer(), width, height, gradients, @@ -158,30 +154,31 @@ public Pair computeSobel(BufferedImage img) throws //float[] test = new float[1000]; //gradients.read(queue).get(test); - float gradientMax = floatMinReductor.reduce(queue, gradients, dataSize, 32, evt).get(); - float dirMax = floatMinReductor.reduce(queue, directions, dataSize, 32, evt).get(); + float gradientMax = ((FloatBuffer)floatMinReductor.reduce(queue, gradients, dataSize, 32, evt)).get(); + float dirMax = ((FloatBuffer)floatMinReductor.reduce(queue, directions, dataSize, 32, evt)).get(); //CLEvent.waitFor(evtGradMax, evtDirMax); - CLBuffer gradientPixels = context.createBuffer(CLMem.Usage.Output, Integer.class, dataSize); - CLBuffer directionPixels = context.createBuffer(CLMem.Usage.Output, Integer.class, dataSize); + CLIntBuffer gradientPixels = context.createIntBuffer(CLMem.Usage.Output, dataSize); + CLIntBuffer directionPixels = context.createIntBuffer(CLMem.Usage.Output, dataSize); //CLEvent evtGrad = - sobel.normalizeImage(queue, gradients, gradientMax, (CLBuffer)gradientPixels, new int[] { dataSize }, null); + sobel.normalizeImage(queue, gradients, gradientMax, gradientPixels.asCLByteBuffer(), new int[] { dataSize }, null); //CLEvent evtDir = - sobel.normalizeImage(queue, directions, dirMax, (CLBuffer)directionPixels, new int[] { dataSize }, null); + sobel.normalizeImage(queue, directions, dirMax, directionPixels.asCLByteBuffer(), new int[] { dataSize }, null); queue.finish(); - BufferedImage gradientsImage = getRowsOrderImage(queue, gradientPixels, width, height);//, evtGrad); - BufferedImage directionsImage = getRowsOrderImage(queue, directionPixels, width, height);//, evtDir); + BufferedImage gradientsImage = getRowsOrderImage(queue, gradientPixels, width, height, pixels);//, evtGrad); + BufferedImage directionsImage = getRowsOrderImage(queue, directionPixels, width, height, pixels);//, evtDir); return new Pair(gradientsImage, directionsImage); } - static BufferedImage getRowsOrderImage(CLQueue queue, CLBuffer buffer, int width, int height, CLEvent... eventsToWaitFor) { + static BufferedImage getRowsOrderImage(CLQueue queue, CLIntBuffer buffer, int width, int height, int[] pixelsTemp, CLEvent... eventsToWaitFor) { queue.finish(); BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - int[] pixels = buffer.read(queue, eventsToWaitFor).getInts(width * height); + int[] pixels = pixelsTemp == null ? new int[width * height] : pixelsTemp; + ((IntBuffer)buffer.read(queue, eventsToWaitFor)).get(pixels); img.setRGB(0, 0, width,height, pixels, 0, width); return img; } diff --git a/Demos/src/main/java/com/nativelibs4java/opencl/demos/vectoradd/VectorAdd.java b/Demos/src/main/java/com/nativelibs4java/opencl/demos/vectoradd/VectorAdd.java index a90feee5..7e6edfc9 100644 --- a/Demos/src/main/java/com/nativelibs4java/opencl/demos/vectoradd/VectorAdd.java +++ b/Demos/src/main/java/com/nativelibs4java/opencl/demos/vectoradd/VectorAdd.java @@ -1,9 +1,6 @@ package com.nativelibs4java.opencl.demos.vectoradd; import com.nativelibs4java.opencl.*; import java.nio.*; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - /** * This is about the simplest possible JavaCL program.
    @@ -19,19 +16,19 @@ public class VectorAdd { public static void main(String[] args) { try { - Pointer a = pointerToFloats(1, 2, 3, 4 ); - Pointer b = pointerToFloats(10, 20, 30, 40); + FloatBuffer a = FloatBuffer.wrap(new float[] { 1, 2, 3, 4 }); + FloatBuffer b = FloatBuffer.wrap(new float[] { 10, 20, 30, 40 }); - Pointer sum = add(a, b); - for (long i = 0, n = sum.getValidElements(); i < n; i++) + FloatBuffer sum = add(a, b); + for (int i = 0, n = sum.capacity(); i < n; i++) System.out.println(sum.get(i)); } catch (Exception ex) { ex.printStackTrace(); } } - public static Pointer add(Pointer a, Pointer b) throws CLBuildException { - int n = (int)a.getValidElements(); + public static FloatBuffer add(FloatBuffer a, FloatBuffer b) throws CLBuildException { + int n = a.capacity(); CLContext context = JavaCL.createBestContext(); CLQueue queue = context.createDefaultQueue(); @@ -44,9 +41,9 @@ public static Pointer add(Pointer a, Pointer b) throws CLBu "} "; CLKernel kernel = context.createProgram(source).createKernel("addFloats"); - CLBuffer aBuf = context.createBuffer(CLMem.Usage.Input, a, true); - CLBuffer bBuf = context.createBuffer(CLMem.Usage.Input, b, true); - CLBuffer outBuf = context.createBuffer(CLMem.Usage.Output, Float.class, n); + CLFloatBuffer aBuf = context.createFloatBuffer(CLMem.Usage.Input, a, true); + CLFloatBuffer bBuf = context.createFloatBuffer(CLMem.Usage.Input, b, true); + CLFloatBuffer outBuf = context.createFloatBuffer(CLMem.Usage.Output, n); kernel.setArgs(aBuf, bBuf, outBuf); kernel.enqueueNDRange(queue, new int[]{n}); diff --git a/Demos/src/main/opencl/com/nativelibs4java/opencl/demos/sobelfilter/SimpleSobel.cl b/Demos/src/main/opencl/com/nativelibs4java/opencl/demos/sobelfilter/SimpleSobel.cl index 763cd0bc..ae0e40cb 100644 --- a/Demos/src/main/opencl/com/nativelibs4java/opencl/demos/sobelfilter/SimpleSobel.cl +++ b/Demos/src/main/opencl/com/nativelibs4java/opencl/demos/sobelfilter/SimpleSobel.cl @@ -21,10 +21,11 @@ sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER #define MY_S 0 #define MY_SE -1 -#define PIXEL_TO_INTENSITIES(pixel, coefX, coefY) (uint2)(coefX, coefY) * (uint2)((pixel.x + pixel.y + pixel.z) * pixel.w / 255 / 3) +#define PIXEL_TO_INTENSITIES(pixel, coefX, coefY) (uint2)(coefX, coefY) * (uint2)((pixel.x + (int)pixel.y + (int)pixel.z) * pixel.w / 256 / 3) __kernel void simpleSobel( - __read_only image2d_t input, + //__read_only image_t inputImage, + __global const uchar4* input, uint width, uint height, __global float* gradientOutput, __global float* directionOutput @@ -43,24 +44,24 @@ __kernel void simpleSobel( bool allowEast = x < width - 1, allowSouth = y < height - 1, allowNorth = y, allowWest = x; if (allowNorth) { if (allowWest) - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x-1, y-1)), MX_NW, MY_NW); - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x, y-1)), MX_N, MY_N); + total += PIXEL_TO_INTENSITIES(input[in - 1], MX_NW, MY_NW); + total += PIXEL_TO_INTENSITIES(input[in], MX_N, MY_N); if (allowEast) - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x+1, y-1)), MX_NE, MY_NE); + total += PIXEL_TO_INTENSITIES(input[in + 1], MX_NE, MY_NE); } if (allowWest) - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x-1, y)), MX_W, MY_W); - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x, y)), MX_C, MY_C); + total += PIXEL_TO_INTENSITIES(input[i - 1], MX_W, MY_W); + total += PIXEL_TO_INTENSITIES(input[i], MX_C, MY_C); if (allowEast) - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x+1, y)), MX_E, MY_E); + total += PIXEL_TO_INTENSITIES(input[i + 1], MX_E, MY_E); if (allowSouth) { if (allowWest) - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x-1, y+1)), MX_SW, MY_SW); - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x, y+1)), MX_S, MY_S); + total += PIXEL_TO_INTENSITIES(input[is - 1], MX_SW, MY_SW); + total += PIXEL_TO_INTENSITIES(input[is], MX_S, MY_S); if (allowEast) - total += PIXEL_TO_INTENSITIES(read_imageui(input, sampler, (int2)(x+1, y+1)), MX_SE, MY_SE); + total += PIXEL_TO_INTENSITIES(input[is + 1], MX_SE, MY_SE); } uint2 square = total * total; diff --git a/Demos/src/test/java/com/nativelibs4java/opencl/demos/SetupUtilsTest.java b/Demos/src/test/java/com/nativelibs4java/opencl/demos/SetupUtilsTest.java deleted file mode 100644 index 8d11439e..00000000 --- a/Demos/src/test/java/com/nativelibs4java/opencl/demos/SetupUtilsTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.demos; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URLConnection; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author ochafik - */ -public class SetupUtilsTest { - @Test - public void checkValidDownloadLinks() throws IOException { - for (SetupUtils.DownloadURL url : SetupUtils.DownloadURL.values()) { - HttpURLConnection con = (HttpURLConnection) url.url.openConnection(); - con.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36"); - assertEquals("Bad url for " + url + " : " + url.url, 200, con.getResponseCode()); - con.disconnect(); - } - } -} diff --git a/Generator/pom.xml b/Generator/pom.xml index dc5752cf..685070f4 100644 --- a/Generator/pom.xml +++ b/Generator/pom.xml @@ -3,15 +3,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.nativelibs4java - javacl-generator - JavaCL Generator / BridJ + javacl-generator-jna + JavaCL OpenCL Wrapper Code Generator / JNA http://code.google.com/p/javacl/ - jar + 1.0.0-RC4 + maven-plugin + com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT + javacl-parent-jna + 1.0.0-RC4 .. @@ -20,13 +22,61 @@ com.nativelibs4java jnaerator + ${jnaerator.version} + shaded com.nativelibs4java - javacl-core + javacl-core-jna + + + org.apache.maven + maven-plugin-api + 3.0.3 + + + + org.apache.maven + maven-project + 3.0-alpha-2 + + + +
    + diff --git a/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java b/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java index 89fcd1d7..af886fad 100644 --- a/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java +++ b/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGenerator.java @@ -1,25 +1,24 @@ package com.nativelibs4java.opencl.generator; import com.nativelibs4java.opencl.*; +import com.ochafik.io.IOUtils; import com.ochafik.lang.jnaerator.*; +import com.ochafik.lang.jnaerator.PreprocessorUtils.MacroUseCallback; import com.ochafik.lang.jnaerator.TypeConversion.JavaPrimitive; import com.ochafik.lang.jnaerator.TypeConversion.TypeConversionMode; -import com.ochafik.lang.jnaerator.UniversalReconciliator; -import com.ochafik.lang.jnaerator.UnsupportedConversionException; import com.ochafik.lang.jnaerator.parser.*; import com.ochafik.lang.jnaerator.runtime.NativeSize; -import com.nativelibs4java.jalico.Adapter; -import com.nativelibs4java.jalico.Pair; +import com.ochafik.util.listenable.Adapter; +import com.ochafik.util.listenable.Pair; import com.ochafik.util.string.RegexUtils; import com.ochafik.util.string.StringUtils; import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; +import java.io.*; import java.util.*; import static com.ochafik.lang.jnaerator.parser.ElementsHelper.*; -import java.io.PrintStream; import java.util.regex.Pattern; +import org.anarres.cpp.LexerException; public class JavaCLGenerator extends JNAerator { @@ -28,13 +27,11 @@ public class JavaCLGenerator extends JNAerator { public JavaCLGenerator(JNAeratorConfig config) { super(config); - config.forceOverwrite = true; - config.outputMode = JNAeratorConfig.OutputMode.Directory; config.noCPlusPlus = true; config.genCPlusPlus = false; config.gccLong = true; config.putTopStructsInSeparateFiles = false; - config.runtime = JNAeratorConfig.Runtime.BridJ;//NL4JStructs; + config.runtime = JNAeratorConfig.Runtime.JNAerator;//NL4JStructs; config.fileToLibrary = new Adapter() { @Override public String adapt(File value) { @@ -58,7 +55,7 @@ public Boolean adapt(Function value) { } Map> macrosByFile = new HashMap>(); - + @Override protected JNAeratorParser createJNAeratorParser() { return new JNAeratorParser() { @@ -86,14 +83,9 @@ protected com.ochafik.lang.jnaerator.parser.ObjCppParser newObjCppParser(TypeCon public Result createResult(final ClassOutputter outputter, Feedback feedback) { return new Result(config, outputter, feedback) { - @Override - public Identifier getLibraryClassFullName(String library) { - return null; - } - @Override public void init() { - typeConverter = new BridJTypeConversion(this) { + typeConverter = new JNATypeConversion(this) { @Override public void initTypes() { @@ -101,11 +93,7 @@ public void initTypes() { } - @Override - protected Identifier packageMember(Identifier libraryPackage, Identifier name) { - return name; - } - + @Override public boolean isObjCppPrimitive(String s) { int len; @@ -129,10 +117,10 @@ public boolean isObjCppPrimitive(String s) { } }; - declarationsConverter = new BridJDeclarationsConverter(this) { + declarationsConverter = new JNADeclarationsConverter(this) { @Override - public void convertFunction(Function function, Signatures signatures, boolean isCallback, DeclarationsHolder declarations, DeclarationsHolder implementations, Identifier libraryClassName, int iConstructor) { + public void convertFunction(Function function, Signatures signatures, boolean isCallback, DeclarationsHolder declarations, DeclarationsHolder implementations, Identifier libraryClassName, int unused) { if (isCallback) return; @@ -153,8 +141,8 @@ public void convertFunction(Function function, Signatures signatures, boolean is return; try { - tr = result.typeConverter.normalizeTypeRef(tr);//, null/*libraryClassName*/, false, false); - List mods = arg.harvestModifiers(); + tr = ((JNATypeConversion) result.typeConverter).resolveTypeDef(tr, libraryClassName, true, false); + List mods = tr.getModifiers(); TypeRef convTr; String argName = arg.getName() == null ? "arg" + iArg : arg.getName(); @@ -163,9 +151,9 @@ public void convertFunction(Function function, Signatures signatures, boolean is if (ModifierType.__local.isContainedBy(mods)) { argName += "LocalByteSize"; //convTr = typeRef(Long.TYPE); - //argExpr = new Expression.New(typeRef(LocalSize.class), varRef(argName)); - convTr = typeRef(LocalSize.class); - argExpr = varRef(argName);//new Expression.New(typeRef(LocalSize.class), varRef(argName)); + //argExpr = new Expression.New(typeRef(CLKernel.LocalSize.class), varRef(argName)); + convTr = typeRef(CLKernel.LocalSize.class); + argExpr = varRef(argName);//new Expression.New(typeRef(CLKernel.LocalSize.class), varRef(argName)); } else { Conversion conv = convertTypeToJavaCL(result, argName, tr, TypeConversion.TypeConversionMode.PrimitiveOrBufferParameter, null); convTr = conv.outerJavaTypeRef; @@ -196,7 +184,7 @@ public void convertFunction(Function function, Signatures signatures, boolean is String functionName = function.getName().toString(); String kernelVarName = functionName + "_kernel"; if (signatures.addVariable(kernelVarName)) - implementations.addDeclaration(new VariablesDeclaration(typeRef(CLKernel.class), new Declarator.DirectDeclarator(kernelVarName))); + implementations.addDeclaration(new VariablesDeclaration(typeRef(CLKernel.class), new Declarator.DirectDeclarator(kernelVarName))); Function method = new Function(Function.Type.JavaMethod, ident(functionName), typeRef(CLEvent.class)); method.addModifiers(ModifierType.Public, ModifierType.Synchronized); method.addThrown(typeRef(CLBuildException.class)); @@ -240,10 +228,10 @@ public void convertFunction(Function function, Signatures signatures, boolean is ); method.setBody(block(statements.toArray(new Statement[statements.size()]))); if (signatures.addMethod(method)) - implementations.addDeclaration(method); + implementations.addDeclaration(method); } }; - globalsGenerator = new BridJGlobalsGenerator(this); + globalsGenerator = new JNAGlobalsGenerator(this); objectiveCGenerator = new ObjectiveCGenerator(this); universalReconciliator = new UniversalReconciliator(); } @@ -305,7 +293,7 @@ static class Conversion { "float", Float.TYPE, float[].class, Float.class, "bool", Boolean.TYPE, boolean[].class, Boolean.class }; - for (int arity : new int[] { 1, 2, 3, 4, 8, 16 }) { + for (int arity : new int[] { 1, 2, 4, 8, 16 }) { String suffix = arity == 1 ? "" : arity +""; for (int i = 0; i < data.length; i += 4) { String rawType = (String)data[i]; @@ -323,16 +311,6 @@ static class Conversion { } } } - data = new Object[] { - "image2d_t", CLImage2D.class, - "image3d_t", CLImage3D.class - }; - for (int i = 0; i < data.length; i+=2) { - String type = (String) data[i]; - Class scalClass = (Class)data[i + 1]; - Pair> arrPair = new Pair>(1, scalClass); - arraysAndArityByType.put(type, arrPair); - } } private Conversion convertTypeToJavaCL(Result result, String argName, TypeRef valueType, TypeConversionMode typeConversionMode, Identifier libraryClassName) throws UnsupportedConversionException { Conversion ret = new Conversion(); @@ -343,29 +321,13 @@ private Conversion convertTypeToJavaCL(Result result, String argName, TypeRef va TypeRef target = ((TypeRef.Pointer)valueType).getTarget(); if (target instanceof TypeRef.SimpleTypeRef) { TypeRef.SimpleTypeRef starget = (TypeRef.SimpleTypeRef)target; - Identifier name = starget.getName(); - - Pair> pair = buffersAndArityByType.get((starget + "").equals("long") ? "long" : name + ""); + + Pair> pair = buffersAndArityByType.get(starget.getName().toString()); if (pair != null) { ret.outerJavaTypeRef = typeRef(ident(CLBuffer.class, expr(typeRef(pair.getSecond())))); return ret; } - Identifier ref = - result.structsFullNames.contains(name) || - result.enumsFullNames.contains(name) ? - name : result.typeConverter.findRef(name, target, libraryClassName, true); - if (ref != null) { - ret.outerJavaTypeRef = typeRef(ident(CLBuffer.class, expr(typeRef(ref)))); - return ret; - } - } else if (target instanceof Struct) { - TypeRef ref = result.typeConverter.findStructRef((Struct)target, libraryClassName); - if (ref != null) { - ret.outerJavaTypeRef = typeRef(ident(CLBuffer.class, expr(ref))); - return ret; - } } - throw new UnsupportedConversionException(valueType, "Unknown pointed target type"); } else if (valueType instanceof TypeRef.SimpleTypeRef) { TypeRef.SimpleTypeRef sr = (TypeRef.SimpleTypeRef)valueType; String name = sr.getName() == null ? sr.toString() : sr.getName().toString(); @@ -460,7 +422,6 @@ protected void generateLibraryFiles(SourceFiles sourceFiles, Result result) thro result.typeConverter.allowFakePointers = true; String library = name; Identifier fullLibraryClassName = ident(className); - interf.setResolvedJavaIdentifier(fullLibraryClassName); result.declarationsConverter.convertStructs(result.structsByLibrary.get(library), signatures, interf, library); //result.declarationsConverter.convertCallbacks(result.callbacksByLibrary.get(library), signatures, interf, fullLibraryClassName); @@ -486,8 +447,7 @@ public SampleUserProgram(CLContext context) throws IOException { if (macroName.equals("__LINE__") || macroName.equals("__FILE__") || macroName.equals("__COUNTER__") || - config.preprocessorConfig.explicitMacros.containsKey(macroName) || - config.preprocessorConfig.implicitMacros.containsKey(macroName)) + config.preprocessorConfig.explicitMacros.containsKey(macroName)) continue; String[] parts = macroName.split("_+"); @@ -515,31 +475,31 @@ public SampleUserProgram(CLContext context) throws IOException { } } -// -// @Override -// protected void autoConfigure() { -// super.autoConfigure(); -// -// /* -// __OPENCL_VERSION__ -// __ENDIAN_LITTLE__ -// -// __IMAGE_SUPPORT__ -// __FAST_RELAXED_MATH__ -// */ -// -// } + + @Override + protected void autoConfigure() { + super.autoConfigure(); + + /* + __OPENCL_VERSION__ + __ENDIAN_LITTLE__ + + __IMAGE_SUPPORT__ + __FAST_RELAXED_MATH__ + */ + + } public static void main(String[] args) { JNAerator.main(new JavaCLGenerator(new JNAeratorConfig()), new String[] { - "-o", "target/generated-sources/test", + "-o", "target/generated-sources/main/java", //"-o", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Demos/target/generated-sources/main/java", "-noJar", "-noComp", "-v", - "-addRootDir", "src/test/opencl", - "src/test/opencl/com/nativelibs4java/opencl/generator/Structs.c", + "-addRootDir", "src/main/opencl", + "src/main/opencl", //"-addRootDir", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Blas/target/../src/main/opencl", //"/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Blas/src/main/opencl/com/nativelibs4java/opencl/blas/LinearAlgebraKernels.c" //"-addRootDir", "/Users/ochafik/Prog/Java/versionedSources/nativelibs4java/trunk/libraries/OpenCL/Demos/target/../src/main/opencl", diff --git a/MavenPlugin/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGeneratorMojo.java b/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGeneratorMojo.java similarity index 97% rename from MavenPlugin/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGeneratorMojo.java rename to Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGeneratorMojo.java index 36465bab..e8b58e3e 100644 --- a/MavenPlugin/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGeneratorMojo.java +++ b/Generator/src/main/java/com/nativelibs4java/opencl/generator/JavaCLGeneratorMojo.java @@ -8,6 +8,7 @@ import com.ochafik.io.IOUtils; import com.ochafik.lang.jnaerator.JNAerator.Feedback; import com.ochafik.lang.jnaerator.JNAeratorConfig; +import com.ochafik.lang.jnaerator.JNAeratorConfig.OutputMode; import com.ochafik.lang.jnaerator.SourceFiles; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.project.MavenProject; @@ -54,14 +55,14 @@ public class JavaCLGeneratorMojo /** * Output directory for JNAerated Java sources. - * @parameter expression="${project.build.directory}/generated-sources/main" + * @parameter expression="${project.build.directory}/generated-sources/main/java" * @optional */ private File javaOutputDirectory; /** * Output directory for JNAerated Java test sources. - * @parameter expression="${project.build.directory}/generated-sources/test" + * @parameter expression="${project.build.directory}/generated-sources/test/java" * @optional */ private File testJavaOutputDirectory; @@ -125,7 +126,7 @@ public void generateAll(File root, File javaOutDir, File openCLOutDir) throws IO final JNAeratorConfig config = new JNAeratorConfig(); config.autoConf = true; config.forceOverwrite = true; - config.outputMode = JNAeratorConfig.OutputMode.Directory; + config.outputMode = OutputMode.Directory; config.outputJar = null; if (!javaOutDir.exists()) javaOutDir.mkdirs(); diff --git a/InteractiveImageDemo/javacl-interactive-image-demo-bridj.iml b/InteractiveImageDemo/javacl-interactive-image-demo-bridj.iml deleted file mode 100644 index 9e091638..00000000 --- a/InteractiveImageDemo/javacl-interactive-image-demo-bridj.iml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/InteractiveImageDemo/javacl-interactive-image-demo.iml b/InteractiveImageDemo/javacl-interactive-image-demo.iml deleted file mode 100644 index acf5a8b2..00000000 --- a/InteractiveImageDemo/javacl-interactive-image-demo.iml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/InteractiveImageDemo/pom.xml b/InteractiveImageDemo/pom.xml index 1f5e9624..2817375a 100644 --- a/InteractiveImageDemo/pom.xml +++ b/InteractiveImageDemo/pom.xml @@ -3,32 +3,32 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.nativelibs4java - javacl-interactive-image-demo - JavaCL Interactive Image Demo / BridJ + javacl-interactive-image-demo-jna + JavaCL Interactive Image Demo / JNA http://code.google.com/p/javacl/ + 1.0.0-RC4 jar com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT + javacl-parent-jna + 1.0.0-RC4 .. - + com.nativelibs4java.opencl.demos.interactiveimage.InteractiveImageDemo - true com.nativelibs4java - javacl-core + javacl-core-jna com.nativelibs4java - javacl-demos + javacl-demos-jna com.nativelibs4java @@ -44,24 +44,10 @@ - - - org.apache.maven.plugins - maven-shade-plugin - - - full-package - package - - shade - - - ${shadedArtifactAttached} - - - - - + + org.apache.maven.plugins + maven-jar-plugin + diff --git a/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/InteractiveImageDemo.java b/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/InteractiveImageDemo.java index 0303e46f..3d3373c9 100644 --- a/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/InteractiveImageDemo.java +++ b/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/InteractiveImageDemo.java @@ -37,7 +37,6 @@ import com.ochafik.swing.syntaxcoloring.CCTokenMarker; import com.ochafik.swing.syntaxcoloring.JEditTextArea; import com.ochafik.util.SystemUtils; -import org.bridj.Platform; import static com.nativelibs4java.opencl.demos.interactiveimage.Utils.*; @@ -425,7 +424,7 @@ void setImage(BufferedImage image) { origIcon(image == null ? null : new ImageIcon(image)); } void readImageResource(String name) { - readImage(Platform.getClassLoader(getClass()).getResource("images/" + name)); + readImage(getClass().getClassLoader().getResource("images/" + name)); } void chooseImage() { diff --git a/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/Utils.java b/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/Utils.java index 51bdb7b9..897f4a65 100644 --- a/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/Utils.java +++ b/InteractiveImageDemo/src/main/java/com/nativelibs4java/opencl/demos/interactiveimage/Utils.java @@ -11,7 +11,6 @@ import java.io.*; import java.awt.FileDialog; import java.util.*; -import org.bridj.Platform; import com.ochafik.swing.UndoRedoUtils; import com.ochafik.swing.syntaxcoloring.TokenMarker; @@ -140,7 +139,7 @@ public static String traceToString(Exception ex) { return sout.toString(); } public static String readTextResource(String path) throws IOException { - InputStream in = Platform.getClassLoader(Utils.class).getResourceAsStream(path); + InputStream in = Utils.class.getClassLoader().getResourceAsStream(path); if (in == null) throw new FileNotFoundException(path); diff --git a/JavaCL/javacl-bridj.iml b/JavaCL/javacl-bridj.iml deleted file mode 100644 index 5977dbce..00000000 --- a/JavaCL/javacl-bridj.iml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/JavaCL/javacl.iml b/JavaCL/javacl.iml deleted file mode 100644 index ccf61703..00000000 --- a/JavaCL/javacl.iml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/JavaCL/pom.xml b/JavaCL/pom.xml index d4e2cb1f..75ac51c8 100644 --- a/JavaCL/pom.xml +++ b/JavaCL/pom.xml @@ -1,125 +1,78 @@ - - - 4.0.0 - com.nativelibs4java - javacl - JavaCL / BridJ - http://code.google.com/p/javacl/ - bundle - - + + 4.0.0 + com.nativelibs4java + javacl-jna + JavaCL / JNA + http://code.google.com/p/javacl/ + 1.0.0-RC4 + jar + + + JavaCL is an Object-Oriented API that makes the C OpenCL API available to Java in a very natural way. It hides away the complexity of cross-platform C bindings, has a clean OO design (with generics, Java enums, NIO buffers, fully typed exceptions...), provides high-level features (OpenGL-interop, array reductions) and comes with samples and demos. For more info, please visit http://code.google.com/p/nativelibs4java/wiki/OpenCL. + + + com.nativelibs4java + javacl-parent-jna + 1.0.0-RC4 + .. + - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - .. - + + com.nativelibs4java.opencl + + + + + + com.nativelibs4java + javacl-core-jna + + + org.apache.commons + commons-math + 2.2 + test + + + velocity + velocity + 1.5 + - - + + + + + com.nativelibs4java - javacl-core - - - org.osgi - org.osgi.core - 4.3.0 - provided - - - org.apache.commons - commons-math - 2.2 - test - - + javacl-generator-jna + + + + compile + - - - - - com.nativelibs4java - maven-javacl-plugin - - - - org.apache.maven.plugins - maven-jar-plugin - + + + + + org.apache.maven.plugins + maven-jar-plugin + org.apache.maven.plugins maven-shade-plugin - - - full-package - package - - shade - - - ${shadedArtifactAttached} - - - - - - - org.apache.felix - maven-bundle-plugin - 2.5.3 - true - - - ${project.groupId}.${project.artifactId} - ${project.name} - ${project.version} - - com.nativelibs4java.opencl.OSGiBundleActivator - - - org.bridj.relocated.* - - - org.osgi.framework - - - com.nativelibs4java.opencl, - com.nativelibs4java.opencl.library, - com.nativelibs4java.opencl.util, - com.nativelibs4java.opencl.util.fft, - com.nativelibs4java.util, - com.ochafik.util.string, - - org.bridj, - org.bridj.ann, - org.bridj.cpp, - org.bridj.cpp.com, - org.bridj.cpp.com.shell, - org.bridj.demangling, - org.bridj.jawt, - org.bridj.objc, - org.bridj.dyncall, - org.bridj.util, - - org.bridj.lib.darwin_universal, - org.bridj.lib.linux_x64, - org.bridj.lib.linux_x86, - org.bridj.lib.sunos_x86, - org.bridj.lib.win32, - org.bridj.lib.win64 - - - - - - + + + diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/OSGiBundleActivator.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/OSGiBundleActivator.java deleted file mode 100644 index 8125666d..00000000 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/OSGiBundleActivator.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.nativelibs4java.opencl; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class OSGiBundleActivator implements BundleActivator { - - public void start(BundleContext bundleContext) { - System.out.println("Starting JavaCL"); - } - - public void stop(BundleContext bundleContext) { - System.out.println("Stopping JavaCL"); - } -} diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Fun1.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Fun1.java deleted file mode 100644 index c7ea7947..00000000 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Fun1.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.util; - - -public enum Fun1 { - not("!"), - complement("~"), - abs, - log, - exp, - sqrt, - sin, - cos, - tan, - atan, - asin, - acos, - sinh, - cosh, - tanh, - asinh, - acosh, - atanh; - - final String prefixOp; - Fun1(String op) { - this.prefixOp = op; - } - Fun1() { - this(null); - } - void expr(String a, StringBuilder out) { - if (prefixOp != null) - out.append('(').append(prefixOp).append(a).append(')'); - out.append(name()).append('(').append(a).append(')'); - } -} \ No newline at end of file diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Fun2.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Fun2.java deleted file mode 100644 index 05db8c0e..00000000 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Fun2.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.util; - - -public enum Fun2 { - min, - max, - atan2, - dist, - modulo("%"), - rshift(">>"), - lshift("<<"), - xor("^"), - bitOr("|"), - bitAnd("&"), - add("+"), - substract("-"), - multiply("*"), - divide("/"); - - String infixOp; - Fun2() {} - Fun2(String infixOp) { - this.infixOp = infixOp; - } - void expr(String a, String b, StringBuilder out) { - if (infixOp == null) - out.append(name()).append('(').append(a).append(", ").append(b).append(")"); - else - out.append(a).append(' ').append(infixOp).append(' ').append(b); - } -} \ No newline at end of file diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/LinearAlgebraUtils.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/LinearAlgebraUtils.java index a0afd2bb..bf2edad4 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/LinearAlgebraUtils.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/LinearAlgebraUtils.java @@ -8,7 +8,7 @@ import com.nativelibs4java.opencl.CLBuffer; import com.nativelibs4java.opencl.CLBuildException; import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.CLBuffer; +import com.nativelibs4java.opencl.CLDoubleBuffer; import com.nativelibs4java.opencl.CLEvent; import com.nativelibs4java.opencl.CLKernel; import com.nativelibs4java.opencl.CLPlatform.DeviceFeature; @@ -18,7 +18,8 @@ import com.nativelibs4java.opencl.util.ReductionUtils; import com.nativelibs4java.opencl.util.ReductionUtils.Reductor; import com.nativelibs4java.util.IOUtils; -import com.nativelibs4java.util.Pair; +import com.ochafik.util.listenable.Pair; +import static com.nativelibs4java.util.NIOUtils.*; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -58,16 +59,15 @@ public CLQueue getQueue() { return queue; } + public synchronized CLEvent multiply( CLBuffer a, int aRows, int aColumns, CLBuffer b, int bRows, int bColumns, CLBuffer out, //long outRows, long outColumns, CLEvent... eventsToWaitFor) throws CLBuildException { - if (a.getElementClass() == Double.class) + if (a.getBufferClass() == DoubleBuffer.class) return multiplyDoubles((CLBuffer)a, aRows, aColumns, (CLBuffer)b, bRows, bColumns, (CLBuffer)out, eventsToWaitFor); - if (a.getElementClass() == Float.class) - return multiplyFloats((CLBuffer)a, aRows, aColumns, (CLBuffer)b, bRows, bColumns, (CLBuffer)out, eventsToWaitFor); throw new UnsupportedOperationException(); } @@ -85,7 +85,7 @@ public synchronized CLEvent multiplyDoubles( long outRows = aRows; long outColumns = bColumns; - return kernels.mulMatDouble(queue, + return kernels.mulMat(queue, a, (int)aColumns, b, (int)bColumns, out, @@ -94,80 +94,40 @@ public synchronized CLEvent multiplyDoubles( eventsToWaitFor ); } - public synchronized CLEvent multiplyFloats( - CLBuffer a, long aRows, long aColumns, - CLBuffer b, long bRows, long bColumns, - CLBuffer out, //long outRows, long outColumns, - CLEvent... eventsToWaitFor) throws CLBuildException - { - long outRows = aRows; - long outColumns = bColumns; - return kernels.mulMatFloat(queue, - a, (int)aColumns, - b, (int)bColumns, - out, - new int[] { (int)outRows, (int)outColumns }, - null, - eventsToWaitFor - ); - } - Reductor addReductorDouble; - synchronized Reductor getAddReductorDouble() { - if (addReductorDouble == null) { - try { - addReductorDouble = ReductionUtils.createReductor(getContext(), ReductionUtils.Operation.Add, OpenCLType.Double, 1); - } catch (CLBuildException ex) { - Logger.getLogger(LinearAlgebraUtils.class.getName()).log(Level.SEVERE, null, ex); - throw new RuntimeException("Failed to create an addition reductor !", ex); - } - } - return addReductorDouble; - } - public synchronized CLEvent transposeDouble(CLBuffer a, int aRows, int aColumns, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - return kernels.transposeDouble(queue, - a, aRows, aColumns, - out, - new int[] { (int)aColumns, (int)aRows }, - null, - eventsToWaitFor - ); - } - Reductor addReductorFloat; - synchronized Reductor getAddReductorFloat() { - if (addReductorFloat == null) { - try { - addReductorFloat = ReductionUtils.createReductor(getContext(), ReductionUtils.Operation.Add, OpenCLType.Float, 1); + /*synchronized CLEvent dot(CLVector a b out, CLEvent... eventsToWaitFor) { + CLEvent.waitFor(eventsToWaitFor); + a.waitForRead(); + b.waitForRead(); + out.waitForWrite(); + FV aa = newVector(fallBackLibrary, a); + FV bb = newVector(fallBackLibrary, b); + out.write(aa.dot(bb, null).read()); + return null; + }*/ + + Reductor addReductor; + synchronized Reductor getAddReductor() { + if (addReductor == null) { + try { + addReductor = ReductionUtils.createReductor(getContext(), ReductionUtils.Operation.Add, OpenCLType.Double, 1); } catch (CLBuildException ex) { Logger.getLogger(LinearAlgebraUtils.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Failed to create an addition reductor !", ex); } } - return addReductorFloat; + return addReductor; } public synchronized CLEvent transpose(CLBuffer a, int aRows, int aColumns, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - if (a.getElementClass() == Double.class) + if (a.getBufferClass() == DoubleBuffer.class) return transposeDoubles((CLBuffer)a, aRows, aColumns, (CLBuffer)out, eventsToWaitFor); - if (a.getElementClass() == Float.class) - return transposeFloats((CLBuffer)a, aRows, aColumns, (CLBuffer)out, eventsToWaitFor); throw new UnsupportedOperationException(); } - public synchronized CLEvent transposeFloats(CLBuffer a, int aRows, int aColumns, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - return kernels.transposeFloat(queue, - a, aRows, aColumns, - out, - new int[] { (int)aColumns, (int)aRows }, - null, - eventsToWaitFor - ); - } - - - public synchronized CLEvent transposeDoubles(CLBuffer a, int aRows, int aColumns, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { - return kernels.transposeDouble(queue, + public synchronized CLEvent transposeDoubles(CLBuffer a, int aRows, int aColumns, CLBuffer out, CLEvent... eventsToWaitFor) throws CLBuildException { + return kernels.transpose(queue, a, aRows, aColumns, out, new int[] { (int)aColumns, (int)aRows }, diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/OpenCLType.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/OpenCLType.java index 8d0faca2..4c093d5f 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/OpenCLType.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/OpenCLType.java @@ -6,13 +6,8 @@ package com.nativelibs4java.opencl.util; public enum OpenCLType { - Int(Integer.class), Char(Character.class), Long(Long.class), Short(Short.class), Byte(Byte.class), Double(Double.class), Float(Float.class), Half(null); - - OpenCLType(Class type) { - this.type = type; - } - public final Class type; - + Int, Char, Long, Short, Byte, Double, Float, Half; + public String toCType() { if (this == Byte) return "char"; diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelMath.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelMath.java index f1a754e1..17d9b749 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelMath.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelMath.java @@ -7,7 +7,7 @@ import com.nativelibs4java.opencl.CLBuildException; import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.CLBuffer; +import com.nativelibs4java.opencl.CLDoubleBuffer; import com.nativelibs4java.opencl.CLEvent; import com.nativelibs4java.opencl.CLKernel; import com.nativelibs4java.opencl.CLProgram; @@ -16,13 +16,14 @@ import com.nativelibs4java.opencl.util.ReductionUtils; import com.nativelibs4java.opencl.util.ReductionUtils.Reductor; import com.nativelibs4java.util.IOUtils; -import com.nativelibs4java.util.Pair; +import com.ochafik.util.listenable.Pair; import static com.nativelibs4java.util.NIOUtils.*; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; +import java.nio.DoubleBuffer; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; @@ -55,86 +56,178 @@ public CLQueue getQueue() { public CLContext getContext() { return getQueue().getContext(); } + + public enum Fun1 { + log, + exp, + sqrt, + sin, + cos, + tan, + atan, + asin, + acos, + sinh, + cosh, + tanh, + asinh, + acosh, + atanh; + + void expr(String a, StringBuilder out) { + out.append(name()).append('(').append(a).append(")"); + } + } + public enum Fun2 { + atan2, + dist, + modulo("%"), + rshift(">>"), + lshift("<<"), + add("+"), + substract("-"), + multiply("*"), + divide("/"); + + String infixOp; + Fun2() {} + Fun2(String infixOp) { + this.infixOp = infixOp; + } + void expr(String a, String b, StringBuilder out) { + if (infixOp == null) + out.append(name()).append('(').append(a).append(", ").append(b).append(")"); + else + out.append(a).append(' ').append(infixOp).append(' ').append(b); + } + } + public enum Primitive { + Float, + Double, + Long, + Int, + Short, + Byte, + + Float2, + Double2, + Long2, + Int2, + Short2, + Byte2, + + Float3, + Double3, + Long3, + Int3, + Short3, + Byte3, + + Float4, + Double4, + Long4, + Int4, + Short4, + Byte4, + + Float8, + Double8, + Long8, + Int8, + Short8, + Byte8, + + Float16, + Double16, + Long16, + Int16, + Short16, + Byte16; + + String type() { + return name().toLowerCase(); + } + } - protected String createVectFun1Source(Fun1 function, Primitive type, StringBuilder out) { - String t = type.clTypeName(); - String kernelName = "vect_" + function.name() + "_" + t;// + (inPlace ? "_inplace" : ""); + protected String createVectFun1Source(Fun1 function, Primitive type, StringBuilder out, boolean inPlace) { + String t = type.type(); + String kernelName = "vect_" + function.name() + "_" + t + (inPlace ? "_inplace" : ""); out.append("__kernel void " + kernelName + "(\n"); - out.append("\t__global const " + t + "* in,\n"); - out.append("\t__global " + t + "* out,\n"); - out.append("\tlong length\n"); + if (!inPlace) + out.append("\t__global const " + t + "* in,\n"); + out.append("\t__global " + t + "* out\n"); out.append(") {\n"); out.append("\tint i = get_global_id(0);\n"); - out.append("\tif (i >= length) return;\n"); out.append("\tout[i] = "); - function.expr("in[i]", out); - out.append(";\n"); + function.expr(inPlace ? "out" : "in", out); + out.append("[i]);\n"); out.append("}\n"); return kernelName; } - protected String createVectFun2Source(Fun2 function, Primitive type1, Primitive type2, Primitive typeOut, StringBuilder out, boolean secondOperandIsScalar) { - String t1 = type1.clTypeName(), t2 = type2.clTypeName(), to = typeOut.clTypeName(); + protected String createVectFun2Source(Fun2 function, Primitive type1, Primitive type2, Primitive typeOut, StringBuilder out) { + String t1 = type1.type(), t2 = type2.type(), to = typeOut.type(); String kernelName = "vect_" + function.name() + "_" + t1 + "_" + t2 + "_" + to; out.append("__kernel void " + kernelName + "(\n"); out.append("\t__global const " + t1 + "* in1,\n"); - if (secondOperandIsScalar) - out.append("\t" + t2 + " in2,\n"); - else - out.append("\t__global const " + t2 + "* in2,\n"); - out.append("\t__global " + to + "* out,\n"); - out.append("\tlong length\n"); + out.append("\t__global const " + t2 + "* in2,\n"); + out.append("\t__global " + to + "* out\n"); out.append(") {\n"); out.append("\tint i = get_global_id(0);\n"); - out.append("\tif (i >= length) return;\n"); out.append("\tout[i] = (" + to + ")"); - function.expr("in1[i]", (secondOperandIsScalar ? "in2" : "in2[i]"), out); + function.expr("in1[i]", "in2[i]", out); out.append(";\n"); out.append("}\n"); return kernelName; } - private EnumMap> fun1Kernels = new EnumMap>(Fun1.class); + private static class Fun1Kernels { + CLKernel inPlace, notInPlace; + } + private EnumMap> fun1Kernels = new EnumMap>(Fun1.class); - public synchronized CLKernel getKernel(Fun1 op, Primitive prim) throws CLBuildException { - EnumMap m = fun1Kernels.get(op); + public synchronized CLKernel getKernel(Fun1 op, Primitive prim, boolean inPlace) throws CLBuildException { + EnumMap m = fun1Kernels.get(op); if (m == null) - fun1Kernels.put(op, m = new EnumMap(Primitive.class)); + fun1Kernels.put(op, m = new EnumMap(Primitive.class)); - CLKernel kers = m.get(prim); + Fun1Kernels kers = m.get(prim); if (kers == null) { StringBuilder out = new StringBuilder(300); - String name = createVectFun1Source(op, prim, out); + String inPlaceName = createVectFun1Source(op, prim, out, true); + String notInPlaceName = createVectFun1Source(op, prim, out, false); CLProgram prog = getContext().createProgram(out.toString()).build(); - kers = prog.createKernel(name); + kers = new Fun1Kernels(); + kers.inPlace = prog.createKernel(inPlaceName); + kers.notInPlace = prog.createKernel(notInPlaceName); m.put(prim, kers); } - return kers; + return inPlace ? kers.inPlace : kers.notInPlace; } - static class PrimitiveTrio extends Pair, Pair> { - public PrimitiveTrio(Primitive a, Primitive b, Primitive c, boolean secondOperandIsScalar) { - super(new Pair(a, b), new Pair(c, secondOperandIsScalar)); + static class PrimitiveTrio extends Pair> { + public PrimitiveTrio(Primitive a, Primitive b, Primitive c) { + super(a, new Pair(b, c)); } } private EnumMap> fun2Kernels = new EnumMap>(Fun2.class); - public synchronized CLKernel getKernel(Fun2 op, Primitive prim, boolean secondOperandIsScalar) throws CLBuildException { - return getKernel(op, prim, prim, prim, secondOperandIsScalar); + public synchronized CLKernel getKernel(Fun2 op, Primitive prim) throws CLBuildException { + return getKernel(op, prim, prim, prim); } - public synchronized CLKernel getKernel(Fun2 op, Primitive prim1, Primitive prim2, Primitive primOut, boolean secondOperandIsScalar) throws CLBuildException { + public synchronized CLKernel getKernel(Fun2 op, Primitive prim1, Primitive prim2, Primitive primOut) throws CLBuildException { Map m = fun2Kernels.get(op); if (m == null) fun2Kernels.put(op, m = new HashMap()); - PrimitiveTrio key = new PrimitiveTrio(prim1, prim2, primOut, secondOperandIsScalar); + PrimitiveTrio key = new PrimitiveTrio(prim1, prim2, primOut); CLKernel ker = m.get(key); if (ker == null) { StringBuilder out = new StringBuilder(300); - String name = createVectFun2Source(op, prim1, prim2, primOut, out, secondOperandIsScalar); + String name = createVectFun2Source(op, prim1, prim2, primOut, out); CLProgram prog = getContext().createProgram(out.toString()).build(); ker = prog.createKernel(name); m.put(key, ker); diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelRandom.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelRandom.java index ffd88468..ca9918e3 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelRandom.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ParallelRandom.java @@ -5,10 +5,8 @@ package com.nativelibs4java.opencl.util; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - import java.io.IOException; +import java.nio.IntBuffer; import java.util.Random; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -19,24 +17,14 @@ import com.nativelibs4java.opencl.CLBuildException; import com.nativelibs4java.opencl.CLContext; import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLBuffer; +import com.nativelibs4java.opencl.CLIntBuffer; import com.nativelibs4java.opencl.JavaCL; import com.nativelibs4java.opencl.CLQueue; import com.nativelibs4java.opencl.CLMem.Usage; +import com.nativelibs4java.util.NIOUtils; /** - * Parallel Random numbers generator (Xorshift adapted to work in parallel).
    - * This class was designed as a drop-in replacement for java.util.Random (albeit with a more limited API) : - *
    {@code
    - * ParallelRandom r = new ParallelRandom();
    - * r.setPreload(true); // faster
    - * while (true) {
    - *     System.out.println(r.nextDouble());
    - * }
    - * }
    - *
    - * It is also possible to get entire batches of random integers with {@link ParallelRandom#next()} or {@link ParallelRandom#next(Pointer)}.
    - * The preload feature precomputes a new batch in background as soon as one starts to consume numbers from the current batch. + * * @author ochafik */ public class ParallelRandom { @@ -53,8 +41,8 @@ public class ParallelRandom { boolean preload; CLEvent preloadEvent; - protected CLBuffer seeds, output; - Pointer lastData; + protected CLIntBuffer seeds, output; + IntBuffer lastData; boolean isDataFresh; public ParallelRandom() throws IOException { @@ -89,12 +77,12 @@ public ParallelRandom(CLQueue queue, int parallelSize, final long seed) throws I randomProgram.getProgram().defineMacro("WORK_ITEMS_COUNT", scheduledWorkItems); final int nSeeds = seedsNeededByWorkItem * parallelSize; - final Pointer seedsBuf = allocateInts(nSeeds).order(context.getKernelsDefaultByteOrder()); + final IntBuffer seedsBuf = NIOUtils.directInts(nSeeds, context.getKernelsDefaultByteOrder()); initSeeds(seedsBuf, seed); //println(seedsBuf); - this.seeds = context.createBuffer(Usage.InputOutput, seedsBuf, true); + this.seeds = context.createIntBuffer(Usage.InputOutput, seedsBuf, true); //this.lastOutputData = NIOUtils.directInts(parallelSize, context.getKernelsDefaultByteOrder()); - this.output = context.createBuffer(Usage.Output, Integer.class, parallelSize); + this.output = context.createIntBuffer(Usage.Output, parallelSize); } catch (InterruptedException ex) { Logger.getLogger(ParallelRandom.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException("Failed to initialized parallel random", ex); @@ -111,15 +99,6 @@ public int nextInt() { return lastData.get(consumedInts++); } - /** - * If true, a new batch of parallel random numbers is automatically precomputed in background as soon as one starts to consume numbers from the current batch (this gives faster random numbers, at the risk of computing more values than needed) - */ - public synchronized boolean isPreload() { - return preload; - } - /** - * If true, a new batch of parallel random numbers is automatically precomputed in background as soon as one starts to consume numbers from the current batch (this gives faster random numbers, at the risk of computing more values than needed) - */ public synchronized void setPreload(boolean preload) throws CLBuildException { this.preload = preload; if (preload && preloadEvent == null) { @@ -191,7 +170,7 @@ public double nextDouble() { return (((long)(nextInt() & doubleMask) << 27) | (nextInt() & doubleMask)) / doubleDivid; } - public CLBuffer getSeeds() { + public CLIntBuffer getSeeds() { return seeds; } public CLQueue getQueue() { @@ -199,7 +178,7 @@ public CLQueue getQueue() { } /** - * Number of random numbers generated at each call of {@link ParallelRandom#next() } or {@link ParallelRandom#next(Pointer) }
    + * Number of random numbers generated at each call of {@link ParallelRandom#next() } or {@link ParallelRandom#next(IntBuffer) }
    * The numbers might not all be generated exactly in parallel, the level of parallelism is implementation-dependent. * @return size of each buffer returned by {@link ParallelRandom#next() } */ @@ -225,7 +204,7 @@ public synchronized CLEvent doNext() { * Copies the next {@link ParallelRandom#getParallelSize() } random integers in the provided output buffer * @param output */ - public synchronized void next(Pointer output) { + public synchronized void next(IntBuffer output) { CLEvent evt = doNext(); this.output.read(queue, output, true, evt); } @@ -234,9 +213,9 @@ public synchronized void next(Pointer output) { /** * Returns a direct NIO buffer containing the next {@link ParallelRandom#getParallelSize() } random integers.
    * This buffer is read only and will only be valid until any of the "next" method is called again. - * @return output buffer of capacity ; see {@link ParallelRandom#getParallelSize() } + * @param output buffer of capacity ; see {@link ParallelRandom#getParallelSize() } */ - public synchronized Pointer next() { + public synchronized IntBuffer next() { CLEvent evt = doNext(); //queue.finish(); evt = null; //return outputBuffer; @@ -244,8 +223,8 @@ public synchronized Pointer next() { return output.read(queue, evt); } - private void initSeeds(final Pointer seedsBuf, final long seed) throws InterruptedException { - final long nSeeds = seedsBuf.getValidElements(); + private void initSeeds(final IntBuffer seedsBuf, final long seed) throws InterruptedException { + final int nSeeds = seedsBuf.capacity(); long start = System.nanoTime(); @@ -254,8 +233,8 @@ private void initSeeds(final Pointer seedsBuf, final long seed) throws //parallelize = false; if (parallelize) { Random random = new Random(seed); - for (long i = nSeeds; i-- != 0;) - seedsBuf.set(i, random.nextInt()); + for (int i = nSeeds; i-- != 0;) + seedsBuf.put(i, random.nextInt()); } else { // Parallelize seeds initialization final int nThreads = Runtime.getRuntime().availableProcessors();// * 2; @@ -265,14 +244,14 @@ private void initSeeds(final Pointer seedsBuf, final long seed) throws service.execute(new Runnable() { public void run() { - long n = nSeeds / nThreads; - long offset = n * iThread; + int n = nSeeds / nThreads; + int offset = n * iThread; Random random = new Random(seed + iThread);// * System.currentTimeMillis()); if (iThread == nThreads - 1) n += nSeeds - n * nThreads; - for (long i = n; i-- != 0;) - seedsBuf.set(offset++, random.nextInt()); + for (int i = n; i-- != 0;) + seedsBuf.put(offset++, random.nextInt()); } }); } diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Primitive.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Primitive.java deleted file mode 100644 index 81518f64..00000000 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Primitive.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package com.nativelibs4java.opencl.util; - -public enum Primitive { - Float(Float.class, 1, OpenCLType.Float), - Double(Double.class, 1, OpenCLType.Double), - Long(Long.class, 1, OpenCLType.Long), - Int(Integer.class, 1, OpenCLType.Int), - Short(Short.class, 1, OpenCLType.Short), - Byte(Byte.class, 1, OpenCLType.Byte), - - Float2(Float.class, 2, OpenCLType.Float), - Double2(Double.class, 2, OpenCLType.Double), - Long2(Long.class, 2, OpenCLType.Long), - Int2(Integer.class, 2, OpenCLType.Int), - Short2(Short.class, 2, OpenCLType.Short), - Byte2(Byte.class, 2, OpenCLType.Byte), - - Float3(Float.class, 3, OpenCLType.Float), - Double3(Double.class, 3, OpenCLType.Double), - Long3(Long.class, 3, OpenCLType.Long), - Int3(Integer.class, 3, OpenCLType.Int), - Short3(Short.class, 3, OpenCLType.Short), - Byte3(Byte.class, 3, OpenCLType.Byte), - - Float4(Float.class, 4, OpenCLType.Float), - Double4(Double.class, 4, OpenCLType.Double), - Long4(Long.class, 4, OpenCLType.Long), - Int4(Integer.class, 4, OpenCLType.Int), - Short4(Short.class, 4, OpenCLType.Short), - Byte4(Byte.class, 4, OpenCLType.Byte), - - Float8(Float.class, 8, OpenCLType.Float), - Double8(Double.class, 8, OpenCLType.Double), - Long8(Long.class, 8, OpenCLType.Long), - Int8(Integer.class, 8, OpenCLType.Int), - Short8(Short.class, 8, OpenCLType.Short), - Byte8(Byte.class, 8, OpenCLType.Byte), - - Float16(Float.class, 16, OpenCLType.Float), - Double16(Double.class, 16, OpenCLType.Double), - Long16(Long.class, 16, OpenCLType.Long), - Int16(Integer.class, 16, OpenCLType.Int), - Short16(Short.class, 16, OpenCLType.Short), - Byte16(Byte.class, 16, OpenCLType.Byte); - - Primitive(Class primitiveType, int primitiveCount, OpenCLType oclType) { - this.primitiveCount = primitiveCount; - this.primitiveType = primitiveType; - this.oclType = oclType; - } - public final OpenCLType oclType; - public final int primitiveCount; - public final Class primitiveType; - public String clTypeName() { - return name().toLowerCase(); - } - public String getRequiredPragmas() { - if (primitiveType == Double.class) - return "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; - return ""; - } -} \ No newline at end of file diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ReductionUtils.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ReductionUtils.java index 2cad3274..17f3221f 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ReductionUtils.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/ReductionUtils.java @@ -16,23 +16,18 @@ import java.util.logging.Logger; import com.nativelibs4java.util.IOUtils; -import com.nativelibs4java.util.Pair; - -import org.bridj.Pointer; -import org.bridj.Platform; -import static org.bridj.Pointer.*; +import com.nativelibs4java.util.NIOUtils; +import com.ochafik.util.listenable.Pair; /** - * Parallel reduction utils (max, min, sum and product computations on OpenCL buffers of any type) + * * @author Olivier */ public class ReductionUtils { - static final int DEFAULT_MAX_REDUCTION_SIZE = 4; - static String source; static final String sourcePath = ReductionUtils.class.getPackage().getName().replace('.', '/') + "/" + "Reduction.c"; static synchronized String getSource() throws IOException { - InputStream in = Platform.getClassLoader(ReductionUtils.class).getResourceAsStream(sourcePath); + InputStream in = ReductionUtils.class.getClassLoader().getResourceAsStream(sourcePath); if (in == null) throw new FileNotFoundException(sourcePath); return source = IOUtils.readText(in); @@ -111,17 +106,10 @@ public static Pair> getReductionCodeAndMacros(Operat macros.put("SEED", seed); return new Pair>(getSource(), macros); } - public interface Reductor { - /** Number of independent channels of the reductor */ - public int getChannels(); - public CLEvent reduce(CLQueue queue, CLBuffer input, long inputLength, CLBuffer output, int maxReductionSize, CLEvent... eventsToWaitFor); - public Pointer reduce(CLQueue queue, CLBuffer input, long inputLength, int maxReductionSize, CLEvent... eventsToWaitFor); - public CLEvent reduce(CLQueue queue, CLBuffer input, long inputLength, Pointer output, int maxReductionSize, CLEvent... eventsToWaitFor); - /** - * Return the result of the reduction operation (with one value per channel). - */ - public Pointer reduce(CLQueue queue, CLBuffer input, CLEvent... eventsToWaitFor); - + public interface Reductor

    { + public CLEvent reduce(CLQueue queue, CLBuffer

    input, long inputLength, B output, int maxReductionSize, CLEvent... eventsToWaitFor); + public B reduce(CLQueue queue, CLBuffer

    input, long inputLength, int maxReductionSize, CLEvent... eventsToWaitFor); + public CLEvent reduce(CLQueue queue, CLBuffer

    input, long inputLength, CLBuffer

    output, int maxReductionSize, CLEvent... eventsToWaitFor); } /*public interface WeightedReductor { public CLEvent reduce(CLQueue queue, CLBuffer input, CLBuffer weights, long inputLength, B output, int maxReductionSize, CLEvent... eventsToWaitFor); @@ -144,11 +132,7 @@ static int getNextPowerOfTwo(int i) { } } - /** - * Create a reductor for the provided operation and primitive type (on the provided number of independent channels).
    - * Channels are reduced independently, so that with 2 channels the max of elements { (1, 30), (2, 20), (3, 10) } would be (3, 30). - */ - public static Reductor createReductor(final CLContext context, Operation op, final OpenCLType valueType, final int valueChannels) throws CLBuildException { + public static

    Reductor

    createReductor(final CLContext context, Operation op, OpenCLType valueType, final int valueChannels) throws CLBuildException { try { @@ -160,19 +144,17 @@ public static Reductor createReductor(final CLContext context, Operation if (kernels.length != 1) throw new RuntimeException("Expected 1 kernel, found : " + kernels.length); final CLKernel kernel = kernels[0]; - return new Reductor() { - @Override - public int getChannels() { - return valueChannels; - } + return new Reductor

    () { @SuppressWarnings("unchecked") - public CLEvent reduce(CLQueue queue, CLBuffer input, long inputLength, Pointer output, int maxReductionSize, CLEvent... eventsToWaitFor) { - Pair, CLEvent[]> outAndEvts = reduceHelper(queue, input, (int)inputLength, maxReductionSize, eventsToWaitFor); + @Override + public CLEvent reduce(CLQueue queue, CLBuffer

    input, long inputLength, B output, int maxReductionSize, CLEvent... eventsToWaitFor) { + input.getBufferClass().cast(output); + Pair, CLEvent[]> outAndEvts = reduceHelper(queue, input, (int)inputLength, maxReductionSize, eventsToWaitFor); return outAndEvts.getFirst().read(queue, 0, valueChannels, output, false, outAndEvts.getSecond()); } @Override - public Pointer reduce(CLQueue queue, CLBuffer input, long inputLength, int maxReductionSize, CLEvent... eventsToWaitFor) { - Pointer output = Pointer.allocateArray((Class)valueType.type, valueChannels).order(context.getByteOrder()); + public B reduce(CLQueue queue, CLBuffer

    input, long inputLength, int maxReductionSize, CLEvent... eventsToWaitFor) { + B output = (B)NIOUtils.directBuffer((int)inputLength, context.getByteOrder(), (Class)input.getBufferClass()); CLEvent evt = reduce(queue, input, inputLength, output, maxReductionSize, eventsToWaitFor); //queue.finish(); //TODO @@ -180,25 +162,18 @@ public Pointer reduce(CLQueue queue, CLBuffer input, long inputLength, int return output; } @Override - public Pointer reduce(CLQueue queue, CLBuffer input, CLEvent... eventsToWaitFor) { - return reduce(queue, input, input.getElementCount(), DEFAULT_MAX_REDUCTION_SIZE, eventsToWaitFor); - } - @Override - public CLEvent reduce(CLQueue queue, CLBuffer input, long inputLength, CLBuffer output, int maxReductionSize, CLEvent... eventsToWaitFor) { - Pair, CLEvent[]> outAndEvts = reduceHelper(queue, input, (int)inputLength, maxReductionSize, eventsToWaitFor); + public CLEvent reduce(CLQueue queue, CLBuffer

    input, long inputLength, CLBuffer

    output, int maxReductionSize, CLEvent... eventsToWaitFor) { + Pair, CLEvent[]> outAndEvts = reduceHelper(queue, input, (int)inputLength, maxReductionSize, eventsToWaitFor); return outAndEvts.getFirst().copyTo(queue, 0, valueChannels, output, 0, outAndEvts.getSecond()); } @SuppressWarnings("unchecked") - public Pair, CLEvent[]> reduceHelper(CLQueue queue, CLBuffer input, int inputLength, int maxReductionSize, CLEvent... eventsToWaitFor) { - if (inputLength == 1) { - return new Pair, CLEvent[]>(input, new CLEvent[0]); - } + public Pair, CLEvent[]> reduceHelper(CLQueue queue, CLBuffer

    input, int inputLength, int maxReductionSize, CLEvent... eventsToWaitFor) { if (inputLength == 1) { - return new Pair, CLEvent[]>(input, new CLEvent[0]); + return new Pair, CLEvent[]>(input, new CLEvent[0]); } CLBuffer[] tempBuffers = new CLBuffer[2]; int depth = 0; - CLBuffer currentOutput = null; + CLBuffer

    currentOutput = null; CLEvent[] eventsArr = new CLEvent[1]; int[] blockCountArr = new int[1]; @@ -211,9 +186,9 @@ public Pair, CLEvent[]> reduceHelper(CLQueue queue, CLBuffer inpu int iOutput = depth & 1; CLBuffer currentInput = depth == 0 ? input : tempBuffers[iOutput ^ 1]; - currentOutput = (CLBuffer)tempBuffers[iOutput]; + currentOutput = (CLBuffer

    )tempBuffers[iOutput]; if (currentOutput == null) - currentOutput = (CLBuffer)(tempBuffers[iOutput] = context.createBuffer(CLMem.Usage.InputOutput, valueType.type, blocksInCurrentDepth * valueChannels)); + currentOutput = (CLBuffer

    )(tempBuffers[iOutput] = context.createBuffer(CLMem.Usage.InputOutput, input.getElementClass(), blocksInCurrentDepth * valueChannels)); synchronized (kernel) { kernel.setArgs(currentInput, (long)blocksInCurrentDepth, (long)inputLength, (long)maxReductionSize, currentOutput); @@ -227,7 +202,7 @@ public Pair, CLEvent[]> reduceHelper(CLQueue queue, CLBuffer inpu inputLength = blocksInCurrentDepth; depth++; } - return new Pair, CLEvent[]>(currentOutput, eventsToWaitFor); + return new Pair, CLEvent[]>(currentOutput, eventsToWaitFor); } }; diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Transformer.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Transformer.java index c747b52f..295faa0e 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Transformer.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/Transformer.java @@ -17,23 +17,20 @@ import java.nio.DoubleBuffer; import java.nio.FloatBuffer; -import org.bridj.*; -import static org.bridj.Pointer.*; - /** - * Generic homogeneous transformer class + * Generic homogen transformer class * @author ochafik + * @param NIO buffer class that represents the data consumed and produced by this transformer * @param primitive array class that represents the data consumed and produced by this transformer */ -public interface Transformer { +public interface Transformer { CLContext getContext(); A transform(CLQueue queue, A input, boolean inverse); - //B transform(CLQueue queue, B input, boolean inverse); - Pointer transform(CLQueue queue, Pointer input, boolean inverse); + B transform(CLQueue queue, B input, boolean inverse); CLEvent transform(CLQueue queue, CLBuffer input, CLBuffer output, boolean inverse, CLEvent... eventsToWaitFor) throws CLException; - long computeOutputSize(long inputSize); + int computeOutputSize(int inputSize); - public abstract class AbstractTransformer implements Transformer { + public abstract class AbstractTransformer implements Transformer { protected final Class primitiveClass; protected final CLContext context; @@ -44,17 +41,16 @@ public AbstractTransformer(CLContext context, Class primitiveClass) { public CLContext getContext() { return context; } - public long computeOutputSize(long inputSize) { + public int computeOutputSize(int inputSize) { return inputSize; } - public A transform(CLQueue queue, A input, boolean inverse) { - return (A)transform(queue, (Pointer)pointerToArray(input), inverse).getArray(); + return (A)NIOUtils.getArray(transform(queue, (B)NIOUtils.wrapArray(input), inverse)); } - public Pointer transform(CLQueue queue, Pointer in, boolean inverse) { - long inputSize = (int)in.getValidElements(); - long length = inputSize / 2; + public B transform(CLQueue queue, B in, boolean inverse) { + int inputSize = in.capacity(); + int length = inputSize / 2; CLBuffer inBuf = context.createBuffer(CLMem.Usage.Input, in, true); // true = copy CLBuffer outBuf = context.createBuffer(CLMem.Usage.Output, primitiveClass, computeOutputSize(inputSize)); @@ -62,7 +58,7 @@ public Pointer transform(CLQueue queue, Pointer in, boolean inverse) { CLEvent dftEvt = transform(queue, inBuf, outBuf, inverse); inBuf.release(); - Pointer out = outBuf.read(queue, dftEvt); + B out = (B)outBuf.read(queue, dftEvt); outBuf.release(); return out; } diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractDFT.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractDFT.java index 5d951e3b..00176cfa 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractDFT.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractDFT.java @@ -5,7 +5,7 @@ import java.io.IOException; import java.nio.Buffer; -abstract class AbstractDFT extends AbstractTransformer { +public abstract class AbstractDFT extends AbstractTransformer { // package-private constructor AbstractDFT(CLContext context, Class primitiveClass) throws IOException, CLException { diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractFFTPow2.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractFFTPow2.java index ed457af0..f1e09a97 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractFFTPow2.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/AbstractFFTPow2.java @@ -3,34 +3,34 @@ import com.nativelibs4java.opencl.*; import com.nativelibs4java.opencl.util.Transformer.AbstractTransformer; import com.nativelibs4java.util.NIOUtils; +import java.nio.Buffer; +import java.nio.IntBuffer; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import org.bridj.*; -import static org.bridj.Pointer.*; // TODO implement something like http://locklessinc.com/articles/non_power_of_2_fft/ -abstract class AbstractFFTPow2 extends AbstractTransformer { +public abstract class AbstractFFTPow2 extends AbstractTransformer { AbstractFFTPow2(CLContext context, Class primitiveClass) { super(context, primitiveClass); } - private Map> cachedOffsetsBufs = new HashMap>(); - protected synchronized CLBuffer getOffsetsBuf(int length) { - CLBuffer offsetsBuf = cachedOffsetsBufs.get(length); + private Map cachedOffsetsBufs = new HashMap(); + protected synchronized CLIntBuffer getOffsetsBuf(int length) { + CLIntBuffer offsetsBuf = cachedOffsetsBufs.get(length); if (offsetsBuf == null) { int[] offsets = new int[length]; fft_compute_offsetsX(offsets, length, 1, 0, 0); - offsetsBuf = context.createBuffer(CLMem.Usage.InputOutput, pointerToInts(offsets), true); + offsetsBuf = context.createIntBuffer(CLMem.Usage.InputOutput, IntBuffer.wrap(offsets), true); cachedOffsetsBufs.put(length, offsetsBuf); } return offsetsBuf; } protected abstract CLEvent cooleyTukeyFFTTwiddleFactors(CLQueue queue, int N, CLBuffer buf, CLEvent... evts) throws CLException ; - protected abstract CLEvent cooleyTukeyFFTCopy(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, int length, CLBuffer offsetsBuf, boolean inverse, CLEvent... evts) throws CLException; + protected abstract CLEvent cooleyTukeyFFTCopy(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, int length, CLIntBuffer offsetsBuf, boolean inverse, CLEvent... evts) throws CLException; protected abstract CLEvent cooleyTukeyFFT(CLQueue queue, CLBuffer Y, int N, CLBuffer twiddleFactors, int inverse, int[] dims, CLEvent... evts) throws CLException; Map> cachedTwiddleFactors = new HashMap>(); @@ -61,7 +61,7 @@ public CLEvent transform(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, b if (Integer.bitCount(length) != 1) throw new UnsupportedOperationException("Only supports FFTs of power-of-two-sized arrays (was given array of length " + length + ")"); - CLBuffer offsetsBuf = getOffsetsBuf(length); + CLIntBuffer offsetsBuf = getOffsetsBuf(length); CLEvent copyEvt = cooleyTukeyFFTCopy(queue, inBuf, outBuf, length, offsetsBuf, inverse, eventsToWaitFor); CLEvent dftEvt = fft(queue, inBuf, length, 1, inverse ? 1 : 0, 1, outBuf, copyEvt); return dftEvt; diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleDFT.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleDFT.java index 1c9ddde5..f8141e3f 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleDFT.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleDFT.java @@ -5,10 +5,7 @@ import java.io.IOException; import java.nio.DoubleBuffer; -/** - * Slow OpenCL Fourier Transform that works in all cases (double precision floating point numbers) - */ -public class DoubleDFT extends AbstractDFT { +public class DoubleDFT extends AbstractDFT { final DoubleDFTProgram program; @@ -22,6 +19,11 @@ public DoubleDFT() throws IOException { @Override protected CLEvent dft(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, int length, int sign, int[] dims, CLEvent... events) throws CLException { - return program.dft(queue, (CLBuffer)inBuf, (CLBuffer)outBuf, length, sign, dims, null, events); + return program.dft(queue, inBuf, outBuf, length, sign, dims, null, events); + } + + @Override + public double[] transform(CLQueue queue, double[] input, boolean inverse) { + return super.transform(queue, input, inverse); } } diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleFFTPow2.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleFFTPow2.java index f7c5f70e..8c9127f1 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleFFTPow2.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/DoubleFFTPow2.java @@ -5,10 +5,7 @@ import java.io.IOException; import java.nio.DoubleBuffer; -/** - * OpenCL Fast Fourier Transform for array sizes that are powers of two (double precision floating point numbers) - */ -public class DoubleFFTPow2 extends AbstractFFTPow2 { +public class DoubleFFTPow2 extends AbstractFFTPow2 { final DoubleFFTProgram program; @@ -24,7 +21,7 @@ public DoubleFFTPow2() throws IOException { protected CLEvent cooleyTukeyFFTTwiddleFactors(CLQueue queue, int N, CLBuffer buf, CLEvent... evts) throws CLException { return program.cooleyTukeyFFTTwiddleFactors(queue, N, buf, new int[] { N / 2 }, null, evts); } - protected CLEvent cooleyTukeyFFTCopy(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, int length, CLBuffer offsetsBuf, boolean inverse, CLEvent... evts) throws CLException { + protected CLEvent cooleyTukeyFFTCopy(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, int length, CLIntBuffer offsetsBuf, boolean inverse, CLEvent... evts) throws CLException { return program.cooleyTukeyFFTCopy(queue, inBuf, outBuf, length, offsetsBuf, inverse ? 1.0 / length : 1, new int[] { length }, null, evts); } protected CLEvent cooleyTukeyFFT(CLQueue queue, CLBuffer Y, int N, CLBuffer twiddleFactors, int inverse, int[] dims, CLEvent... evts) throws CLException { diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatDFT.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatDFT.java index e043ffa7..51a1cf66 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatDFT.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatDFT.java @@ -7,10 +7,7 @@ import java.io.IOException; import java.nio.FloatBuffer; -/** - * Slow OpenCL Fourier Transform that works in all cases (simple precision floating point numbers) - */ -public class FloatDFT extends AbstractDFT { +public class FloatDFT extends AbstractDFT { final FloatDFTProgram program; diff --git a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatFFTPow2.java b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatFFTPow2.java index 4207c709..3113f29c 100644 --- a/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatFFTPow2.java +++ b/JavaCL/src/main/java/com/nativelibs4java/opencl/util/fft/FloatFFTPow2.java @@ -4,10 +4,7 @@ import java.io.IOException; import java.nio.FloatBuffer; -/** - * OpenCL Fast Fourier Transform for array sizes that are powers of two (simple precision floating point numbers) - */ -public class FloatFFTPow2 extends AbstractFFTPow2 { +public class FloatFFTPow2 extends AbstractFFTPow2 { final FloatFFTProgram program; @@ -23,7 +20,7 @@ public FloatFFTPow2() throws IOException { protected CLEvent cooleyTukeyFFTTwiddleFactors(CLQueue queue, int N, CLBuffer buf, CLEvent... evts) throws CLException { return program.cooleyTukeyFFTTwiddleFactors(queue, N, buf, new int[] { N / 2 }, null, evts); } - protected CLEvent cooleyTukeyFFTCopy(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, int length, CLBuffer offsetsBuf, boolean inverse, CLEvent... evts) throws CLException { + protected CLEvent cooleyTukeyFFTCopy(CLQueue queue, CLBuffer inBuf, CLBuffer outBuf, int length, CLIntBuffer offsetsBuf, boolean inverse, CLEvent... evts) throws CLException { return program.cooleyTukeyFFTCopy(queue, inBuf, outBuf, length, offsetsBuf, inverse ? 1.0f / length : 1, new int[] { length }, null, evts); } protected CLEvent cooleyTukeyFFT(CLQueue queue, CLBuffer Y, int N, CLBuffer twiddleFactors, int inverse, int[] dims, CLEvent... evts) throws CLException { diff --git a/JavaCL/src/main/opencl/com/nativelibs4java/opencl/util/LinearAlgebraKernels.c b/JavaCL/src/main/opencl/com/nativelibs4java/opencl/util/LinearAlgebraKernels.c index 347772d5..0e55020f 100644 --- a/JavaCL/src/main/opencl/com/nativelibs4java/opencl/util/LinearAlgebraKernels.c +++ b/JavaCL/src/main/opencl/com/nativelibs4java/opencl/util/LinearAlgebraKernels.c @@ -1,6 +1,6 @@ #pragma OPENCL EXTENSION cl_khr_fp64: enable -__kernel void mulMatDouble( +__kernel void mulMat( __global const double* a, /*size_t aRows,*/ int aColumns, __global const double* b, /*size_t bRows,*/ int bColumns, __global double* c @@ -9,6 +9,7 @@ __kernel void mulMatDouble( int j = get_global_id(1); double total = 0; + // c[i, j] = sum(a[i, k] * b[k, j]) int iAOff = i * aColumns; for (int k = 0; k < aColumns; k++) { @@ -17,7 +18,7 @@ __kernel void mulMatDouble( c[i * bColumns + j] = total; } -__kernel void mulVecDouble( +__kernel void mulVec( __global const double* a, /*size_t aRows,*/ int aColumns, __global const double* b, int bSize, __global double* c @@ -33,60 +34,13 @@ __kernel void mulVecDouble( c[i] = total; } -__kernel void transposeDouble( +__kernel void transpose( __global const double* a, int aRows, int aColumns, __global double* out ) { int i = get_global_id(0); int j = get_global_id(1); - int outColumns = aRows; - out[i * outColumns + j] = a[j * aColumns + i]; -} - -__kernel void mulMatFloat( - __global const float* a, /*size_t aRows,*/ int aColumns, - __global const float* b, /*size_t bRows,*/ int bColumns, - __global float* c -) { - int i = get_global_id(0); - int j = get_global_id(1); - - float total = 0; - int iOff = i * aColumns; - for (int k = 0; k < aColumns; k++) { - total += a[iOff + k] * b[k * bColumns + j]; - } - c[i * bColumns + j] = total; - // c[0] = a[0];//total; - // c[1] = a[1];//total; - // c[2] = a[2];//total; - // c[3] = a[3];//total; -} - -__kernel void mulVecFloat( - __global const float* a, /*size_t aRows,*/ int aColumns, - __global const float* b, int bSize, - __global float* c -) { - int globalId = get_global_id(0); - int i = globalId; - - float total = 0; - int iOff = i * aColumns; - for (size_t k = 0; k < aColumns; k++) { - total += a[iOff + k] * b[k]; - } - c[i] = total; -} - -__kernel void transposeFloat( - __global const float* a, int aRows, int aColumns, - __global float* out -) { - int i = get_global_id(0); - int j = get_global_id(1); - int outColumns = aRows; out[i * outColumns + j] = a[j * aColumns + i]; } \ No newline at end of file diff --git a/JavaCL/src/test/java/com/nativelibs4java/opencl/generator/GeneratorTest.java b/JavaCL/src/test/java/com/nativelibs4java/opencl/generator/GeneratorTest.java deleted file mode 100644 index 917eaaa6..00000000 --- a/JavaCL/src/test/java/com/nativelibs4java/opencl/generator/GeneratorTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.nativelibs4java.opencl.generator; - -import com.nativelibs4java.opencl.CLBuffer; -import com.nativelibs4java.opencl.CLContext; -import com.nativelibs4java.opencl.CLEvent; -import com.nativelibs4java.opencl.CLMem; -import com.nativelibs4java.opencl.CLQueue; -import com.nativelibs4java.opencl.JavaCL; -import java.io.IOException; -import org.bridj.Pointer; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.Before; - -public class GeneratorTest { - CLContext context; - CLQueue queue; - Structs structs; - - @Before - public void setup() throws IOException { - context = JavaCL.createBestContext(); - queue = context.createDefaultQueue(); - structs = new Structs(context); - } - - @Test - public void testStructs() throws IOException { - Structs.S s = new Structs.S(); - Pointer pS = Pointer.getPointer(s); - CLBuffer b = context.createBuffer(CLMem.Usage.InputOutput, pS); - - CLEvent e = structs.f(queue, b, new int[] { 1 }, null); - b.read(queue, pS, true, e); - assertEquals(10, s.a()); - assertEquals(100, s.b()); - - s.a(1).b(2); - b.write(queue, pS, true); - e = structs.f(queue, b, new int[] { 1 }, null); - b.read(queue, pS, true, e); - assertEquals(12, s.a()); - assertEquals(120, s.b()); - - } - - @Test - public void testFloat3() { - float[] input = new float[] { 1, 2, 3 }; - CLBuffer outputBuffer = context.createFloatBuffer(CLMem.Usage.Output, 3); - CLEvent e = structs.g(queue, input, outputBuffer, new int[] { 1 }, null); - float[] output = outputBuffer.read(queue, e).getFloats(); - assertArrayEquals(input, output, 0.0f); - } -} \ No newline at end of file diff --git a/JavaCL/src/test/java/com/nativelibs4java/opencl/util/DiscreteFourierTransformTest.java b/JavaCL/src/test/java/com/nativelibs4java/opencl/util/DiscreteFourierTransformTest.java index 50e8d4bc..ee7ebce4 100644 --- a/JavaCL/src/test/java/com/nativelibs4java/opencl/util/DiscreteFourierTransformTest.java +++ b/JavaCL/src/test/java/com/nativelibs4java/opencl/util/DiscreteFourierTransformTest.java @@ -70,7 +70,7 @@ static void assertArrayEquals(String title, Object a, Object b) { static Collection createTestDoubleInputs() { Collection ret = new ArrayList(); - for (int n : new int[] { 1, 2, 4, 8, 16, 1024 }) { + for (int n : new int[] { 1024, 1, 2, 4, 8, 16 }) { double[] in = new double[2 * n]; for (int i = 0; i < n; i++) { @@ -103,7 +103,7 @@ static double[] scale(double factor, double[] in) { return out; } - public void testDoubleValues(String title, Transformer tr) { + public void testDoubleValues(String title, Transformer tr) { FastFourierTransformer apache = new FastFourierTransformer(); CLQueue queue = tr.getContext() == null ? null : tr.getContext().createDefaultOutOfOrderQueueIfPossible(); for (double[] data : createTestDoubleInputs()) { @@ -111,7 +111,7 @@ public void testDoubleValues(String title, Transformer tr) { assertArrayEquals(title + " (n = " + (data.length / 2) + ")", expected, tr.transform(queue, data, false), precisionDouble); } } - public void testFloatValues(String title, Transformer tr) { + public void testFloatValues(String title, Transformer tr) { FastFourierTransformer apache = new FastFourierTransformer(); CLQueue queue = tr.getContext() == null ? null : tr.getContext().createDefaultOutOfOrderQueueIfPossible(); for (double[] data : createTestDoubleInputs()) { @@ -155,7 +155,7 @@ public void testDoubleFFTInverse() throws IOException, CLException { public void testFloatFFTInverse() throws IOException, CLException { testFloatTransformer("Float FFT Inverse", new FloatFFTPow2()); } - void testDoubleTransformer(String title, Transformer t) throws IOException, CLException { + void testDoubleTransformer(String title, Transformer t) throws IOException, CLException { CLQueue queue = t.getContext().createDefaultOutOfOrderQueueIfPossible(); //System.out.println("Context: " + t.getContext()); for (double[] in : createTestDoubleInputs()) { @@ -164,7 +164,7 @@ void testDoubleTransformer(String title, Transformer t) throws assertArrayEquals(title + " (n = " + (in.length / 2) + ")", in, back, precisionInverseDouble); } } - void testFloatTransformer(String title, Transformer t) throws IOException, CLException { + void testFloatTransformer(String title, Transformer t) throws IOException, CLException { CLQueue queue = t.getContext().createDefaultOutOfOrderQueueIfPossible(); //System.out.println("Context: " + t.getContext()); for (float[] in : createTestFloatInputs()) { diff --git a/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ParallelRandomTest.java b/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ParallelRandomTest.java index fd642cbb..9dd4d3be 100644 --- a/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ParallelRandomTest.java +++ b/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ParallelRandomTest.java @@ -1,9 +1,7 @@ package com.nativelibs4java.opencl.util; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - import com.nativelibs4java.opencl.JavaCL; +import java.nio.IntBuffer; import org.junit.Assert; import org.junit.Test; @@ -37,7 +35,7 @@ public void testPICircle() { int nInside = 0, nTotalPoints = 0; for (int iLoop = 0; iLoop < nLoops; iLoop++) { - Pointer values = random.next(); + IntBuffer values = random.next(); for (int iPoint = 0; iPoint < nPoints; iPoint++) { int offset = iPoint * 2; int ix = values.get(offset), iy = values.get(offset + 1); diff --git a/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ReductionTest.java b/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ReductionTest.java index 6d62b14a..be5512e1 100644 --- a/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ReductionTest.java +++ b/JavaCL/src/test/java/com/nativelibs4java/opencl/util/ReductionTest.java @@ -6,9 +6,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; import java.util.Arrays; +import java.nio.IntBuffer; +import java.nio.FloatBuffer; import org.junit.Before; import org.junit.BeforeClass; @@ -19,10 +19,10 @@ public class ReductionTest { - //@BeforeClass - //public static void setup() { - // com.sun.jna.Native.setProtected(true); - //} + @BeforeClass + public static void setup() { + com.sun.jna.Native.setProtected(true); + } CLContext context; CLQueue queue; @@ -38,22 +38,22 @@ public void init() { @Test public void testMinMax() { try { - CLBuffer input = context.createBuffer(CLMem.Usage.Input, pointerToInts( + CLIntBuffer input = context.createIntBuffer(CLMem.Usage.Input, IntBuffer.wrap(new int[] { 1110, 22, 35535, 3, 1 - ), true); + }), true); int maxReductionSize = 2; - Pointer result = allocateInt().order(context.getByteOrder()); + IntBuffer result = NIOUtils.directInts(1, context.getByteOrder()); Reductor reductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Min, OpenCLType.Int, 1); reductor.reduce(queue, input, input.getElementCount(), result, maxReductionSize); queue.finish(); - assertEquals(1, (int)result.get()); + assertEquals(1, result.get(0)); reductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Max, OpenCLType.Int, 1); reductor.reduce(queue, input, input.getElementCount(), result, maxReductionSize); queue.finish(); - assertEquals(35535, (int)result.get()); + assertEquals(35535, result.get(0)); } catch (Exception ex) { ex.printStackTrace(); @@ -69,7 +69,7 @@ public void testIssue26() { for (int i = 0; i < array.length; i++) array[i] = 1; - CLBuffer clBufferInput = context.createBuffer(CLMem.Usage.Input, pointerToFloats(array), true); + CLBuffer clBufferInput = context.createFloatBuffer(CLMem.Usage.Input, FloatBuffer.wrap(array), true); ReductionUtils.Reductor reductor = ReductionUtils.createReductor( context, @@ -77,7 +77,7 @@ public void testIssue26() { OpenCLType.Float, 1 ); - Pointer result = reductor.reduce(queue, clBufferInput, 4097, 64); + FloatBuffer result = reductor.reduce(queue, clBufferInput, 4097, 64); float sum = result.get(0); float expected = 4097; System.err.println("[Test of issue 26] Expected " + expected + ", got " + sum); @@ -94,20 +94,20 @@ public void testAddReduction() { int channels = 1; int maxReductionSize = 64; - Pointer inBuf = allocateInts(channels * dataSize).order(context.getByteOrder()); + IntBuffer inBuf = NIOUtils.directInts(channels * dataSize, context.getByteOrder()); for (int i = 0; i < dataSize; i++) { for (int c = 0; c < channels; c++) - inBuf.set(i * channels + c, i); + inBuf.put(i * channels + c, i); } - CLBuffer in = context.createBuffer(CLMem.Usage.Input, Integer.class, channels * dataSize); + CLIntBuffer in = context.createIntBuffer(CLMem.Usage.Input, channels * dataSize); in.write(queue, inBuf, true); - Pointer check = in.read(queue); + IntBuffer check = in.read(queue); for (int i = 0; i < dataSize; i++) - assertEquals((int)inBuf.get(i), (int)check.get(i)); + assertEquals(inBuf.get(i), check.get(i)); - Pointer out = allocateInts(channels).order(context.getByteOrder()); + IntBuffer out = NIOUtils.directInts(channels, context.getByteOrder()); Reductor reductor = ReductionUtils.createReductor(context, ReductionUtils.Operation.Add, OpenCLType.Int, channels); diff --git a/JavaCL/src/test/opencl/com/nativelibs4java/opencl/generator/Structs.c b/JavaCL/src/test/opencl/com/nativelibs4java/opencl/generator/Structs.c deleted file mode 100644 index fa1e8dba..00000000 --- a/JavaCL/src/test/opencl/com/nativelibs4java/opencl/generator/Structs.c +++ /dev/null @@ -1,14 +0,0 @@ -typedef struct _S { - int a, b; -} S; - -kernel void f(__global S *pS) { - pS->a = pS->a * 2 + 10; - pS->b = pS->b * 10 + 100; -} - -kernel void g(float3 floats, __global float *out) { - out[0] = floats.x; - out[1] = floats.y; - out[2] = floats.z; -} \ No newline at end of file diff --git a/Blas/.gitignore b/JavaCLTutorial/.gitignore similarity index 100% rename from Blas/.gitignore rename to JavaCLTutorial/.gitignore diff --git a/Tutorials/DFT/pom.xml b/JavaCLTutorial/pom.xml similarity index 52% rename from Tutorials/DFT/pom.xml rename to JavaCLTutorial/pom.xml index e1bcaef2..4eeef46c 100644 --- a/Tutorials/DFT/pom.xml +++ b/JavaCLTutorial/pom.xml @@ -2,35 +2,51 @@ 4.0.0 com.nativelibs4java - javacl-dft-tutorial - JavaCL Tutorial + javacl-tutorial-jna + JavaCL Tutorial / JNA http://code.google.com/p/javacl/ + 1.0.0-RC4 jar - + com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - ../.. + javacl-parent-jna + 1.0.0-RC4 + .. com.nativelibs4java - javacl + javacl-jna org.apache.commons commons-math 2.2 + + org.scala-lang + scala-library + com.nativelibs4java - maven-javacl-plugin + javacl-generator-jna + + + + compile + + + + + + net.alchim31.maven + scala-maven-plugin org.apache.maven.plugins @@ -38,6 +54,16 @@ + + + + + net.alchim31.maven + scala-maven-plugin + + + + diff --git a/Tutorials/DFT/src/main/java/tutorial/DFT.java b/JavaCLTutorial/src/main/java/tutorial/DFT.java similarity index 86% rename from Tutorials/DFT/src/main/java/tutorial/DFT.java rename to JavaCLTutorial/src/main/java/tutorial/DFT.java index cddafe1e..b20a0dad 100644 --- a/Tutorials/DFT/src/main/java/tutorial/DFT.java +++ b/JavaCLTutorial/src/main/java/tutorial/DFT.java @@ -5,7 +5,6 @@ import com.nativelibs4java.util.*; import java.io.IOException; import java.nio.DoubleBuffer; -import org.bridj.Pointer; public class DFT { @@ -28,15 +27,15 @@ public DFT(CLQueue queue) throws IOException, CLBuildException { * returns the Discrete Fourier Transform of these values if forward == true or the inverse * transform if forward == false. */ - public synchronized Pointer dft(Pointer in, boolean forward) { - assert in.getValidElements() % 2 == 0; - int length = (int)in.getValidElements() / 2; + public synchronized DoubleBuffer dft(DoubleBuffer in, boolean forward) { + assert in.capacity() % 2 == 0; + int length = in.capacity() / 2; // Create an input CLBuffer that will be a copy of the NIO buffer : - CLBuffer inBuf = context.createDoubleBuffer(CLMem.Usage.Input, in, true); // true = copy + CLDoubleBuffer inBuf = context.createDoubleBuffer(CLMem.Usage.Input, in, true); // true = copy // Create an output CLBuffer : - CLBuffer outBuf = context.createDoubleBuffer(CLMem.Usage.Output, length * 2); + CLDoubleBuffer outBuf = context.createDoubleBuffer(CLMem.Usage.Output, length * 2); // Set the args of the kernel : kernel.setArgs(inBuf, outBuf, length, forward ? 1 : -1); @@ -50,8 +49,10 @@ public synchronized Pointer dft(Pointer in, boolean forward) { /// Wrapper method that takes and returns double arrays public double[] dft(double[] complexValues, boolean forward) { - Pointer outBuffer = dft(Pointer.pointerToDoubles(complexValues), forward); - return outBuffer.getDoubles(); + DoubleBuffer outBuffer = dft(DoubleBuffer.wrap(complexValues), forward); + double[] out = new double[complexValues.length]; + outBuffer.get(out); + return out; } public static void main(String[] args) throws IOException, CLBuildException { diff --git a/Tutorials/DFT/src/main/java/tutorial/DFT2.java b/JavaCLTutorial/src/main/java/tutorial/DFT2.java similarity index 62% rename from Tutorials/DFT/src/main/java/tutorial/DFT2.java rename to JavaCLTutorial/src/main/java/tutorial/DFT2.java index 5b617d65..ba5d1005 100644 --- a/Tutorials/DFT/src/main/java/tutorial/DFT2.java +++ b/JavaCLTutorial/src/main/java/tutorial/DFT2.java @@ -3,7 +3,6 @@ import com.nativelibs4java.opencl.*; import java.io.IOException; import java.nio.DoubleBuffer; -import org.bridj.Pointer; public class DFT2 { @@ -17,12 +16,12 @@ public DFT2(CLQueue queue) throws IOException, CLBuildException { this.program = new DiscreteFourierTransformProgram(context); } - public synchronized Pointer dft(Pointer in, boolean forward) throws CLBuildException { - assert in.getValidElements() % 2 == 0; - int length = (int)in.getValidElements() / 2; + public synchronized DoubleBuffer dft(DoubleBuffer in, boolean forward) throws CLBuildException { + assert in.capacity() % 2 == 0; + int length = in.capacity() / 2; - CLBuffer inBuf = context.createDoubleBuffer(CLMem.Usage.Input, in, true); // true = copy - CLBuffer outBuf = context.createDoubleBuffer(CLMem.Usage.Output, length * 2); + CLDoubleBuffer inBuf = context.createDoubleBuffer(CLMem.Usage.Input, in, true); // true = copy + CLDoubleBuffer outBuf = context.createDoubleBuffer(CLMem.Usage.Output, length * 2); // The following call is type-safe, thanks to the JavaCL Maven generator : // (if the OpenCL function signature changes, the generated Java definition will be updated and compilation will fail) @@ -31,7 +30,9 @@ public synchronized Pointer dft(Pointer in, boolean forward) thr } public double[] dft(double[] complexValues, boolean forward) throws CLBuildException { - Pointer outBuffer = dft(Pointer.pointerToDoubles(complexValues), forward); - return outBuffer.getDoubles(); + DoubleBuffer outBuffer = dft(DoubleBuffer.wrap(complexValues), forward); + double[] out = new double[complexValues.length]; + outBuffer.get(out); + return out; } } diff --git a/Tutorials/DFT/src/main/opencl/tutorial/DiscreteFourierTransformProgram.c b/JavaCLTutorial/src/main/opencl/tutorial/DiscreteFourierTransformProgram.c similarity index 100% rename from Tutorials/DFT/src/main/opencl/tutorial/DiscreteFourierTransformProgram.c rename to JavaCLTutorial/src/main/opencl/tutorial/DiscreteFourierTransformProgram.c diff --git a/Tutorials/DFT/src/main/opencl/tutorial/DiscreteFourierTransformProgram.cl b/JavaCLTutorial/src/main/opencl/tutorial/DiscreteFourierTransformProgram.cl similarity index 100% rename from Tutorials/DFT/src/main/opencl/tutorial/DiscreteFourierTransformProgram.cl rename to JavaCLTutorial/src/main/opencl/tutorial/DiscreteFourierTransformProgram.cl diff --git a/LICENSE b/LICENSE deleted file mode 100644 index b92be7b9..00000000 --- a/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2015, Olivier Chafik -All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Olivier Chafik nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LibCL/.gitignore b/LibCL/.gitignore deleted file mode 100644 index 8e0d5325..00000000 --- a/LibCL/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -project/boot -project/target -*~ diff --git a/LibCL/libcl-bridj.iml b/LibCL/libcl-bridj.iml deleted file mode 100644 index 2a63f7cf..00000000 --- a/LibCL/libcl-bridj.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/LibCL/libcl.iml b/LibCL/libcl.iml deleted file mode 100644 index c51ad6a8..00000000 --- a/LibCL/libcl.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/LibCL/pom.xml b/LibCL/pom.xml deleted file mode 100644 index 52ad5064..00000000 --- a/LibCL/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - 4.0.0 - com.nativelibs4java - libcl - LibCL - http://code.google.com/p/javacl/ - jar - - - Library of OpenCL functions for easy use from JavaCL - - - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - .. - - - - - - diff --git a/LibCL/src/main/resources/LibCL/Bits.cl b/LibCL/src/main/resources/LibCL/Bits.cl deleted file mode 100644 index 25bd8e19..00000000 --- a/LibCL/src/main/resources/LibCL/Bits.cl +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _LIBCL_BITS_CL_ -#define _LIBCL_BITS_CL_ - -/** - * SWAR algorithm - * http://stackoverflow.com/questions/109023/best-algorithm-to-count-the-number-of-set-bits-in-a-32-bit-integer - */ -int countBitsInInt(int i) -{ - i = i - ((i >> 1) & 0x55555555); - i = (i & 0x33333333) + ((i >> 2) & 0x33333333); - return ((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; -} - -#define _LIBCL_BITS_CL_ diff --git a/LibCL/src/main/resources/LibCL/Gaussian7x7.cl b/LibCL/src/main/resources/LibCL/Gaussian7x7.cl deleted file mode 100644 index 9bf1121d..00000000 --- a/LibCL/src/main/resources/LibCL/Gaussian7x7.cl +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _LIBCL_GAUSSIAN_7x7_CL_ -#define _LIBCL_GAUSSIAN_7x7_CL_ - -// Matrix values taken from http://en.wikipedia.org/wiki/Gaussian_blur : -__constant float gaussian7x7Matrix[] = { - 0.00000067f, 0.00002292f, 0.00019117f, 0.00038771f, 0.00019117f, 0.00002292f, 0.00000067f, - 0.00002292f, 0.00078633f, 0.00655965f, 0.01330373f, 0.00655965f, 0.00078633f, 0.00002292f, - 0.00019117f, 0.00655965f, 0.05472157f, 0.11098164f, 0.05472157f, 0.00655965f, 0.00019117f, - 0.00038771f, 0.01330373f, 0.11098164f, 0.22508352f, 0.11098164f, 0.01330373f, 0.00038771f, - 0.00019117f, 0.00655965f, 0.05472157f, 0.11098164f, 0.05472157f, 0.00655965f, 0.00019117f, - 0.00002292f, 0.00078633f, 0.00655965f, 0.01330373f, 0.00655965f, 0.00078633f, 0.00002292f, - 0.00000067f, 0.00002292f, 0.00019117f, 0.00038771f, 0.00019117f, 0.00002292f, 0.00000067f -}; - - -#endif // _LIBCL_GAUSSIAN_7x7_CL_ diff --git a/LibCL/src/main/resources/LibCL/ImageConvert.cl b/LibCL/src/main/resources/LibCL/ImageConvert.cl deleted file mode 100644 index c3ff97cc..00000000 --- a/LibCL/src/main/resources/LibCL/ImageConvert.cl +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _LIBCL_IMAGE_CONVERT_CL_ -#define _LIBCL_IMAGE_CONVERT_CL_ - -__constant float4 luminanceDot = ((float4)(1 / 3.f, 1 / 3.f, 1 / 3.f, 0)); - -void convertFloatRGBImageToGray( - read_only image2d_t inputImage, - write_only image2d_t outputImage) -{ - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - int x = get_global_id(0), y = get_global_id(1); - - int2 coords = (int2)(x, y); - float4 pixel = read_imagef(inputImage, sampler, coords); - float luminance = dot(luminanceDot, pixel); - write_imagef(outputImage, coords, (float4)(luminance, luminance, luminance, 1)); -} - -#endif // _LIBCL_IMAGE_CONVERT_CL_ diff --git a/LibCL/src/main/resources/LibCL/ImageConvolution.cl b/LibCL/src/main/resources/LibCL/ImageConvolution.cl deleted file mode 100644 index 5d2caedd..00000000 --- a/LibCL/src/main/resources/LibCL/ImageConvolution.cl +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef _LIBCL_IMAGE_CONVOLUTION_CL_ -#define _LIBCL_IMAGE_CONVOLUTION_CL_ - -/** - * Compute convolution result for pixel (x, y) separately on each of the 4 pixel channels. - * @param x X coordinate of the resulting convolved pixel - * @param y Y coordinate of the resulting convolved pixel - * @param matrix Pointer to the convolution matrix - * @param matrixSize Width and height of the convolution matrix (3 for a 3x3 matrix) - * @returns Convolution result - */ -float4 convolveFloatImagePixel( - read_only image2d_t inputImage, - int x, int y, - __constant float* matrix, - int matrixSize) -{ - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - - float4 total = (float4)0; - int matrixCenterOffset = matrixSize / 2; - - for (int dy = 0; dy < matrixSize; dy++) { - int offset = dy * matrixSize; - for (int dx = 0; dx < matrixSize; dx++) { - float4 pixel = read_imagef(inputImage, sampler, (int2)(x + dx - matrixCenterOffset, y + dy - matrixCenterOffset)); - float factor = matrix[offset + dx]; - total += factor * pixel; - } - } - return total; -} - -/** - * Compute convolution result for pixel (x, y) with a different convolution matrix on all 4 channels. - * @param x X coordinate of the resulting convolved pixel - * @param y Y coordinate of the resulting convolved pixel - * @param matrixX Pointer to the convolution matrix for channel x - * @param matrixY Pointer to the convolution matrix for channel y - * @param matrixZ Pointer to the convolution matrix for channel z - * @param matrixW Pointer to the convolution matrix for channel w - * @param matrixSize Width and height of the convolution matrices (3 for a 3x3 matrix) - * @returns Convolution result - */ -float4 convolveFloatImagePixelChannels( - read_only image2d_t inputImage, - int x, int y, - __constant float* matrixX, - __constant float* matrixY, - __constant float* matrixZ, - __constant float* matrixW, - int matrixSize) -{ - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - - float4 total = (float4)0; - int matrixCenterOffset = matrixSize / 2; - - for (int dy = 0; dy < matrixSize; dy++) { - int offset = dy * matrixSize; - for (int dx = 0; dx < matrixSize; dx++) { - float4 pixel = read_imagef(inputImage, sampler, (int2)(x + dx - matrixCenterOffset, y + dy - matrixCenterOffset)); - int pos = offset + dx; - float4 factors = (float4)(matrixX[pos], matrixY[pos], matrixZ[pos], matrixW[pos]); - total += factors * pixel; - } - } - return total; -} - -/** - * Compute convolution result for pixel (x, y), using only the x component of all input pixels. - * @param x X coordinate of the resulting convolved pixel - * @param y Y coordinate of the resulting convolved pixel - * @param matrix Pointer to the convolution matrix - * @param matrixSize Width and height of the convolution matrix (3 for a 3x3 matrix) - * @returns Convolution result - */ -float convolveFloatImagePixelX( - read_only image2d_t inputImage, - int x, int y, - __constant float* matrix, - int matrixSize) -{ - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - - float total = 0; - int matrixCenterOffset = matrixSize / 2; - - for (int dy = 0; dy < matrixSize; dy++) { - int offset = dy * matrixSize; - for (int dx = 0; dx < matrixSize; dx++) { - float4 pixel = read_imagef(inputImage, sampler, (int2)(x + dx - matrixCenterOffset, y + dy - matrixCenterOffset)); - float factor = matrix[offset + dx]; - total += factor * pixel.x; - } - } - return total; -} - -/** - * Compute convolution result for pixel (x, y), using the average of the x, y and z channels as input (luminance, if the pixel is RGBA). - * @param x X coordinate of the resulting convolved pixel - * @param y Y coordinate of the resulting convolved pixel - * @param matrix Pointer to the convolution matrix - * @param matrixSize Width and height of the convolution matrix (3 for a 3x3 matrix) - * @returns Convolution result - */ -float convolveFloatImagePixelGray( - read_only image2d_t inputImage, - int x, int y, - __constant float* matrix, - int matrixSize) -{ - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - - float total = 0; - int matrixCenterOffset = matrixSize / 2; - - const float4 luminanceDot = (float4)(1/3.f, 1/3.f, 1/3.f, 0); - for (int dy = 0; dy < matrixSize; dy++) { - int offset = dy * matrixSize; - for (int dx = 0; dx < matrixSize; dx++) { - float4 pixel = read_imagef(inputImage, sampler, (int2)(x + dx - matrixCenterOffset, y + dy - matrixCenterOffset)); - float factor = matrix[offset + dx]; - total += factor * dot(luminanceDot, pixel); - } - } - return total; -} - -/** - * Compute convolution results for pixel (x, y), using the average of the x, y and z channels as input (luminance, if the pixel is RGBA) and two different convolution matrices (interleaved in float2 cells). - * @param x X coordinate of the resulting convolved pixel - * @param y Y coordinate of the resulting convolved pixel - * @param matrix Pointer to the convolution matrices (two matrices are interleaved in this matrix's cell values components) - * @param matrixSize Width and height of the convolution matrix (3 for a 3x3 matrix) - * @returns Convolution results - */ -float2 convolveFloatImagePixelGray2( - read_only image2d_t inputImage, - int x, int y, - __constant float2* matrix, - int matrixSize) -{ - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - - float2 total = (float2)0; - int matrixCenterOffset = matrixSize / 2; - - const float4 luminanceDot = (float4)(1/3.f, 1/3.f, 1/3.f, 0); - for (int dy = 0; dy < matrixSize; dy++) { - int offset = dy * matrixSize; - for (int dx = 0; dx < matrixSize; dx++) { - float4 pixel = read_imagef(inputImage, sampler, (int2)(x + dx - matrixCenterOffset, y + dy - matrixCenterOffset)); - float2 factor = matrix[offset + dx]; - total += factor * dot(luminanceDot, pixel); - } - } - return total; -} - -/** - * Compute the convolution of an image with a convolution matrix. - * The resulting image will have a constant w channel (typically, alpha) set to 1. - * @param matrix Pointer to the convolution matrix - * @param matrixSize Width and height of the convolution matrix (3 for a 3x3 matrix) - */ -void convolveFloatImage( - read_only image2d_t inputImage, - __constant float* matrix, - int matrixSize, - write_only image2d_t outputImage) -{ - int x = get_global_id(0), y = get_global_id(1); - - float4 total = convolveFloatImagePixel(inputImage, x, y, matrix, matrixSize); - - // Transparent images are not very useful ! - total.w = 1; - write_imagef(outputImage, (int2)(x, y), total); -} - -/** - * Compute the convolution of an image with a different convolution matrix on each of the 4 pixel channels. - * @param matrixX Pointer to the convolution matrix for channel x - * @param matrixY Pointer to the convolution matrix for channel y - * @param matrixZ Pointer to the convolution matrix for channel z - * @param matrixW Pointer to the convolution matrix for channel w - * @param matrixSize Width and height of the convolution matrix (3 for a 3x3 matrix) - */ -void convolveFloatImageChannels( - read_only image2d_t inputImage, - __constant float* matrixX, - __constant float* matrixY, - __constant float* matrixZ, - __constant float* matrixW, - int matrixSize, - write_only image2d_t outputImage) -{ - int x = get_global_id(0), y = get_global_id(1); - - float4 total = convolveFloatImagePixelChannels(inputImage, x, y, matrixX, matrixY, matrixZ, matrixW, matrixSize); - total.w = 1; - write_imagef(outputImage, (int2)(x, y), total); -} - -#endif // _LIBCL_IMAGE_CONVOLUTION_CL_ diff --git a/LibCL/src/main/resources/LibCL/RichardsonLucyImageDeconvolution.cl b/LibCL/src/main/resources/LibCL/RichardsonLucyImageDeconvolution.cl deleted file mode 100644 index 9126d5d7..00000000 --- a/LibCL/src/main/resources/LibCL/RichardsonLucyImageDeconvolution.cl +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef _LIBCL_RICHARDSON_LUCY_IMAGE_DECONVOLUTION_CL_ -#define _LIBCL_RICHARDSON_LUCY_IMAGE_DECONVOLUTION_CL_ - -#include "LibCL/ImageConvolution.cl" -#include "LibCL/ImageConvert.cl" - -// Convert image to grayscale -void richardsonLucyDeconvolutionPre1(read_only image2d_t inputImage, write_only image2d_t outputImage) -{ - convertFloatRGBImageToGray(inputImage, outputImage); -} - -// Put I factors in w (alpha) channel -void richardsonLucyDeconvolutionPre2(read_only image2d_t inputImage, __constant float* matrix, int matrixSize, write_only image2d_t outputImage) -{ - int x = get_global_id(0), y = get_global_id(1); - float conv = convolveFloatImagePixelX(inputImage, x, y, matrix, matrixSize); - - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - - int2 coords = (int2)(x, y); - float4 pixel = read_imagef(inputImage, sampler, coords); - pixel.w = conv; - write_imagef(outputImage, coords, pixel); -} - -// Put x into xyz and set w to 1 (make the image look grey again !) -void richardsonLucyDeconvolutionPost(read_only image2d_t inputImage, write_only image2d_t outputImage) -{ - int x = get_global_id(0), y = get_global_id(1); - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - - int2 coords = (int2)(x, y); - float4 pixel = read_imagef(inputImage, sampler, coords); - pixel.y = pixel.z = pixel.x; - pixel.w = 1; - write_imagef(outputImage, coords, pixel); -} - -void richardsonLucyDeconvolutionPass( - read_only image2d_t inputImage, - __constant float* matrix, - int matrixSize, - write_only image2d_t outputImage) -{ - int x = get_global_id(0), y = get_global_id(1); - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - const int matrixCenterOffset = matrixSize / 2; - - float total = 0; - for (int dy = 0; dy < matrixSize; dy++) { - int offset = dy * matrixSize; - for (int dx = 0; dx < matrixSize; dx++) { - float4 pixel = read_imagef(inputImage, sampler, (int2)(x + dx - matrixCenterOffset, y + dy - matrixCenterOffset)); - float factor = matrix[offset + dx]; - total += factor * pixel.x / pixel.w; - } - } - - int2 coords = (int2)(x, y); - float4 pixel = read_imagef(inputImage, sampler, coords); - pixel.x *= total; - write_imagef(outputImage, coords, pixel); -} - -#define RICHARDSON_LUCY_DECONVOLUTION_PRE(matrix, matrixSize) \ - __kernel void pre1(read_only image2d_t inputImage, write_only image2d_t outputImage) { richardsonLucyDeconvolutionPre1(inputImage, outputImage); } \ - __kernel void pre2(read_only image2d_t inputImage, write_only image2d_t outputImage) { richardsonLucyDeconvolutionPre2(inputImage, matrix, matrixSize, outputImage); } - -#define RICHARDSON_LUCY_DECONVOLUTION_PASS(matrix, matrixSize, n) \ - __kernel void deconvolvePass ## n(read_only image2d_t inputImage, write_only image2d_t outputImage) { richardsonLucyDeconvolutionPass(inputImage, matrix, matrixSize, outputImage); } - -#define RICHARDSON_LUCY_DECONVOLUTION_POST() \ - __kernel void post(read_only image2d_t inputImage, write_only image2d_t outputImage) { richardsonLucyDeconvolutionPost(inputImage, outputImage); } - -#endif _LIBCL_RICHARDSON_LUCY_IMAGE_DECONVOLUTION_CL_ - diff --git a/LibCL/src/main/resources/LibCL/SobelOperator.cl b/LibCL/src/main/resources/LibCL/SobelOperator.cl deleted file mode 100644 index ccad0de8..00000000 --- a/LibCL/src/main/resources/LibCL/SobelOperator.cl +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _LIBCL_SOBEL_OPERATOR_CL_ -#define _LIBCL_SOBEL_OPERATOR_CL_ - -/** - Sobel operator - See http://en.wikipedia.org/wiki/Sobel_operator - Written by Olivier Chafik, no right reserved :-) */ - -/** - * Return (float2)(gradient, angle) of Sobel operator applied at given pixel. - */ -inline float2 sobelOperatorRGBFloat( - read_only image2d_t inputImage, - int x, - int y) -{ - const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; - -#define PIXEL_CONTRIB(dx, dy, coefX, coefY) \ - {\ - float4 pixel = read_imagef(inputImage, sampler, (int2)(x + dx, y + dy)); \ - total += (float2)(coefX, coefY) * (float2)(((pixel.x + (int)pixel.y + (int)pixel.z) / 3.f) * pixel.w); \ - } - - float2 total = (float2)0; - -#define MX_NW 1 -#define MX_N 2 -#define MX_NE 1 -#define MX_W 0 -#define MX_C 0 -#define MX_E 0 -#define MX_SW -1 -#define MX_S -2 -#define MX_SE -1 - -#define MY_NW 1 -#define MY_N 0 -#define MY_NE -1 -#define MY_W 2 -#define MY_C 0 -#define MY_E -2 -#define MY_SW 1 -#define MY_S 0 -#define MY_SE -1 - - PIXEL_CONTRIB(-1, -1, MX_NW, MY_NW); - PIXEL_CONTRIB(0, -1, MX_N, MY_N); - PIXEL_CONTRIB(1, -1, MX_NE, MY_NE); - PIXEL_CONTRIB(-1, 0, MX_W, MY_W); - PIXEL_CONTRIB(0, 0, MX_C, MY_C); - PIXEL_CONTRIB(1, 0, MX_E, MY_E); - PIXEL_CONTRIB(-1, 1, MX_SW, MY_SW); - PIXEL_CONTRIB(0, 1, MX_S, MY_S); - PIXEL_CONTRIB(1, 1, MX_SE, MY_SE); - - float gradient = length(total); - float direction = atan2(total.y, total.x); - - return (float2)(gradient, direction); -} - -#endif // _LIBCL_SOBEL_OPERATOR_CL_ diff --git a/LibCL/src/main/resources/LibCL/hsla2rgba.cl b/LibCL/src/main/resources/LibCL/hsla2rgba.cl deleted file mode 100644 index 9eb4863c..00000000 --- a/LibCL/src/main/resources/LibCL/hsla2rgba.cl +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _LIBCL_HSLA_2_RGBA_CL_ -#define _LIBCL_HSLA_2_RGBA_CL_ - -inline float hsla2rgba_sub(float x, float y, float z) { - if (z < 0) - z += 1.f; - else if (z > 1) - z -= 1.f; - - if (6 * z < 1) - return x + (y - x) * 6 * z; - if (2 * z < 1) - return y; - if (3 * z < 2) - return x + (y - x) * ((2.f / 3.f) - z) * 6; - return x; -} - -inline float4 hsla2rgba(float4 hsla) { - float - h = hsla.x, - s = hsla.y, - l = hsla.z, - a = hsla.w; - - float r, g, b; - if (s == 0) - r = g = b = l; - else { - float y; - if (l < 0.5f) - y = l * (1.0f + s); - else - y = l + s - l * s; - float x = 2.0f * l - y; - - r = hsla2rgba_sub(x, y, h + 1.f / 3.f); - g = hsla2rgba_sub(x, y, h); - b = hsla2rgba_sub(x, y, h - 1.f / 3.f); - } - return (float4)(r, g, b, a); -} - -#endif // _LIBCL_HSLA_2_RGBA_CL_ diff --git a/LibCL/src/main/resources/LibCL/rgba2hsla.cl b/LibCL/src/main/resources/LibCL/rgba2hsla.cl deleted file mode 100644 index 8dcd76e5..00000000 --- a/LibCL/src/main/resources/LibCL/rgba2hsla.cl +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _LIBCL_RGBA_2_HSLA_CL_ -#define _LIBCL_RGBA_2_HSLA_CL_ - -inline float4 rgba2hsla(float4 rgba) { - float - r = rgba.x, - g = rgba.y, - b = rgba.z, - a = rgba.w; - - float mn = min(r, min(g, b)); - float mx = max(r, max(g, b)); - - float l = (mn + mx) / 2.f; - float s, h; - if (mn == mx) { - s = h = 0; - } else { - float diff = mx - mn; - float sum = mx + mn; - if (l < 0.5f) - s = diff / sum; - else - s = diff / (2.0f - sum); - if (r == mx) - h = (g - b) / diff; - else if (g == mx) - h = 2.0f + (b - r) / diff; - else //if (b == mx) - h = 4.0f + (r - g) / diff; - } - h = clamp(h / 6.0f, 0.0f, 1.0f); - return (float4)(h, s, l, a); -} - -#endif // _LIBCL_HSLA_2_RGBA_CL_ diff --git a/LibCL/src/main/resources/LibCL/stdlib.h b/LibCL/src/main/resources/LibCL/stdlib.h deleted file mode 100644 index 1f8afb0e..00000000 --- a/LibCL/src/main/resources/LibCL/stdlib.h +++ /dev/null @@ -1,21 +0,0 @@ - -//#include "tcl.h" -//#ifdef NO_STDLIB_H -//# include "../compat/stdlib.h" -//#else -//# include -//#endif -//#include - -#ifndef CONST -#define CONST const -#endif - -#ifndef isspace -#define isspace(c) (c == ' ' || c == '\t' || c == '\r' || c == '\n') -#endif - -#ifndef isdigit -#define isdigit(c) (c >= '0' && c <= '9') -#endif - diff --git a/LibCL/src/main/resources/LibCL/strstr.c b/LibCL/src/main/resources/LibCL/strstr.c deleted file mode 100644 index 147e97c4..00000000 --- a/LibCL/src/main/resources/LibCL/strstr.c +++ /dev/null @@ -1,5 +0,0 @@ - -/*__global const char * strstr ( __global const char * str1, const char * str2 ) { - -} -*/ diff --git a/LibCL/src/main/resources/LibCL/strtod.c b/LibCL/src/main/resources/LibCL/strtod.c deleted file mode 100644 index 38565acb..00000000 --- a/LibCL/src/main/resources/LibCL/strtod.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * strtod.c -- - * - * Source code for the "strtod" library procedure. - * - * Copyright (c) 1988-1993 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) strtod.c 1.9 96/12/13 15:02:46 - * - * JavaCL / LibCL (Olivier Chafik, 2011) : copied from FreeBSD - * - */ - -//#include "tcl.h" -//#ifdef NO_STDLIB_H -//# include "../compat/stdlib.h" -//#else -//# include -//#endif -//#include - -#ifndef CONST -#define CONST const -#endif - - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif -#ifndef NULL -#define NULL 0 -#endif - -const int _strtod_maxExponent_ = 511; /* Largest possible base 10 exponent. Any - * exponent larger than this will already - * produce underflow or overflow, so there's - * no need to worry about additional digits. - */ - -__constant double _strtod_powersOf10_[] = { /* Table giving binary powers of 10. Entry */ - 10., /* is 10^2^i. Used to convert decimal */ - 100., /* exponents into floating-point numbers. */ - 1.0e4, - 1.0e8, - 1.0e16, - 1.0e32, - 1.0e64, - 1.0e128, - 1.0e256 -}; - - -/* - *---------------------------------------------------------------------- - * - * strtod -- - * - * This procedure converts a floating-point number from an ASCII - * decimal representation to internal double-precision format. - * - * Results: - * The return value is the double-precision floating-point - * representation of the characters in string. If endPtr isn't - * NULL, then *endPtr is filled in with the address of the - * next character after the last one that was part of the - * floating-point number. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -double -strtod(__global CONST char *string, /* A decimal ASCII floating-point number, - * optionally preceded by white space. - * Must have form "-I.FE-X", where I is the - * integer part of the mantissa, F is the - * fractional part of the mantissa, and X - * is the exponent. Either of the signs - * may be "+", "-", or omitted. Either I - * or F may be omitted, or both. The decimal - * point isn't necessary unless F is present. - * The "E" may actually be an "e". E and X - * may both be omitted (but not just one). - */ - __global char **endPtr /* If non-NULL, store terminating character's - * address here. */ - ) { - int sign, expSign = FALSE; - double fraction, dblExp; - __constant double *d; - __global CONST char *p; - int c; - int exp = 0; /* Exponent read from "EX" field. */ - int fracExp = 0; /* Exponent that derives from the fractional - * part. Under normal circumstatnces, it is - * the negative of the number of digits in F. - * However, if I is very long, the last digits - * of I get dropped (otherwise a long I with a - * large negative exponent could cause an - * unnecessary overflow on I alone). In this - * case, fracExp is incremented one for each - * dropped digit. */ - int mantSize; /* Number of digits in mantissa. */ - int decPt; /* Number of mantissa digits BEFORE decimal - * point. */ - __global CONST char *pExp; /* Temporarily holds location of exponent - * in string. */ - - /* - * Strip off leading blanks and check for a sign. - */ - - p = string; - while (isspace(*p)) { - p += 1; - } - if (*p == '-') { - sign = TRUE; - p += 1; - } else { - if (*p == '+') { - p += 1; - } - sign = FALSE; - } - - /* - * Count the number of digits in the mantissa (including the decimal - * point), and also locate the decimal point. - */ - - decPt = -1; - for (mantSize = 0; ; mantSize += 1) - { - c = *p; - if (!isdigit(c)) { - if ((c != '.') || (decPt >= 0)) { - break; - } - decPt = mantSize; - } - p += 1; - } - - /* - * Now suck up the digits in the mantissa. Use two integers to - * collect 9 digits each (this is faster than using floating-point). - * If the mantissa has more than 18 digits, ignore the extras, since - * they can't affect the value anyway. - */ - - pExp = p; - p -= mantSize; - if (decPt < 0) { - decPt = mantSize; - } else { - mantSize -= 1; /* One of the digits was the point. */ - } - if (mantSize > 18) { - fracExp = decPt - 18; - mantSize = 18; - } else { - fracExp = decPt - mantSize; - } - if (mantSize == 0) { - fraction = 0.0; - p = string; - goto done; - } else { - int frac1, frac2; - frac1 = 0; - for ( ; mantSize > 9; mantSize -= 1) - { - c = *p; - p += 1; - if (c == '.') { - c = *p; - p += 1; - } - frac1 = 10*frac1 + (c - '0'); - } - frac2 = 0; - for (; mantSize > 0; mantSize -= 1) - { - c = *p; - p += 1; - if (c == '.') { - c = *p; - p += 1; - } - frac2 = 10*frac2 + (c - '0'); - } - fraction = (1.0e9 * frac1) + frac2; - } - - /* - * Skim off the exponent. - */ - - p = pExp; - if ((*p == 'E') || (*p == 'e')) { - p += 1; - if (*p == '-') { - expSign = TRUE; - p += 1; - } else { - if (*p == '+') { - p += 1; - } - expSign = FALSE; - } - while (isdigit(*p)) { - exp = exp * 10 + (*p - '0'); - p += 1; - } - } - if (expSign) { - exp = fracExp - exp; - } else { - exp = fracExp + exp; - } - - /* - * Generate a floating-point number that represents the exponent. - * Do this by processing the exponent one bit at a time to combine - * many powers of 2 of 10. Then combine the exponent with the - * fraction. - */ - - if (exp < 0) { - expSign = TRUE; - exp = -exp; - } else { - expSign = FALSE; - } - if (exp > _strtod_maxExponent_) { - exp = _strtod_maxExponent_; - } - dblExp = 1.0; - - for (d = _strtod_powersOf10_; exp != 0; exp >>= 1, d += 1) { - if (exp & 01) { - dblExp *= *d; - } - } - if (expSign) { - fraction /= dblExp; - } else { - fraction *= dblExp; - } - -done: - if (endPtr != NULL) { - *endPtr = (__global char *) p; - } - - if (sign) { - return -fraction; - } - return fraction; -} diff --git a/LibCL/src/main/resources/LibCL/strtof.c b/LibCL/src/main/resources/LibCL/strtof.c deleted file mode 100644 index 64f6e956..00000000 --- a/LibCL/src/main/resources/LibCL/strtof.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * strtof.c -- - * - * Source code for the "strtof" library procedure. - * - * Copyright (c) 1988-1993 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) strtof.c 1.9 96/12/13 15:02:46 - * - * JavaCL / LibCL (Olivier Chafik, 2011) : adapted from strod.c copied from FreeBSD - * - */ - -//#include "tcl.h" -//#ifdef NO_STDLIB_H -//# include "../compat/stdlib.h" -//#else -//# include -//#endif -//#include - -#ifndef CONST -#define CONST const -#endif - - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif -#ifndef NULL -#define NULL 0 -#endif - -const float _strtof_powersOf10_[] = { // Table giving binary powers of 10. Entry - 10.0f, // is 10^2^i. Used to convert decimal - 100.0f, // exponents into floating-point numbers. - 1.0e4f, - 1.0e8f, - 1.0e16f, - 1.0e32f -}; - -/* - *---------------------------------------------------------------------- - * - * strtof -- - * - * This procedure converts a floating-point number from an ASCII - * decimal representation to internal double-precision format. - * - * Results: - * The return value is the double-precision floating-point - * representation of the characters in string. If endPtr isn't - * NULL, then *endPtr is filled in with the address of the - * next character after the last one that was part of the - * floating-point number. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -float -strtof(__global CONST char *string, /* A decimal ASCII floating-point number, - * optionally preceded by white space. - * Must have form "-I.FE-X", where I is the - * integer part of the mantissa, F is the - * fractional part of the mantissa, and X - * is the exponent. Either of the signs - * may be "+", "-", or omitted. Either I - * or F may be omitted, or both. The decimal - * point isn't necessary unless F is present. - * The "E" may actually be an "e". E and X - * may both be omitted (but not just one). - */ - __global char **endPtr /* If non-NULL, store terminating character's - * address here. */ - ) { - int sign, expSign = FALSE; - float fraction, dblExp; - __constant float *d; - __global CONST char *p; - int c; - int exp = 0; /* Exponent read from "EX" field. */ - int fracExp = 0; /* Exponent that derives from the fractional - * part. Under normal circumstatnces, it is - * the negative of the number of digits in F. - * However, if I is very long, the last digits - * of I get dropped (otherwise a long I with a - * large negative exponent could cause an - * unnecessary overflow on I alone). In this - * case, fracExp is incremented one for each - * dropped digit. */ - int mantSize; /* Number of digits in mantissa. */ - int decPt; /* Number of mantissa digits BEFORE decimal - * point. */ - __global CONST char *pExp; /* Temporarily holds location of exponent - * in string. */ - - /* - * Strip off leading blanks and check for a sign. - */ - - p = string; - while (isspace(*p)) { - p += 1; - } - if (*p == '-') { - sign = TRUE; - p += 1; - } else { - if (*p == '+') { - p += 1; - } - sign = FALSE; - } - - /* - * Count the number of digits in the mantissa (including the decimal - * point), and also locate the decimal point. - */ - - decPt = -1; - for (mantSize = 0; ; mantSize += 1) - { - c = *p; - if (!isdigit(c)) { - if ((c != '.') || (decPt >= 0)) { - break; - } - decPt = mantSize; - } - p += 1; - } - - /* - * Now suck up the digits in the mantissa. Use two integers to - * collect 9 digits each (this is faster than using floating-point). - * If the mantissa has more than 18 digits, ignore the extras, since - * they can't affect the value anyway. - */ - - pExp = p; - p -= mantSize; - if (decPt < 0) { - decPt = mantSize; - } else { - mantSize -= 1; /* One of the digits was the point. */ - } - if (mantSize > 18) { - fracExp = decPt - 18; - mantSize = 18; - } else { - fracExp = decPt - mantSize; - } - if (mantSize == 0) { - fraction = 0.0; - p = string; - goto done; - } else { - int frac1, frac2; - frac1 = 0; - for ( ; mantSize > 9; mantSize -= 1) - { - c = *p; - p += 1; - if (c == '.') { - c = *p; - p += 1; - } - frac1 = 10*frac1 + (c - '0'); - } - frac2 = 0; - for (; mantSize > 0; mantSize -= 1) - { - c = *p; - p += 1; - if (c == '.') { - c = *p; - p += 1; - } - frac2 = 10*frac2 + (c - '0'); - } - fraction = (1.0e9f * frac1) + frac2; - } - - /* - * Skim off the exponent. - */ - - p = pExp; - if ((*p == 'E') || (*p == 'e')) { - p += 1; - if (*p == '-') { - expSign = TRUE; - p += 1; - } else { - if (*p == '+') { - p += 1; - } - expSign = FALSE; - } - while (isdigit(*p)) { - exp = exp * 10 + (*p - '0'); - p += 1; - } - } - if (expSign) { - exp = fracExp - exp; - } else { - exp = fracExp + exp; - } - - /* - * Generate a floating-point number that represents the exponent. - * Do this by processing the exponent one bit at a time to combine - * many powers of 2 of 10. Then combine the exponent with the - * fraction. - */ - - if (exp < 0) { - expSign = TRUE; - exp = -exp; - } else { - expSign = FALSE; - } - const int maxExponent = 38; /* Largest possible base 10 exponent. Any - * exponent larger than this will already - * produce underflow or overflow, so there's - * no need to worry about additional digits. - */ - - if (exp > maxExponent) { - exp = maxExponent; - } - dblExp = 1.0f; - - for (d = _strtof_powersOf10_; exp != 0; exp >>= 1, d += 1) { - if (exp & 01) { - dblExp *= *d; - } - } - /* - if (exp) { - if (exp & 01) - dblExp *= 10.0f; - exp >>= 1; - - if (exp) { - if (exp & 01) - dblExp *= 100.0f; - exp >>= 1; - - if (exp) { - if (exp & 01) - dblExp *= 1.0e4f; - exp >>= 1; - - if (exp) { - if (exp & 01) - dblExp *= 1.0e8f; - exp >>= 1; - - if (exp) { - if (exp & 01) - dblExp *= 1.0e16f; - exp >>= 1; - - if (exp) { - if (exp & 01) - dblExp *= 1.0e32f; - //exp >>= 1; - } - } - } - } - } - }*/ - - - if (expSign) { - fraction /= dblExp; - } else { - fraction *= dblExp; - } - -done: - if (endPtr != NULL) { - *endPtr = (__global char *) p; - } - - if (sign) { - return -fraction; - } - return fraction; -} diff --git a/MavenPlugin/.gitignore b/MavenPlugin/.gitignore deleted file mode 100644 index 8e0d5325..00000000 --- a/MavenPlugin/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -project/boot -project/target -*~ diff --git a/MavenPlugin/pom.xml b/MavenPlugin/pom.xml deleted file mode 100644 index ac5ea2ea..00000000 --- a/MavenPlugin/pom.xml +++ /dev/null @@ -1,127 +0,0 @@ - - 4.0.0 - com.nativelibs4java - maven-javacl-plugin - Maven JavaCL Plugin - http://code.google.com/p/javacl/ - maven-plugin - - - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - .. - - - - - - com.nativelibs4java - javacl-generator - - - - org.apache.maven - maven-plugin-api - 3.3.1 - - - - org.apache.maven - maven-project - 3.0-alpha-2 - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - description - a - Description : - - - goal - Xt - - - phase - Xt - - - execute - Xt - - - aggregator - t - - - description - t - - - execute - t - - - goal - t - - - phase - t - - - requiresDirectInvocation - t - - - requiresDependencyResolution - t - - - requiresProject - t - - - requiresReports - t - - - requiresOnline - t - - - parameter - t - - - component - t - - - required - t - - - readonly - t - - - - - - - - - diff --git a/NumericalBenchmark/pom.xml b/NumericalBenchmark/pom.xml index 198d7e6f..208ff198 100644 --- a/NumericalBenchmark/pom.xml +++ b/NumericalBenchmark/pom.xml @@ -2,22 +2,24 @@ 4.0.0 com.nativelibs4java - javacl-numerical-benchmark - JavaCL Numerical Benchmark + javacl-numerical-benchmark-jna + JavaCL Numerical Benchmark / JNA http://code.google.com/p/javacl/ + 1.0.0-RC4 jar com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT + nativelibs4java-parent + 1.9 .. - + com.nativelibs4java - javacl + javacl-jna + 1.0.0-RC4 org.apache.commons @@ -29,12 +31,20 @@ scala-library - + com.nativelibs4java - maven-javacl-plugin + javacl-generator-bridj-jna + 1.0.0-RC4 + + + + compile + + + net.alchim31.maven @@ -46,7 +56,7 @@ - + diff --git a/OpenCL4Java/opencl4java-bridj.iml b/OpenCL4Java/opencl4java-bridj.iml deleted file mode 100644 index 72af1b34..00000000 --- a/OpenCL4Java/opencl4java-bridj.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/OpenCL4Java/opencl4java.iml b/OpenCL4Java/opencl4java.iml deleted file mode 100644 index fcc43623..00000000 --- a/OpenCL4Java/opencl4java.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/OpenCL4Java/pom.xml b/OpenCL4Java/pom.xml index 18b0e460..b0e935da 100644 --- a/OpenCL4Java/pom.xml +++ b/OpenCL4Java/pom.xml @@ -3,9 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.nativelibs4java - opencl4java - OpenCL4Java / BridJ + opencl4java-jna + OpenCL4Java / JNA http://code.google.com/p/nativelibs4java/wiki/OpenCL + 1.0.0-RC4 jar @@ -19,40 +20,22 @@ For more info, please visit http://code.google.com/p/nativelibs4java/wiki/OpenCL com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT + javacl-parent-jna + 1.0.0-RC4 .. - + com.nativelibs4java - bridj - - 0.7.1-SNAPSHOT + jnaerator-runtime + + ${jnaerator.version} - - - regenerate - - - - com.nativelibs4java - maven-jnaerator-plugin - ${jnaerator.version} - - src/main/java - - - - - - - diff --git a/OpenCL4Java/src/main/headers/1.2/CL/cl.h b/OpenCL4Java/src/main/headers/1.2/CL/cl.h deleted file mode 100644 index c61f4ffd..00000000 --- a/OpenCL4Java/src/main/headers/1.2/CL/cl.h +++ /dev/null @@ -1,1239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - ******************************************************************************/ - -#ifndef __OPENCL_CL_H -#define __OPENCL_CL_H - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************/ - -typedef struct _cl_platform_id * cl_platform_id; -typedef struct _cl_device_id * cl_device_id; -typedef struct _cl_context * cl_context; -typedef struct _cl_command_queue * cl_command_queue; -typedef struct _cl_mem * cl_mem; -typedef struct _cl_program * cl_program; -typedef struct _cl_kernel * cl_kernel; -typedef struct _cl_event * cl_event; -typedef struct _cl_sampler * cl_sampler; - -typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ -typedef cl_ulong cl_bitfield; -typedef cl_bitfield cl_device_type; -typedef cl_uint cl_platform_info; -typedef cl_uint cl_device_info; -typedef cl_bitfield cl_device_fp_config; -typedef cl_uint cl_device_mem_cache_type; -typedef cl_uint cl_device_local_mem_type; -typedef cl_bitfield cl_device_exec_capabilities; -typedef cl_bitfield cl_command_queue_properties; -typedef intptr_t cl_device_partition_property; -typedef cl_bitfield cl_device_affinity_domain; - -typedef intptr_t cl_context_properties; -typedef cl_uint cl_context_info; -typedef cl_uint cl_command_queue_info; -typedef cl_uint cl_channel_order; -typedef cl_uint cl_channel_type; -typedef cl_bitfield cl_mem_flags; -typedef cl_uint cl_mem_object_type; -typedef cl_uint cl_mem_info; -typedef cl_bitfield cl_mem_migration_flags; -typedef cl_uint cl_image_info; -typedef cl_uint cl_buffer_create_type; -typedef cl_uint cl_addressing_mode; -typedef cl_uint cl_filter_mode; -typedef cl_uint cl_sampler_info; -typedef cl_bitfield cl_map_flags; -typedef cl_uint cl_program_info; -typedef cl_uint cl_program_build_info; -typedef cl_uint cl_program_binary_type; -typedef cl_int cl_build_status; -typedef cl_uint cl_kernel_info; -typedef cl_uint cl_kernel_arg_info; -typedef cl_uint cl_kernel_arg_address_qualifier; -typedef cl_uint cl_kernel_arg_access_qualifier; -typedef cl_bitfield cl_kernel_arg_type_qualifier; -typedef cl_uint cl_kernel_work_group_info; -typedef cl_uint cl_event_info; -typedef cl_uint cl_command_type; -typedef cl_uint cl_profiling_info; - - -typedef struct _cl_image_format { - cl_channel_order image_channel_order; - cl_channel_type image_channel_data_type; -} cl_image_format; - -typedef struct _cl_image_desc { - cl_mem_object_type image_type; - size_t image_width; - size_t image_height; - size_t image_depth; - size_t image_array_size; - size_t image_row_pitch; - size_t image_slice_pitch; - cl_uint num_mip_levels; - cl_uint num_samples; - cl_mem buffer; -} cl_image_desc; - -typedef struct _cl_buffer_region { - size_t origin; - size_t size; -} cl_buffer_region; - - -/******************************************************************************/ - -/* Error Codes */ -#define CL_SUCCESS 0 -#define CL_DEVICE_NOT_FOUND -1 -#define CL_DEVICE_NOT_AVAILABLE -2 -#define CL_COMPILER_NOT_AVAILABLE -3 -#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4 -#define CL_OUT_OF_RESOURCES -5 -#define CL_OUT_OF_HOST_MEMORY -6 -#define CL_PROFILING_INFO_NOT_AVAILABLE -7 -#define CL_MEM_COPY_OVERLAP -8 -#define CL_IMAGE_FORMAT_MISMATCH -9 -#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10 -#define CL_BUILD_PROGRAM_FAILURE -11 -#define CL_MAP_FAILURE -12 -#define CL_MISALIGNED_SUB_BUFFER_OFFSET -13 -#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14 -#define CL_COMPILE_PROGRAM_FAILURE -15 -#define CL_LINKER_NOT_AVAILABLE -16 -#define CL_LINK_PROGRAM_FAILURE -17 -#define CL_DEVICE_PARTITION_FAILED -18 -#define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19 - -#define CL_INVALID_VALUE -30 -#define CL_INVALID_DEVICE_TYPE -31 -#define CL_INVALID_PLATFORM -32 -#define CL_INVALID_DEVICE -33 -#define CL_INVALID_CONTEXT -34 -#define CL_INVALID_QUEUE_PROPERTIES -35 -#define CL_INVALID_COMMAND_QUEUE -36 -#define CL_INVALID_HOST_PTR -37 -#define CL_INVALID_MEM_OBJECT -38 -#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39 -#define CL_INVALID_IMAGE_SIZE -40 -#define CL_INVALID_SAMPLER -41 -#define CL_INVALID_BINARY -42 -#define CL_INVALID_BUILD_OPTIONS -43 -#define CL_INVALID_PROGRAM -44 -#define CL_INVALID_PROGRAM_EXECUTABLE -45 -#define CL_INVALID_KERNEL_NAME -46 -#define CL_INVALID_KERNEL_DEFINITION -47 -#define CL_INVALID_KERNEL -48 -#define CL_INVALID_ARG_INDEX -49 -#define CL_INVALID_ARG_VALUE -50 -#define CL_INVALID_ARG_SIZE -51 -#define CL_INVALID_KERNEL_ARGS -52 -#define CL_INVALID_WORK_DIMENSION -53 -#define CL_INVALID_WORK_GROUP_SIZE -54 -#define CL_INVALID_WORK_ITEM_SIZE -55 -#define CL_INVALID_GLOBAL_OFFSET -56 -#define CL_INVALID_EVENT_WAIT_LIST -57 -#define CL_INVALID_EVENT -58 -#define CL_INVALID_OPERATION -59 -#define CL_INVALID_GL_OBJECT -60 -#define CL_INVALID_BUFFER_SIZE -61 -#define CL_INVALID_MIP_LEVEL -62 -#define CL_INVALID_GLOBAL_WORK_SIZE -63 -#define CL_INVALID_PROPERTY -64 -#define CL_INVALID_IMAGE_DESCRIPTOR -65 -#define CL_INVALID_COMPILER_OPTIONS -66 -#define CL_INVALID_LINKER_OPTIONS -67 -#define CL_INVALID_DEVICE_PARTITION_COUNT -68 - -/* OpenCL Version */ -#define CL_VERSION_1_0 1 -#define CL_VERSION_1_1 1 -#define CL_VERSION_1_2 1 - -/* cl_bool */ -#define CL_FALSE 0 -#define CL_TRUE 1 -#define CL_BLOCKING CL_TRUE -#define CL_NON_BLOCKING CL_FALSE - -/* cl_platform_info */ -#define CL_PLATFORM_PROFILE 0x0900 -#define CL_PLATFORM_VERSION 0x0901 -#define CL_PLATFORM_NAME 0x0902 -#define CL_PLATFORM_VENDOR 0x0903 -#define CL_PLATFORM_EXTENSIONS 0x0904 - -/* cl_device_type - bitfield */ -#define CL_DEVICE_TYPE_DEFAULT (1 << 0) -#define CL_DEVICE_TYPE_CPU (1 << 1) -#define CL_DEVICE_TYPE_GPU (1 << 2) -#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3) -#define CL_DEVICE_TYPE_CUSTOM (1 << 4) -#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF - -/* cl_device_info */ -#define CL_DEVICE_TYPE 0x1000 -#define CL_DEVICE_VENDOR_ID 0x1001 -#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002 -#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003 -#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004 -#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009 -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B -#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C -#define CL_DEVICE_ADDRESS_BITS 0x100D -#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E -#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F -#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010 -#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011 -#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012 -#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013 -#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014 -#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015 -#define CL_DEVICE_IMAGE_SUPPORT 0x1016 -#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017 -#define CL_DEVICE_MAX_SAMPLERS 0x1018 -#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019 -#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A -#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B -#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C -#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D -#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E -#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F -#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020 -#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021 -#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022 -#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023 -#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024 -#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025 -#define CL_DEVICE_ENDIAN_LITTLE 0x1026 -#define CL_DEVICE_AVAILABLE 0x1027 -#define CL_DEVICE_COMPILER_AVAILABLE 0x1028 -#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029 -#define CL_DEVICE_QUEUE_PROPERTIES 0x102A -#define CL_DEVICE_NAME 0x102B -#define CL_DEVICE_VENDOR 0x102C -#define CL_DRIVER_VERSION 0x102D -#define CL_DEVICE_PROFILE 0x102E -#define CL_DEVICE_VERSION 0x102F -#define CL_DEVICE_EXTENSIONS 0x1030 -#define CL_DEVICE_PLATFORM 0x1031 -#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 -/* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */ -#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034 -#define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035 -#define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036 -#define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037 -#define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038 -#define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039 -#define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A -#define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B -#define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C -#define CL_DEVICE_OPENCL_C_VERSION 0x103D -#define CL_DEVICE_LINKER_AVAILABLE 0x103E -#define CL_DEVICE_BUILT_IN_KERNELS 0x103F -#define CL_DEVICE_IMAGE_MAX_BUFFER_SIZE 0x1040 -#define CL_DEVICE_IMAGE_MAX_ARRAY_SIZE 0x1041 -#define CL_DEVICE_PARENT_DEVICE 0x1042 -#define CL_DEVICE_PARTITION_MAX_SUB_DEVICES 0x1043 -#define CL_DEVICE_PARTITION_PROPERTIES 0x1044 -#define CL_DEVICE_PARTITION_AFFINITY_DOMAIN 0x1045 -#define CL_DEVICE_PARTITION_TYPE 0x1046 -#define CL_DEVICE_REFERENCE_COUNT 0x1047 -#define CL_DEVICE_PREFERRED_INTEROP_USER_SYNC 0x1048 -#define CL_DEVICE_PRINTF_BUFFER_SIZE 0x1049 - -/* cl_device_fp_config - bitfield */ -#define CL_FP_DENORM (1 << 0) -#define CL_FP_INF_NAN (1 << 1) -#define CL_FP_ROUND_TO_NEAREST (1 << 2) -#define CL_FP_ROUND_TO_ZERO (1 << 3) -#define CL_FP_ROUND_TO_INF (1 << 4) -#define CL_FP_FMA (1 << 5) -#define CL_FP_SOFT_FLOAT (1 << 6) -#define CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT (1 << 7) - -/* cl_device_mem_cache_type */ -#define CL_NONE 0x0 -#define CL_READ_ONLY_CACHE 0x1 -#define CL_READ_WRITE_CACHE 0x2 - -/* cl_device_local_mem_type */ -#define CL_LOCAL 0x1 -#define CL_GLOBAL 0x2 - -/* cl_device_exec_capabilities - bitfield */ -#define CL_EXEC_KERNEL (1 << 0) -#define CL_EXEC_NATIVE_KERNEL (1 << 1) - -/* cl_command_queue_properties - bitfield */ -#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0) -#define CL_QUEUE_PROFILING_ENABLE (1 << 1) - -/* cl_context_info */ -#define CL_CONTEXT_REFERENCE_COUNT 0x1080 -#define CL_CONTEXT_DEVICES 0x1081 -#define CL_CONTEXT_PROPERTIES 0x1082 -#define CL_CONTEXT_NUM_DEVICES 0x1083 - -/* cl_context_properties */ -#define CL_CONTEXT_PLATFORM 0x1084 -#define CL_CONTEXT_INTEROP_USER_SYNC 0x1085 - -/* cl_device_partition_property */ -#define CL_DEVICE_PARTITION_EQUALLY 0x1086 -#define CL_DEVICE_PARTITION_BY_COUNTS 0x1087 -#define CL_DEVICE_PARTITION_BY_COUNTS_LIST_END 0x0 -#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN 0x1088 - -/* cl_device_affinity_domain */ -#define CL_DEVICE_AFFINITY_DOMAIN_NUMA (1 << 0) -#define CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE (1 << 1) -#define CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE (1 << 2) -#define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3) -#define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4) -#define CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE (1 << 5) - -/* cl_command_queue_info */ -#define CL_QUEUE_CONTEXT 0x1090 -#define CL_QUEUE_DEVICE 0x1091 -#define CL_QUEUE_REFERENCE_COUNT 0x1092 -#define CL_QUEUE_PROPERTIES 0x1093 - -/* cl_mem_flags - bitfield */ -#define CL_MEM_READ_WRITE (1 << 0) -#define CL_MEM_WRITE_ONLY (1 << 1) -#define CL_MEM_READ_ONLY (1 << 2) -#define CL_MEM_USE_HOST_PTR (1 << 3) -#define CL_MEM_ALLOC_HOST_PTR (1 << 4) -#define CL_MEM_COPY_HOST_PTR (1 << 5) -// reserved (1 << 6) -#define CL_MEM_HOST_WRITE_ONLY (1 << 7) -#define CL_MEM_HOST_READ_ONLY (1 << 8) -#define CL_MEM_HOST_NO_ACCESS (1 << 9) - -/* cl_mem_migration_flags - bitfield */ -#define CL_MIGRATE_MEM_OBJECT_HOST (1 << 0) -#define CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED (1 << 1) - -/* cl_channel_order */ -#define CL_R 0x10B0 -#define CL_A 0x10B1 -#define CL_RG 0x10B2 -#define CL_RA 0x10B3 -#define CL_RGB 0x10B4 -#define CL_RGBA 0x10B5 -#define CL_BGRA 0x10B6 -#define CL_ARGB 0x10B7 -#define CL_INTENSITY 0x10B8 -#define CL_LUMINANCE 0x10B9 -#define CL_Rx 0x10BA -#define CL_RGx 0x10BB -#define CL_RGBx 0x10BC - -/* cl_channel_type */ -#define CL_SNORM_INT8 0x10D0 -#define CL_SNORM_INT16 0x10D1 -#define CL_UNORM_INT8 0x10D2 -#define CL_UNORM_INT16 0x10D3 -#define CL_UNORM_SHORT_565 0x10D4 -#define CL_UNORM_SHORT_555 0x10D5 -#define CL_UNORM_INT_101010 0x10D6 -#define CL_SIGNED_INT8 0x10D7 -#define CL_SIGNED_INT16 0x10D8 -#define CL_SIGNED_INT32 0x10D9 -#define CL_UNSIGNED_INT8 0x10DA -#define CL_UNSIGNED_INT16 0x10DB -#define CL_UNSIGNED_INT32 0x10DC -#define CL_HALF_FLOAT 0x10DD -#define CL_FLOAT 0x10DE - -/* cl_mem_object_type */ -#define CL_MEM_OBJECT_BUFFER 0x10F0 -#define CL_MEM_OBJECT_IMAGE2D 0x10F1 -#define CL_MEM_OBJECT_IMAGE3D 0x10F2 -#define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3 -#define CL_MEM_OBJECT_IMAGE1D 0x10F4 -#define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5 -#define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6 - -/* cl_mem_info */ -#define CL_MEM_TYPE 0x1100 -#define CL_MEM_FLAGS 0x1101 -#define CL_MEM_SIZE 0x1102 -#define CL_MEM_HOST_PTR 0x1103 -#define CL_MEM_MAP_COUNT 0x1104 -#define CL_MEM_REFERENCE_COUNT 0x1105 -#define CL_MEM_CONTEXT 0x1106 -#define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107 -#define CL_MEM_OFFSET 0x1108 - -/* cl_image_info */ -#define CL_IMAGE_FORMAT 0x1110 -#define CL_IMAGE_ELEMENT_SIZE 0x1111 -#define CL_IMAGE_ROW_PITCH 0x1112 -#define CL_IMAGE_SLICE_PITCH 0x1113 -#define CL_IMAGE_WIDTH 0x1114 -#define CL_IMAGE_HEIGHT 0x1115 -#define CL_IMAGE_DEPTH 0x1116 -#define CL_IMAGE_ARRAY_SIZE 0x1117 -#define CL_IMAGE_BUFFER 0x1118 -#define CL_IMAGE_NUM_MIP_LEVELS 0x1119 -#define CL_IMAGE_NUM_SAMPLES 0x111A - -/* cl_addressing_mode */ -#define CL_ADDRESS_NONE 0x1130 -#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131 -#define CL_ADDRESS_CLAMP 0x1132 -#define CL_ADDRESS_REPEAT 0x1133 -#define CL_ADDRESS_MIRRORED_REPEAT 0x1134 - -/* cl_filter_mode */ -#define CL_FILTER_NEAREST 0x1140 -#define CL_FILTER_LINEAR 0x1141 - -/* cl_sampler_info */ -#define CL_SAMPLER_REFERENCE_COUNT 0x1150 -#define CL_SAMPLER_CONTEXT 0x1151 -#define CL_SAMPLER_NORMALIZED_COORDS 0x1152 -#define CL_SAMPLER_ADDRESSING_MODE 0x1153 -#define CL_SAMPLER_FILTER_MODE 0x1154 - -/* cl_map_flags - bitfield */ -#define CL_MAP_READ (1 << 0) -#define CL_MAP_WRITE (1 << 1) -#define CL_MAP_WRITE_INVALIDATE_REGION (1 << 2) - -/* cl_program_info */ -#define CL_PROGRAM_REFERENCE_COUNT 0x1160 -#define CL_PROGRAM_CONTEXT 0x1161 -#define CL_PROGRAM_NUM_DEVICES 0x1162 -#define CL_PROGRAM_DEVICES 0x1163 -#define CL_PROGRAM_SOURCE 0x1164 -#define CL_PROGRAM_BINARY_SIZES 0x1165 -#define CL_PROGRAM_BINARIES 0x1166 -#define CL_PROGRAM_NUM_KERNELS 0x1167 -#define CL_PROGRAM_KERNEL_NAMES 0x1168 - -/* cl_program_build_info */ -#define CL_PROGRAM_BUILD_STATUS 0x1181 -#define CL_PROGRAM_BUILD_OPTIONS 0x1182 -#define CL_PROGRAM_BUILD_LOG 0x1183 -#define CL_PROGRAM_BINARY_TYPE 0x1184 - -/* cl_program_binary_type */ -#define CL_PROGRAM_BINARY_TYPE_NONE 0x0 -#define CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT 0x1 -#define CL_PROGRAM_BINARY_TYPE_LIBRARY 0x2 -#define CL_PROGRAM_BINARY_TYPE_EXECUTABLE 0x4 - -/* cl_build_status */ -#define CL_BUILD_SUCCESS 0 -#define CL_BUILD_NONE -1 -#define CL_BUILD_ERROR -2 -#define CL_BUILD_IN_PROGRESS -3 - -/* cl_kernel_info */ -#define CL_KERNEL_FUNCTION_NAME 0x1190 -#define CL_KERNEL_NUM_ARGS 0x1191 -#define CL_KERNEL_REFERENCE_COUNT 0x1192 -#define CL_KERNEL_CONTEXT 0x1193 -#define CL_KERNEL_PROGRAM 0x1194 -#define CL_KERNEL_ATTRIBUTES 0x1195 - -/* cl_kernel_arg_info */ -#define CL_KERNEL_ARG_ADDRESS_QUALIFIER 0x1196 -#define CL_KERNEL_ARG_ACCESS_QUALIFIER 0x1197 -#define CL_KERNEL_ARG_TYPE_NAME 0x1198 -#define CL_KERNEL_ARG_TYPE_QUALIFIER 0x1199 -#define CL_KERNEL_ARG_NAME 0x119A - -/* cl_kernel_arg_address_qualifier */ -#define CL_KERNEL_ARG_ADDRESS_GLOBAL 0x119B -#define CL_KERNEL_ARG_ADDRESS_LOCAL 0x119C -#define CL_KERNEL_ARG_ADDRESS_CONSTANT 0x119D -#define CL_KERNEL_ARG_ADDRESS_PRIVATE 0x119E - -/* cl_kernel_arg_access_qualifier */ -#define CL_KERNEL_ARG_ACCESS_READ_ONLY 0x11A0 -#define CL_KERNEL_ARG_ACCESS_WRITE_ONLY 0x11A1 -#define CL_KERNEL_ARG_ACCESS_READ_WRITE 0x11A2 -#define CL_KERNEL_ARG_ACCESS_NONE 0x11A3 - -/* cl_kernel_arg_type_qualifer */ -#define CL_KERNEL_ARG_TYPE_NONE 0 -#define CL_KERNEL_ARG_TYPE_CONST (1 << 0) -#define CL_KERNEL_ARG_TYPE_RESTRICT (1 << 1) -#define CL_KERNEL_ARG_TYPE_VOLATILE (1 << 2) - -/* cl_kernel_work_group_info */ -#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0 -#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1 -#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2 -#define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3 -#define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4 -#define CL_KERNEL_GLOBAL_WORK_SIZE 0x11B5 - -/* cl_event_info */ -#define CL_EVENT_COMMAND_QUEUE 0x11D0 -#define CL_EVENT_COMMAND_TYPE 0x11D1 -#define CL_EVENT_REFERENCE_COUNT 0x11D2 -#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3 -#define CL_EVENT_CONTEXT 0x11D4 - -/* cl_command_type */ -#define CL_COMMAND_NDRANGE_KERNEL 0x11F0 -#define CL_COMMAND_TASK 0x11F1 -#define CL_COMMAND_NATIVE_KERNEL 0x11F2 -#define CL_COMMAND_READ_BUFFER 0x11F3 -#define CL_COMMAND_WRITE_BUFFER 0x11F4 -#define CL_COMMAND_COPY_BUFFER 0x11F5 -#define CL_COMMAND_READ_IMAGE 0x11F6 -#define CL_COMMAND_WRITE_IMAGE 0x11F7 -#define CL_COMMAND_COPY_IMAGE 0x11F8 -#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9 -#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA -#define CL_COMMAND_MAP_BUFFER 0x11FB -#define CL_COMMAND_MAP_IMAGE 0x11FC -#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD -#define CL_COMMAND_MARKER 0x11FE -#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF -#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200 -#define CL_COMMAND_READ_BUFFER_RECT 0x1201 -#define CL_COMMAND_WRITE_BUFFER_RECT 0x1202 -#define CL_COMMAND_COPY_BUFFER_RECT 0x1203 -#define CL_COMMAND_USER 0x1204 -#define CL_COMMAND_BARRIER 0x1205 -#define CL_COMMAND_MIGRATE_MEM_OBJECTS 0x1206 -#define CL_COMMAND_FILL_BUFFER 0x1207 -#define CL_COMMAND_FILL_IMAGE 0x1208 - -/* command execution status */ -#define CL_COMPLETE 0x0 -#define CL_RUNNING 0x1 -#define CL_SUBMITTED 0x2 -#define CL_QUEUED 0x3 - -/* cl_buffer_create_type */ -#define CL_BUFFER_CREATE_TYPE_REGION 0x1220 - -/* cl_profiling_info */ -#define CL_PROFILING_COMMAND_QUEUED 0x1280 -#define CL_PROFILING_COMMAND_SUBMIT 0x1281 -#define CL_PROFILING_COMMAND_START 0x1282 -#define CL_PROFILING_COMMAND_END 0x1283 - -/********************************************************************************************************/ - -/* Platform API */ -extern CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformIDs(cl_uint /* num_entries */, - cl_platform_id * /* platforms */, - cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetPlatformInfo(cl_platform_id /* platform */, - cl_platform_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -/* Device APIs */ -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDs(cl_platform_id /* platform */, - cl_device_type /* device_type */, - cl_uint /* num_entries */, - cl_device_id * /* devices */, - cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceInfo(cl_device_id /* device */, - cl_device_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clCreateSubDevices(cl_device_id /* in_device */, - const cl_device_partition_property * /* properties */, - cl_uint /* num_devices */, - cl_device_id * /* out_devices */, - cl_uint * /* num_devices_ret */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2; - -/* Context APIs */ -extern CL_API_ENTRY cl_context CL_API_CALL -clCreateContext(const cl_context_properties * /* properties */, - cl_uint /* num_devices */, - const cl_device_id * /* devices */, - void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *), - void * /* user_data */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_context CL_API_CALL -clCreateContextFromType(const cl_context_properties * /* properties */, - cl_device_type /* device_type */, - void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *), - void * /* user_data */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetContextInfo(cl_context /* context */, - cl_context_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -/* Command Queue APIs */ -extern CL_API_ENTRY cl_command_queue CL_API_CALL -clCreateCommandQueue(cl_context /* context */, - cl_device_id /* device */, - cl_command_queue_properties /* properties */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetCommandQueueInfo(cl_command_queue /* command_queue */, - cl_command_queue_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -/* Memory Object APIs */ -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateBuffer(cl_context /* context */, - cl_mem_flags /* flags */, - size_t /* size */, - void * /* host_ptr */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateSubBuffer(cl_mem /* buffer */, - cl_mem_flags /* flags */, - cl_buffer_create_type /* buffer_create_type */, - const void * /* buffer_create_info */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateImage(cl_context /* context */, - cl_mem_flags /* flags */, - const cl_image_format * /* image_format */, - const cl_image_desc * /* image_desc */, - void * /* host_ptr */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetSupportedImageFormats(cl_context /* context */, - cl_mem_flags /* flags */, - cl_mem_object_type /* image_type */, - cl_uint /* num_entries */, - cl_image_format * /* image_formats */, - cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetMemObjectInfo(cl_mem /* memobj */, - cl_mem_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetImageInfo(cl_mem /* image */, - cl_image_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetMemObjectDestructorCallback( cl_mem /* memobj */, - void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), - void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1; - -/* Sampler APIs */ -extern CL_API_ENTRY cl_sampler CL_API_CALL -clCreateSampler(cl_context /* context */, - cl_bool /* normalized_coords */, - cl_addressing_mode /* addressing_mode */, - cl_filter_mode /* filter_mode */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetSamplerInfo(cl_sampler /* sampler */, - cl_sampler_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -/* Program Object APIs */ -extern CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithSource(cl_context /* context */, - cl_uint /* count */, - const char ** /* strings */, - const size_t * /* lengths */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBinary(cl_context /* context */, - cl_uint /* num_devices */, - const cl_device_id * /* device_list */, - const size_t * /* lengths */, - const unsigned char ** /* binaries */, - cl_int * /* binary_status */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithBuiltInKernels(cl_context /* context */, - cl_uint /* num_devices */, - const cl_device_id * /* device_list */, - const char * /* kernel_names */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clBuildProgram(cl_program /* program */, - cl_uint /* num_devices */, - const cl_device_id * /* device_list */, - const char * /* options */, - void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */), - void * /* user_data */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clCompileProgram(cl_program /* program */, - cl_uint /* num_devices */, - const cl_device_id * /* device_list */, - const char * /* options */, - cl_uint /* num_input_headers */, - const cl_program * /* input_headers */, - const char ** /* header_include_names */, - void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */), - void * /* user_data */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_program CL_API_CALL -clLinkProgram(cl_context /* context */, - cl_uint /* num_devices */, - const cl_device_id * /* device_list */, - const char * /* options */, - cl_uint /* num_input_programs */, - const cl_program * /* input_programs */, - void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */), - void * /* user_data */, - cl_int * /* errcode_ret */ ) CL_API_SUFFIX__VERSION_1_2; - - -extern CL_API_ENTRY cl_int CL_API_CALL -clUnloadPlatformCompiler(cl_platform_id /* platform */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetProgramInfo(cl_program /* program */, - cl_program_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetProgramBuildInfo(cl_program /* program */, - cl_device_id /* device */, - cl_program_build_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -/* Kernel Object APIs */ -extern CL_API_ENTRY cl_kernel CL_API_CALL -clCreateKernel(cl_program /* program */, - const char * /* kernel_name */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clCreateKernelsInProgram(cl_program /* program */, - cl_uint /* num_kernels */, - cl_kernel * /* kernels */, - cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetKernelArg(cl_kernel /* kernel */, - cl_uint /* arg_index */, - size_t /* arg_size */, - const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetKernelInfo(cl_kernel /* kernel */, - cl_kernel_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetKernelArgInfo(cl_kernel /* kernel */, - cl_uint /* arg_indx */, - cl_kernel_arg_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetKernelWorkGroupInfo(cl_kernel /* kernel */, - cl_device_id /* device */, - cl_kernel_work_group_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -/* Event Object APIs */ -extern CL_API_ENTRY cl_int CL_API_CALL -clWaitForEvents(cl_uint /* num_events */, - const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetEventInfo(cl_event /* event */, - cl_event_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_event CL_API_CALL -clCreateUserEvent(cl_context /* context */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetUserEventStatus(cl_event /* event */, - cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetEventCallback( cl_event /* event */, - cl_int /* command_exec_callback_type */, - void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), - void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; - -/* Profiling APIs */ -extern CL_API_ENTRY cl_int CL_API_CALL -clGetEventProfilingInfo(cl_event /* event */, - cl_profiling_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -/* Flush and Finish APIs */ -extern CL_API_ENTRY cl_int CL_API_CALL -clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; - -/* Enqueued Commands APIs */ -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBuffer(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_read */, - size_t /* offset */, - size_t /* size */, - void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadBufferRect(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_read */, - const size_t * /* buffer_offset */, - const size_t * /* host_offset */, - const size_t * /* region */, - size_t /* buffer_row_pitch */, - size_t /* buffer_slice_pitch */, - size_t /* host_row_pitch */, - size_t /* host_slice_pitch */, - void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBuffer(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_write */, - size_t /* offset */, - size_t /* size */, - const void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteBufferRect(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_write */, - const size_t * /* buffer_offset */, - const size_t * /* host_offset */, - const size_t * /* region */, - size_t /* buffer_row_pitch */, - size_t /* buffer_slice_pitch */, - size_t /* host_row_pitch */, - size_t /* host_slice_pitch */, - const void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillBuffer(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - const void * /* pattern */, - size_t /* pattern_size */, - size_t /* offset */, - size_t /* size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBuffer(cl_command_queue /* command_queue */, - cl_mem /* src_buffer */, - cl_mem /* dst_buffer */, - size_t /* src_offset */, - size_t /* dst_offset */, - size_t /* size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferRect(cl_command_queue /* command_queue */, - cl_mem /* src_buffer */, - cl_mem /* dst_buffer */, - const size_t * /* src_origin */, - const size_t * /* dst_origin */, - const size_t * /* region */, - size_t /* src_row_pitch */, - size_t /* src_slice_pitch */, - size_t /* dst_row_pitch */, - size_t /* dst_slice_pitch */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReadImage(cl_command_queue /* command_queue */, - cl_mem /* image */, - cl_bool /* blocking_read */, - const size_t * /* origin[3] */, - const size_t * /* region[3] */, - size_t /* row_pitch */, - size_t /* slice_pitch */, - void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueWriteImage(cl_command_queue /* command_queue */, - cl_mem /* image */, - cl_bool /* blocking_write */, - const size_t * /* origin[3] */, - const size_t * /* region[3] */, - size_t /* input_row_pitch */, - size_t /* input_slice_pitch */, - const void * /* ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueFillImage(cl_command_queue /* command_queue */, - cl_mem /* image */, - const void * /* fill_color */, - const size_t * /* origin[3] */, - const size_t * /* region[3] */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImage(cl_command_queue /* command_queue */, - cl_mem /* src_image */, - cl_mem /* dst_image */, - const size_t * /* src_origin[3] */, - const size_t * /* dst_origin[3] */, - const size_t * /* region[3] */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */, - cl_mem /* src_image */, - cl_mem /* dst_buffer */, - const size_t * /* src_origin[3] */, - const size_t * /* region[3] */, - size_t /* dst_offset */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */, - cl_mem /* src_buffer */, - cl_mem /* dst_image */, - size_t /* src_offset */, - const size_t * /* dst_origin[3] */, - const size_t * /* region[3] */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY void * CL_API_CALL -clEnqueueMapBuffer(cl_command_queue /* command_queue */, - cl_mem /* buffer */, - cl_bool /* blocking_map */, - cl_map_flags /* map_flags */, - size_t /* offset */, - size_t /* size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY void * CL_API_CALL -clEnqueueMapImage(cl_command_queue /* command_queue */, - cl_mem /* image */, - cl_bool /* blocking_map */, - cl_map_flags /* map_flags */, - const size_t * /* origin[3] */, - const size_t * /* region[3] */, - size_t * /* image_row_pitch */, - size_t * /* image_slice_pitch */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueUnmapMemObject(cl_command_queue /* command_queue */, - cl_mem /* memobj */, - void * /* mapped_ptr */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMigrateMemObjects(cl_command_queue /* command_queue */, - cl_uint /* num_mem_objects */, - const cl_mem * /* mem_objects */, - cl_mem_migration_flags /* flags */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNDRangeKernel(cl_command_queue /* command_queue */, - cl_kernel /* kernel */, - cl_uint /* work_dim */, - const size_t * /* global_work_offset */, - const size_t * /* global_work_size */, - const size_t * /* local_work_size */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueTask(cl_command_queue /* command_queue */, - cl_kernel /* kernel */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueNativeKernel(cl_command_queue /* command_queue */, - void (CL_CALLBACK * /*user_func*/)(void *), - void * /* args */, - size_t /* cb_args */, - cl_uint /* num_mem_objects */, - const cl_mem * /* mem_list */, - const void ** /* args_mem_loc */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMarkerWithWaitList(cl_command_queue /* command_queue */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueBarrierWithWaitList(cl_command_queue /* command_queue */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clSetPrintfCallback(cl_context /* context */, - void (CL_CALLBACK * /* pfn_notify */)(cl_context /* program */, - cl_uint /*printf_data_len */, - char * /* printf_data_ptr */, - void * /* user_data */), - void * /* user_data */) CL_API_SUFFIX__VERSION_1_2; - - - -/* Extension function access - * - * Returns the extension function address for the given function name, - * or NULL if a valid function can not be found. The client must - * check to make sure the address is not NULL, before using or - * calling the returned function address. - */ -extern CL_API_ENTRY void * CL_API_CALL -clGetExtensionFunctionAddressForPlatform(cl_platform_id /* platform */, - const char * /* func_name */) CL_API_SUFFIX__VERSION_1_2; - - -#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS -#warning CL_USE_DEPRECATED_OPENCL_1_0_APIS is defined. These APIs are unsupported and untested in OpenCL 1.1! - /* - * WARNING: - * This API introduces mutable state into the OpenCL implementation. It has been REMOVED - * to better facilitate thread safety. The 1.0 API is not thread safe. It is not tested by the - * OpenCL 1.1 conformance test, and consequently may not work or may not work dependably. - * It is likely to be non-performant. Use of this API is not advised. Use at your own risk. - * - * Software developers previously relying on this API are instructed to set the command queue - * properties when creating the queue, instead. - */ - extern CL_API_ENTRY cl_int CL_API_CALL - clSetCommandQueueProperty(cl_command_queue /* command_queue */, - cl_command_queue_properties /* properties */, - cl_bool /* enable */, - cl_command_queue_properties * /* old_properties */) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED; -#endif /* CL_USE_DEPRECATED_OPENCL_1_0_APIS */ - - -#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS - extern CL_API_ENTRY cl_mem CL_API_CALL - clCreateImage2D(cl_context /* context */, - cl_mem_flags /* flags */, - const cl_image_format * /* image_format */, - size_t /* image_width */, - size_t /* image_height */, - size_t /* image_row_pitch */, - void * /* host_ptr */, - cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - - extern CL_API_ENTRY cl_mem CL_API_CALL - clCreateImage3D(cl_context /* context */, - cl_mem_flags /* flags */, - const cl_image_format * /* image_format */, - size_t /* image_width */, - size_t /* image_height */, - size_t /* image_depth */, - size_t /* image_row_pitch */, - size_t /* image_slice_pitch */, - void * /* host_ptr */, - cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - - extern CL_API_ENTRY cl_int CL_API_CALL - clEnqueueMarker(cl_command_queue /* command_queue */, - cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - - extern CL_API_ENTRY cl_int CL_API_CALL - clEnqueueWaitForEvents(cl_command_queue /* command_queue */, - cl_uint /* num_events */, - const cl_event * /* event_list */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - - extern CL_API_ENTRY cl_int CL_API_CALL - clEnqueueBarrier(cl_command_queue /* command_queue */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - - extern CL_API_ENTRY cl_int CL_API_CALL - clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - - extern CL_API_ENTRY void * CL_API_CALL - clGetExtensionFunctionAddress(const char * /* func_name */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; -#endif /* CL_USE_DEPRECATED_OPENCL_1_2_APIS */ - -#ifdef __cplusplus -} -#endif - -#endif /* __OPENCL_CL_H */ - diff --git a/OpenCL4Java/src/main/headers/1.2/CL/cl_apple.h b/OpenCL4Java/src/main/headers/1.2/CL/cl_apple.h deleted file mode 100644 index 8ba28881..00000000 --- a/OpenCL4Java/src/main/headers/1.2/CL/cl_apple.h +++ /dev/null @@ -1,60 +0,0 @@ - -/* Context GL sharing - * - * Please check for the "cl_APPLE_gl_sharing" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) - * before using these extensions. - - * Apple extension for creating a CL context from a CGL share group - * - * This enumerated value can be specified as part of the argument passed to clCreateContext - * to allow OpenCL compliant devices in an existing CGL share group to be used as the devices in - * the newly created CL context. GL objects that were allocated in the given CGL share group can - * now be shared between CL and GL. - * - * If the and argument values to clCreateContext are 0 and NULL respectively, - * all CL compliant devices in the CGL share group will be used to create the context. - * Additional CL devices can also be specified using the and arguments. - * These, however, cannot be GPU devices. On Mac OS X, you can add the CPU to the list of CL devices - * (in addition to the CL compliant devices in the CGL share group) used to create the CL context. - * Note that if a CPU device is specified, the CGL share group must also include the GL float renderer; - * Otherwise CL_INVALID_DEVICE will be returned. - * - * NOTE: Make sure that appropriate cl_gl.h header file is included separately - */ -#define CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE 0x10000000 /* Introduced in Mac OS X 10.6 */ - -/* Apple extension for retrieving OpenGL context information for a CL context - * created via the above method. - * - * Provides a query mechanism to retrieve OpenGL context specific information - * from an OpenCL context to help identify device specific mappings and usage. - * - * For example, one possible usage would be to allow the client to map a CGL - * virtual screen index to an appropriate CL device id to insure that the - * rendering device and the compute device are the same, thus guaranteeing - * any shared OpenGL memory that is attached o a CL memory object remains - * resident on the active device. - */ -cl_int clGetGLContextInfoAPPLE ( cl_context /* context */, - void * /* platform_gl_ctx */, - cl_gl_platform_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) ; - -/* The list of supported param_name values and the information returned in param_value by - * clGetContextInfo are listed below: - - * Returns a cl_device_id for the CL device associated with the virtual screen for - * the given CGL context. Return type: cl_device_id - */ -#define CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE 0x10000002 /* Introduced in Mac OS X 10.6 */ - -/* Returns an array of cl_device_ids for the CL device(s) corresponding to - * the virtual screen(s) for the given CGL context. Return type: cl_device_id[] - */ -#define CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE 0x10000003 /* Introduced in Mac OS X 10.6 */ - -/* Error code returned by clGetGLContextInfoAPPLE if an invalid platform_gl_ctx is provided */ -#define CL_INVALID_GL_CONTEXT_APPLE -1000 /* Introduced in Mac OS X 10.6 */ - diff --git a/OpenCL4Java/src/main/headers/1.2/CL/cl_ext.h b/OpenCL4Java/src/main/headers/1.2/CL/cl_ext.h deleted file mode 100644 index 4e92c7e6..00000000 --- a/OpenCL4Java/src/main/headers/1.2/CL/cl_ext.h +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - ******************************************************************************/ - -/* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */ - -/* cl_ext.h contains OpenCL extensions which don't have external */ -/* (OpenGL, D3D) dependencies. */ - -#ifndef __CL_EXT_H -#define __CL_EXT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __APPLE__ - #include - #include -#else - #include -#endif - -/* cl_khr_fp64 extension - no extension #define since it has no functions */ -#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 - -/* cl_khr_fp16 extension - no extension #define since it has no functions */ -#define CL_DEVICE_HALF_FP_CONFIG 0x1033 - -/* Memory object destruction - * - * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR - * - * Registers a user callback function that will be called when the memory object is deleted and its resources - * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback - * stack associated with memobj. The registered user callback functions are called in the reverse order in - * which they were registered. The user callback functions are called and then the memory object is deleted - * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be - * notified when the memory referenced by host_ptr, specified when the memory object is created and used as - * the storage bits for the memory object, can be reused or freed. - * - * The application may not call CL api's with the cl_mem object passed to the pfn_notify. - * - * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) - * before using. - */ -#define cl_APPLE_SetMemObjectDestructor 1 -cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */, - void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), - void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; - - -/* Context Logging Functions - * - * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext(). - * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) - * before using. - * - * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger - */ -#define cl_APPLE_ContextLoggingFunctions 1 -extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */, - const void * /* private_info */, - size_t /* cb */, - void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; - -/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */ -extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */, - const void * /* private_info */, - size_t /* cb */, - void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; - -/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */ -extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */, - const void * /* private_info */, - size_t /* cb */, - void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; - - -/************************ -* cl_khr_icd extension * -************************/ -#define cl_khr_icd 1 - -/* cl_platform_info */ -#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 - -/* Additional Error Codes */ -#define CL_PLATFORM_NOT_FOUND_KHR -1001 - -extern CL_API_ENTRY cl_int CL_API_CALL -clIcdGetPlatformIDsKHR(cl_uint /* num_entries */, - cl_platform_id * /* platforms */, - cl_uint * /* num_platforms */); - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)( - cl_uint /* num_entries */, - cl_platform_id * /* platforms */, - cl_uint * /* num_platforms */); - - -/****************************************** -* cl_nv_device_attribute_query extension * -******************************************/ -/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */ -#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 -#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 -#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 -#define CL_DEVICE_WARP_SIZE_NV 0x4003 -#define CL_DEVICE_GPU_OVERLAP_NV 0x4004 -#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 -#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 - - -/********************************* -* cl_amd_device_attribute_query * -*********************************/ -#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036 - - -#ifdef CL_VERSION_1_1 - /*********************************** - * cl_ext_device_fission extension * - ***********************************/ - #define cl_ext_device_fission 1 - - extern CL_API_ENTRY cl_int CL_API_CALL - clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; - - typedef CL_API_ENTRY cl_int - (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; - - extern CL_API_ENTRY cl_int CL_API_CALL - clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; - - typedef CL_API_ENTRY cl_int - (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; - - typedef cl_ulong cl_device_partition_property_ext; - extern CL_API_ENTRY cl_int CL_API_CALL - clCreateSubDevicesEXT( cl_device_id /*in_device*/, - const cl_device_partition_property_ext * /* properties */, - cl_uint /*num_entries*/, - cl_device_id * /*out_devices*/, - cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; - - typedef CL_API_ENTRY cl_int - ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/, - const cl_device_partition_property_ext * /* properties */, - cl_uint /*num_entries*/, - cl_device_id * /*out_devices*/, - cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; - - /* cl_device_partition_property_ext */ - #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050 - #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051 - #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052 - #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053 - - /* clDeviceGetInfo selectors */ - #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054 - #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055 - #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056 - #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057 - #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058 - - /* error codes */ - #define CL_DEVICE_PARTITION_FAILED_EXT -1057 - #define CL_INVALID_PARTITION_COUNT_EXT -1058 - #define CL_INVALID_PARTITION_NAME_EXT -1059 - - /* CL_AFFINITY_DOMAINs */ - #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1 - #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2 - #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3 - #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4 - #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10 - #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100 - - /* cl_device_partition_property_ext list terminators */ - #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0) - #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0) - #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1) - - - -#endif /* CL_VERSION_1_1 */ - -#ifdef __cplusplus -} -#endif - - -#endif /* __CL_EXT_H */ diff --git a/OpenCL4Java/src/main/headers/1.2/CL/cl_gl.h b/OpenCL4Java/src/main/headers/1.2/CL/cl_gl.h deleted file mode 100644 index e8586e23..00000000 --- a/OpenCL4Java/src/main/headers/1.2/CL/cl_gl.h +++ /dev/null @@ -1,163 +0,0 @@ -/********************************************************************************** - * Copyright (c) 2011 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ - -#ifndef __OPENCL_CL_GL_H -#define __OPENCL_CL_GL_H - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef cl_uint cl_gl_object_type; -typedef cl_uint cl_gl_texture_info; -typedef cl_uint cl_gl_platform_info; -typedef struct __GLsync *cl_GLsync; - -/* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */ -#define CL_GL_OBJECT_BUFFER 0x2000 -#define CL_GL_OBJECT_TEXTURE2D 0x2001 -#define CL_GL_OBJECT_TEXTURE3D 0x2002 -#define CL_GL_OBJECT_RENDERBUFFER 0x2003 -#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E -#define CL_GL_OBJECT_TEXTURE1D 0x200F -#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010 -#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011 - -/* cl_gl_texture_info */ -#define CL_GL_TEXTURE_TARGET 0x2004 -#define CL_GL_MIPMAP_LEVEL 0x2005 - - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLBuffer(cl_context /* context */, - cl_mem_flags /* flags */, - cl_GLuint /* bufobj */, - int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLTexture(cl_context /* context */, - cl_mem_flags /* flags */, - cl_GLenum /* target */, - cl_GLint /* miplevel */, - cl_GLuint /* texture */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLRenderbuffer(cl_context /* context */, - cl_mem_flags /* flags */, - cl_GLuint /* renderbuffer */, - cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLObjectInfo(cl_mem /* memobj */, - cl_gl_object_type * /* gl_object_type */, - cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLTextureInfo(cl_mem /* memobj */, - cl_gl_texture_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */, - cl_uint /* num_objects */, - const cl_mem * /* mem_objects */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */, - cl_uint /* num_objects */, - const cl_mem * /* mem_objects */, - cl_uint /* num_events_in_wait_list */, - const cl_event * /* event_wait_list */, - cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; - - -#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS -#warning CL_USE_DEPRECATED_OPENCL_1_1_APIS is defined. These APIs are unsupported and untested in OpenCL 1.2! - extern CL_API_ENTRY cl_mem CL_API_CALL - clCreateFromGLTexture2D(cl_context /* context */, - cl_mem_flags /* flags */, - cl_GLenum /* target */, - cl_GLint /* miplevel */, - cl_GLuint /* texture */, - cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - - extern CL_API_ENTRY cl_mem CL_API_CALL - clCreateFromGLTexture3D(cl_context /* context */, - cl_mem_flags /* flags */, - cl_GLenum /* target */, - cl_GLint /* miplevel */, - cl_GLuint /* texture */, - cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; -#endif /* CL_USE_DEPRECATED_OPENCL_1_2_APIS */ - -/* cl_khr_gl_sharing extension */ - -#define cl_khr_gl_sharing 1 - -typedef cl_uint cl_gl_context_info; - -/* Additional Error Codes */ -#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 - -/* cl_gl_context_info */ -#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 -#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 - -/* Additional cl_context_properties */ -#define CL_GL_CONTEXT_KHR 0x2008 -#define CL_EGL_DISPLAY_KHR 0x2009 -#define CL_GLX_DISPLAY_KHR 0x200A -#define CL_WGL_HDC_KHR 0x200B -#define CL_CGL_SHAREGROUP_KHR 0x200C - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLContextInfoKHR(const cl_context_properties * /* properties */, - cl_gl_context_info /* param_name */, - size_t /* param_value_size */, - void * /* param_value */, - size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)( - const cl_context_properties * properties, - cl_gl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret); - -#ifdef __cplusplus -} -#endif - -#endif /* __OPENCL_CL_GL_H */ diff --git a/OpenCL4Java/src/main/headers/1.2/CL/cl_gl_ext.h b/OpenCL4Java/src/main/headers/1.2/CL/cl_gl_ext.h deleted file mode 100644 index 7c9b64cf..00000000 --- a/OpenCL4Java/src/main/headers/1.2/CL/cl_gl_ext.h +++ /dev/null @@ -1,69 +0,0 @@ -/********************************************************************************** - * Copyright (c) 2008-2010 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ - -/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ - -/* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */ -/* OpenGL dependencies. */ - -#ifndef __OPENCL_CL_GL_EXT_H -#define __OPENCL_CL_GL_EXT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __APPLE__ - #include -#else - #include -#endif - -/* - * For each extension, follow this template - * cl_VEN_extname extension */ -/* #define cl_VEN_extname 1 - * ... define new types, if any - * ... define new tokens, if any - * ... define new APIs, if any - * - * If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header - * This allows us to avoid having to decide whether to include GL headers or GLES here. - */ - -/* - * cl_khr_gl_event extension - * See section 9.9 in the OpenCL 1.1 spec for more information - */ -#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D - -extern CL_API_ENTRY cl_event CL_API_CALL -clCreateEventFromGLsyncKHR(cl_context /* context */, - cl_GLsync /* cl_GLsync */, - cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1; - -#ifdef __cplusplus -} -#endif - -#endif /* __OPENCL_CL_GL_EXT_H */ diff --git a/OpenCL4Java/src/main/headers/1.2/CL/cl_platform.h b/OpenCL4Java/src/main/headers/1.2/CL/cl_platform.h deleted file mode 100644 index c8234309..00000000 --- a/OpenCL4Java/src/main/headers/1.2/CL/cl_platform.h +++ /dev/null @@ -1,1201 +0,0 @@ -/********************************************************************************** - * Copyright (c) 2008-2010 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ - -/* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */ - -#ifndef __CL_PLATFORM_H -#define __CL_PLATFORM_H - -#ifdef __APPLE__ - /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */ - #include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_WIN32) - #define CL_API_ENTRY - #define CL_API_CALL __stdcall - #define CL_CALLBACK __stdcall -#else - #define CL_API_ENTRY - #define CL_API_CALL - #define CL_CALLBACK -#endif - -#ifdef __APPLE__ - #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import)) - #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER - #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER - #define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK - #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK - #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER -#else - #define CL_EXTENSION_WEAK_LINK - #define CL_API_SUFFIX__VERSION_1_0 - #define CL_EXT_SUFFIX__VERSION_1_0 - #define CL_API_SUFFIX__VERSION_1_1 - #define CL_EXT_SUFFIX__VERSION_1_1 - #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED - #define CL_API_SUFFIX__VERSION_1_2 - #define CL_EXT_SUFFIX__VERSION_1_2 - #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -#endif - -#if (defined (_WIN32) && defined(_MSC_VER)) - -/* scalar types */ -typedef signed __int8 cl_char; -typedef unsigned __int8 cl_uchar; -typedef signed __int16 cl_short; -typedef unsigned __int16 cl_ushort; -typedef signed __int32 cl_int; -typedef unsigned __int32 cl_uint; -typedef signed __int64 cl_long; -typedef unsigned __int64 cl_ulong; - -typedef unsigned __int16 cl_half; -typedef float cl_float; -typedef double cl_double; - -/* Macro names and corresponding values defined by OpenCL */ -#define CL_CHAR_BIT 8 -#define CL_SCHAR_MAX 127 -#define CL_SCHAR_MIN (-127-1) -#define CL_CHAR_MAX CL_SCHAR_MAX -#define CL_CHAR_MIN CL_SCHAR_MIN -#define CL_UCHAR_MAX 255 -#define CL_SHRT_MAX 32767 -#define CL_SHRT_MIN (-32767-1) -#define CL_USHRT_MAX 65535 -#define CL_INT_MAX 2147483647 -#define CL_INT_MIN (-2147483647-1) -#define CL_UINT_MAX 0xffffffffU -#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) -#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) -#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) - -#define CL_FLT_DIG 6 -#define CL_FLT_MANT_DIG 24 -#define CL_FLT_MAX_10_EXP +38 -#define CL_FLT_MAX_EXP +128 -#define CL_FLT_MIN_10_EXP -37 -#define CL_FLT_MIN_EXP -125 -#define CL_FLT_RADIX 2 -#define CL_FLT_MAX 340282346638528859811704183484516925440.0f -#define CL_FLT_MIN 1.175494350822287507969e-38f -#define CL_FLT_EPSILON 0x1.0p-23f - -#define CL_DBL_DIG 15 -#define CL_DBL_MANT_DIG 53 -#define CL_DBL_MAX_10_EXP +308 -#define CL_DBL_MAX_EXP +1024 -#define CL_DBL_MIN_10_EXP -307 -#define CL_DBL_MIN_EXP -1021 -#define CL_DBL_RADIX 2 -#define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 -#define CL_DBL_MIN 2.225073858507201383090e-308 -#define CL_DBL_EPSILON 2.220446049250313080847e-16 - -#define CL_M_E 2.718281828459045090796 -#define CL_M_LOG2E 1.442695040888963387005 -#define CL_M_LOG10E 0.434294481903251816668 -#define CL_M_LN2 0.693147180559945286227 -#define CL_M_LN10 2.302585092994045901094 -#define CL_M_PI 3.141592653589793115998 -#define CL_M_PI_2 1.570796326794896557999 -#define CL_M_PI_4 0.785398163397448278999 -#define CL_M_1_PI 0.318309886183790691216 -#define CL_M_2_PI 0.636619772367581382433 -#define CL_M_2_SQRTPI 1.128379167095512558561 -#define CL_M_SQRT2 1.414213562373095145475 -#define CL_M_SQRT1_2 0.707106781186547572737 - -#define CL_M_E_F 2.71828174591064f -#define CL_M_LOG2E_F 1.44269502162933f -#define CL_M_LOG10E_F 0.43429449200630f -#define CL_M_LN2_F 0.69314718246460f -#define CL_M_LN10_F 2.30258512496948f -#define CL_M_PI_F 3.14159274101257f -#define CL_M_PI_2_F 1.57079637050629f -#define CL_M_PI_4_F 0.78539818525314f -#define CL_M_1_PI_F 0.31830987334251f -#define CL_M_2_PI_F 0.63661974668503f -#define CL_M_2_SQRTPI_F 1.12837922573090f -#define CL_M_SQRT2_F 1.41421353816986f -#define CL_M_SQRT1_2_F 0.70710676908493f - -#define CL_NAN (CL_INFINITY - CL_INFINITY) -#define CL_HUGE_VALF ((cl_float) 1e50) -#define CL_HUGE_VAL ((cl_double) 1e500) -#define CL_MAXFLOAT CL_FLT_MAX -#define CL_INFINITY CL_HUGE_VALF - -#else - -#include - -/* scalar types */ -typedef int8_t cl_char; -typedef uint8_t cl_uchar; -typedef int16_t cl_short __attribute__((aligned(2))); -typedef uint16_t cl_ushort __attribute__((aligned(2))); -typedef int32_t cl_int __attribute__((aligned(4))); -typedef uint32_t cl_uint __attribute__((aligned(4))); -typedef int64_t cl_long __attribute__((aligned(8))); -typedef uint64_t cl_ulong __attribute__((aligned(8))); - -typedef uint16_t cl_half __attribute__((aligned(2))); -typedef float cl_float __attribute__((aligned(4))); -typedef double cl_double __attribute__((aligned(8))); - -/* Macro names and corresponding values defined by OpenCL */ -#define CL_CHAR_BIT 8 -#define CL_SCHAR_MAX 127 -#define CL_SCHAR_MIN (-127-1) -#define CL_CHAR_MAX CL_SCHAR_MAX -#define CL_CHAR_MIN CL_SCHAR_MIN -#define CL_UCHAR_MAX 255 -#define CL_SHRT_MAX 32767 -#define CL_SHRT_MIN (-32767-1) -#define CL_USHRT_MAX 65535 -#define CL_INT_MAX 2147483647 -#define CL_INT_MIN (-2147483647-1) -#define CL_UINT_MAX 0xffffffffU -#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) -#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) -#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) - -#define CL_FLT_DIG 6 -#define CL_FLT_MANT_DIG 24 -#define CL_FLT_MAX_10_EXP +38 -#define CL_FLT_MAX_EXP +128 -#define CL_FLT_MIN_10_EXP -37 -#define CL_FLT_MIN_EXP -125 -#define CL_FLT_RADIX 2 -#define CL_FLT_MAX 0x1.fffffep127f -#define CL_FLT_MIN 0x1.0p-126f -#define CL_FLT_EPSILON 0x1.0p-23f - -#define CL_DBL_DIG 15 -#define CL_DBL_MANT_DIG 53 -#define CL_DBL_MAX_10_EXP +308 -#define CL_DBL_MAX_EXP +1024 -#define CL_DBL_MIN_10_EXP -307 -#define CL_DBL_MIN_EXP -1021 -#define CL_DBL_RADIX 2 -#define CL_DBL_MAX 0x1.fffffffffffffp1023 -#define CL_DBL_MIN 0x1.0p-1022 -#define CL_DBL_EPSILON 0x1.0p-52 - -#define CL_M_E 2.718281828459045090796 -#define CL_M_LOG2E 1.442695040888963387005 -#define CL_M_LOG10E 0.434294481903251816668 -#define CL_M_LN2 0.693147180559945286227 -#define CL_M_LN10 2.302585092994045901094 -#define CL_M_PI 3.141592653589793115998 -#define CL_M_PI_2 1.570796326794896557999 -#define CL_M_PI_4 0.785398163397448278999 -#define CL_M_1_PI 0.318309886183790691216 -#define CL_M_2_PI 0.636619772367581382433 -#define CL_M_2_SQRTPI 1.128379167095512558561 -#define CL_M_SQRT2 1.414213562373095145475 -#define CL_M_SQRT1_2 0.707106781186547572737 - -#define CL_M_E_F 2.71828174591064f -#define CL_M_LOG2E_F 1.44269502162933f -#define CL_M_LOG10E_F 0.43429449200630f -#define CL_M_LN2_F 0.69314718246460f -#define CL_M_LN10_F 2.30258512496948f -#define CL_M_PI_F 3.14159274101257f -#define CL_M_PI_2_F 1.57079637050629f -#define CL_M_PI_4_F 0.78539818525314f -#define CL_M_1_PI_F 0.31830987334251f -#define CL_M_2_PI_F 0.63661974668503f -#define CL_M_2_SQRTPI_F 1.12837922573090f -#define CL_M_SQRT2_F 1.41421353816986f -#define CL_M_SQRT1_2_F 0.70710676908493f - -#if defined( __GNUC__ ) - #define CL_HUGE_VALF __builtin_huge_valf() - #define CL_HUGE_VAL __builtin_huge_val() - #define CL_NAN __builtin_nanf( "" ) -#else - #define CL_HUGE_VALF ((cl_float) 1e50) - #define CL_HUGE_VAL ((cl_double) 1e500) - float nanf( const char * ); - #define CL_NAN nanf( "" ) -#endif -#define CL_MAXFLOAT CL_FLT_MAX -#define CL_INFINITY CL_HUGE_VALF - -#endif - -#include - -/* Mirror types to GL types. Mirror types allow us to avoid deciding which headers to load based on whether we are using GL or GLES here. */ -typedef unsigned int cl_GLuint; -typedef int cl_GLint; -typedef unsigned int cl_GLenum; - -/* - * Vector types - * - * Note: OpenCL requires that all types be naturally aligned. - * This means that vector types must be naturally aligned. - * For example, a vector of four floats must be aligned to - * a 16 byte boundary (calculated as 4 * the natural 4-byte - * alignment of the float). The alignment qualifiers here - * will only function properly if your compiler supports them - * and if you don't actively work to defeat them. For example, - * in order for a cl_float4 to be 16 byte aligned in a struct, - * the start of the struct must itself be 16-byte aligned. - * - * Maintaining proper alignment is the user's responsibility. - */ - -/* Define basic vector types */ -#if defined( __VEC__ ) - #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ - typedef vector unsigned char __cl_uchar16; - typedef vector signed char __cl_char16; - typedef vector unsigned short __cl_ushort8; - typedef vector signed short __cl_short8; - typedef vector unsigned int __cl_uint4; - typedef vector signed int __cl_int4; - typedef vector float __cl_float4; - #define __CL_UCHAR16__ 1 - #define __CL_CHAR16__ 1 - #define __CL_USHORT8__ 1 - #define __CL_SHORT8__ 1 - #define __CL_UINT4__ 1 - #define __CL_INT4__ 1 - #define __CL_FLOAT4__ 1 -#endif - -#if defined( __SSE__ ) - #if defined( __MINGW64__ ) - #include - #else - #include - #endif - #if defined( __GNUC__ ) - typedef float __cl_float4 __attribute__((vector_size(16))); - #else - typedef __m128 __cl_float4; - #endif - #define __CL_FLOAT4__ 1 -#endif - -#if defined( __SSE2__ ) - #if defined( __MINGW64__ ) - #include - #else - #include - #endif - #if defined( __GNUC__ ) - typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16))); - typedef cl_char __cl_char16 __attribute__((vector_size(16))); - typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16))); - typedef cl_short __cl_short8 __attribute__((vector_size(16))); - typedef cl_uint __cl_uint4 __attribute__((vector_size(16))); - typedef cl_int __cl_int4 __attribute__((vector_size(16))); - typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16))); - typedef cl_long __cl_long2 __attribute__((vector_size(16))); - typedef cl_double __cl_double2 __attribute__((vector_size(16))); - #else - typedef __m128i __cl_uchar16; - typedef __m128i __cl_char16; - typedef __m128i __cl_ushort8; - typedef __m128i __cl_short8; - typedef __m128i __cl_uint4; - typedef __m128i __cl_int4; - typedef __m128i __cl_ulong2; - typedef __m128i __cl_long2; - typedef __m128d __cl_double2; - #endif - #define __CL_UCHAR16__ 1 - #define __CL_CHAR16__ 1 - #define __CL_USHORT8__ 1 - #define __CL_SHORT8__ 1 - #define __CL_INT4__ 1 - #define __CL_UINT4__ 1 - #define __CL_ULONG2__ 1 - #define __CL_LONG2__ 1 - #define __CL_DOUBLE2__ 1 -#endif - -#if defined( __MMX__ ) - #include - #if defined( __GNUC__ ) - typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8))); - typedef cl_char __cl_char8 __attribute__((vector_size(8))); - typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8))); - typedef cl_short __cl_short4 __attribute__((vector_size(8))); - typedef cl_uint __cl_uint2 __attribute__((vector_size(8))); - typedef cl_int __cl_int2 __attribute__((vector_size(8))); - typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8))); - typedef cl_long __cl_long1 __attribute__((vector_size(8))); - typedef cl_float __cl_float2 __attribute__((vector_size(8))); - #else - typedef __m64 __cl_uchar8; - typedef __m64 __cl_char8; - typedef __m64 __cl_ushort4; - typedef __m64 __cl_short4; - typedef __m64 __cl_uint2; - typedef __m64 __cl_int2; - typedef __m64 __cl_ulong1; - typedef __m64 __cl_long1; - typedef __m64 __cl_float2; - #endif - #define __CL_UCHAR8__ 1 - #define __CL_CHAR8__ 1 - #define __CL_USHORT4__ 1 - #define __CL_SHORT4__ 1 - #define __CL_INT2__ 1 - #define __CL_UINT2__ 1 - #define __CL_ULONG1__ 1 - #define __CL_LONG1__ 1 - #define __CL_FLOAT2__ 1 -#endif - -#if defined( __AVX__ ) - #if defined( __MINGW64__ ) - #include - #else - #include - #endif - #if defined( __GNUC__ ) - typedef cl_float __cl_float8 __attribute__((vector_size(32))); - typedef cl_double __cl_double4 __attribute__((vector_size(32))); - #else - typedef __m256 __cl_float8; - typedef __m256d __cl_double4; - #endif - #define __CL_FLOAT8__ 1 - #define __CL_DOUBLE4__ 1 -#endif - -/* Define alignment keys */ -#if defined( __GNUC__ ) - #define CL_ALIGNED(_x) __attribute__ ((aligned(_x))) -#elif defined( _WIN32) && (_MSC_VER) - /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */ - /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */ - /* #include */ - /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */ - #define CL_ALIGNED(_x) -#else - #warning Need to implement some method to align data here - #define CL_ALIGNED(_x) -#endif - -/* Indicate whether .xyzw, .s0123 and .hi.lo are supported */ -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - /* .xyzw and .s0123...{f|F} are supported */ - #define CL_HAS_NAMED_VECTOR_FIELDS 1 - /* .hi and .lo are supported */ - #define CL_HAS_HI_LO_VECTOR_FIELDS 1 -#endif - -/* Define cl_vector types */ - -/* ---- cl_charn ---- */ -typedef union -{ - cl_char CL_ALIGNED(2) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_char x, y; }; - __extension__ struct{ cl_char s0, s1; }; - __extension__ struct{ cl_char lo, hi; }; -#endif -#if defined( __CL_CHAR2__) - __cl_char2 v2; -#endif -}cl_char2; - -typedef union -{ - cl_char CL_ALIGNED(4) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_char x, y, z, w; }; - __extension__ struct{ cl_char s0, s1, s2, s3; }; - __extension__ struct{ cl_char2 lo, hi; }; -#endif -#if defined( __CL_CHAR2__) - __cl_char2 v2[2]; -#endif -#if defined( __CL_CHAR4__) - __cl_char4 v4; -#endif -}cl_char4; - -/* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */ -typedef cl_char4 cl_char3; - -typedef union -{ - cl_char CL_ALIGNED(8) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_char x, y, z, w; }; - __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_char4 lo, hi; }; -#endif -#if defined( __CL_CHAR2__) - __cl_char2 v2[4]; -#endif -#if defined( __CL_CHAR4__) - __cl_char4 v4[2]; -#endif -#if defined( __CL_CHAR8__ ) - __cl_char8 v8; -#endif -}cl_char8; - -typedef union -{ - cl_char CL_ALIGNED(16) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_char8 lo, hi; }; -#endif -#if defined( __CL_CHAR2__) - __cl_char2 v2[8]; -#endif -#if defined( __CL_CHAR4__) - __cl_char4 v4[4]; -#endif -#if defined( __CL_CHAR8__ ) - __cl_char8 v8[2]; -#endif -#if defined( __CL_CHAR16__ ) - __cl_char16 v16; -#endif -}cl_char16; - - -/* ---- cl_ucharn ---- */ -typedef union -{ - cl_uchar CL_ALIGNED(2) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uchar x, y; }; - __extension__ struct{ cl_uchar s0, s1; }; - __extension__ struct{ cl_uchar lo, hi; }; -#endif -#if defined( __cl_uchar2__) - __cl_uchar2 v2; -#endif -}cl_uchar2; - -typedef union -{ - cl_uchar CL_ALIGNED(4) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uchar x, y, z, w; }; - __extension__ struct{ cl_uchar s0, s1, s2, s3; }; - __extension__ struct{ cl_uchar2 lo, hi; }; -#endif -#if defined( __CL_UCHAR2__) - __cl_uchar2 v2[2]; -#endif -#if defined( __CL_UCHAR4__) - __cl_uchar4 v4; -#endif -}cl_uchar4; - -/* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */ -typedef cl_uchar4 cl_uchar3; - -typedef union -{ - cl_uchar CL_ALIGNED(8) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uchar x, y, z, w; }; - __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_uchar4 lo, hi; }; -#endif -#if defined( __CL_UCHAR2__) - __cl_uchar2 v2[4]; -#endif -#if defined( __CL_UCHAR4__) - __cl_uchar4 v4[2]; -#endif -#if defined( __CL_UCHAR8__ ) - __cl_uchar8 v8; -#endif -}cl_uchar8; - -typedef union -{ - cl_uchar CL_ALIGNED(16) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_uchar8 lo, hi; }; -#endif -#if defined( __CL_UCHAR2__) - __cl_uchar2 v2[8]; -#endif -#if defined( __CL_UCHAR4__) - __cl_uchar4 v4[4]; -#endif -#if defined( __CL_UCHAR8__ ) - __cl_uchar8 v8[2]; -#endif -#if defined( __CL_UCHAR16__ ) - __cl_uchar16 v16; -#endif -}cl_uchar16; - - -/* ---- cl_shortn ---- */ -typedef union -{ - cl_short CL_ALIGNED(4) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_short x, y; }; - __extension__ struct{ cl_short s0, s1; }; - __extension__ struct{ cl_short lo, hi; }; -#endif -#if defined( __CL_SHORT2__) - __cl_short2 v2; -#endif -}cl_short2; - -typedef union -{ - cl_short CL_ALIGNED(8) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_short x, y, z, w; }; - __extension__ struct{ cl_short s0, s1, s2, s3; }; - __extension__ struct{ cl_short2 lo, hi; }; -#endif -#if defined( __CL_SHORT2__) - __cl_short2 v2[2]; -#endif -#if defined( __CL_SHORT4__) - __cl_short4 v4; -#endif -}cl_short4; - -/* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */ -typedef cl_short4 cl_short3; - -typedef union -{ - cl_short CL_ALIGNED(16) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_short x, y, z, w; }; - __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_short4 lo, hi; }; -#endif -#if defined( __CL_SHORT2__) - __cl_short2 v2[4]; -#endif -#if defined( __CL_SHORT4__) - __cl_short4 v4[2]; -#endif -#if defined( __CL_SHORT8__ ) - __cl_short8 v8; -#endif -}cl_short8; - -typedef union -{ - cl_short CL_ALIGNED(32) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_short8 lo, hi; }; -#endif -#if defined( __CL_SHORT2__) - __cl_short2 v2[8]; -#endif -#if defined( __CL_SHORT4__) - __cl_short4 v4[4]; -#endif -#if defined( __CL_SHORT8__ ) - __cl_short8 v8[2]; -#endif -#if defined( __CL_SHORT16__ ) - __cl_short16 v16; -#endif -}cl_short16; - - -/* ---- cl_ushortn ---- */ -typedef union -{ - cl_ushort CL_ALIGNED(4) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ushort x, y; }; - __extension__ struct{ cl_ushort s0, s1; }; - __extension__ struct{ cl_ushort lo, hi; }; -#endif -#if defined( __CL_USHORT2__) - __cl_ushort2 v2; -#endif -}cl_ushort2; - -typedef union -{ - cl_ushort CL_ALIGNED(8) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ushort x, y, z, w; }; - __extension__ struct{ cl_ushort s0, s1, s2, s3; }; - __extension__ struct{ cl_ushort2 lo, hi; }; -#endif -#if defined( __CL_USHORT2__) - __cl_ushort2 v2[2]; -#endif -#if defined( __CL_USHORT4__) - __cl_ushort4 v4; -#endif -}cl_ushort4; - -/* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */ -typedef cl_ushort4 cl_ushort3; - -typedef union -{ - cl_ushort CL_ALIGNED(16) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ushort x, y, z, w; }; - __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_ushort4 lo, hi; }; -#endif -#if defined( __CL_USHORT2__) - __cl_ushort2 v2[4]; -#endif -#if defined( __CL_USHORT4__) - __cl_ushort4 v4[2]; -#endif -#if defined( __CL_USHORT8__ ) - __cl_ushort8 v8; -#endif -}cl_ushort8; - -typedef union -{ - cl_ushort CL_ALIGNED(32) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_ushort8 lo, hi; }; -#endif -#if defined( __CL_USHORT2__) - __cl_ushort2 v2[8]; -#endif -#if defined( __CL_USHORT4__) - __cl_ushort4 v4[4]; -#endif -#if defined( __CL_USHORT8__ ) - __cl_ushort8 v8[2]; -#endif -#if defined( __CL_USHORT16__ ) - __cl_ushort16 v16; -#endif -}cl_ushort16; - -/* ---- cl_intn ---- */ -typedef union -{ - cl_int CL_ALIGNED(8) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_int x, y; }; - __extension__ struct{ cl_int s0, s1; }; - __extension__ struct{ cl_int lo, hi; }; -#endif -#if defined( __CL_INT2__) - __cl_int2 v2; -#endif -}cl_int2; - -typedef union -{ - cl_int CL_ALIGNED(16) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_int x, y, z, w; }; - __extension__ struct{ cl_int s0, s1, s2, s3; }; - __extension__ struct{ cl_int2 lo, hi; }; -#endif -#if defined( __CL_INT2__) - __cl_int2 v2[2]; -#endif -#if defined( __CL_INT4__) - __cl_int4 v4; -#endif -}cl_int4; - -/* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */ -typedef cl_int4 cl_int3; - -typedef union -{ - cl_int CL_ALIGNED(32) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_int x, y, z, w; }; - __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_int4 lo, hi; }; -#endif -#if defined( __CL_INT2__) - __cl_int2 v2[4]; -#endif -#if defined( __CL_INT4__) - __cl_int4 v4[2]; -#endif -#if defined( __CL_INT8__ ) - __cl_int8 v8; -#endif -}cl_int8; - -typedef union -{ - cl_int CL_ALIGNED(64) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_int8 lo, hi; }; -#endif -#if defined( __CL_INT2__) - __cl_int2 v2[8]; -#endif -#if defined( __CL_INT4__) - __cl_int4 v4[4]; -#endif -#if defined( __CL_INT8__ ) - __cl_int8 v8[2]; -#endif -#if defined( __CL_INT16__ ) - __cl_int16 v16; -#endif -}cl_int16; - - -/* ---- cl_uintn ---- */ -typedef union -{ - cl_uint CL_ALIGNED(8) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uint x, y; }; - __extension__ struct{ cl_uint s0, s1; }; - __extension__ struct{ cl_uint lo, hi; }; -#endif -#if defined( __CL_UINT2__) - __cl_uint2 v2; -#endif -}cl_uint2; - -typedef union -{ - cl_uint CL_ALIGNED(16) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uint x, y, z, w; }; - __extension__ struct{ cl_uint s0, s1, s2, s3; }; - __extension__ struct{ cl_uint2 lo, hi; }; -#endif -#if defined( __CL_UINT2__) - __cl_uint2 v2[2]; -#endif -#if defined( __CL_UINT4__) - __cl_uint4 v4; -#endif -}cl_uint4; - -/* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */ -typedef cl_uint4 cl_uint3; - -typedef union -{ - cl_uint CL_ALIGNED(32) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uint x, y, z, w; }; - __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_uint4 lo, hi; }; -#endif -#if defined( __CL_UINT2__) - __cl_uint2 v2[4]; -#endif -#if defined( __CL_UINT4__) - __cl_uint4 v4[2]; -#endif -#if defined( __CL_UINT8__ ) - __cl_uint8 v8; -#endif -}cl_uint8; - -typedef union -{ - cl_uint CL_ALIGNED(64) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_uint8 lo, hi; }; -#endif -#if defined( __CL_UINT2__) - __cl_uint2 v2[8]; -#endif -#if defined( __CL_UINT4__) - __cl_uint4 v4[4]; -#endif -#if defined( __CL_UINT8__ ) - __cl_uint8 v8[2]; -#endif -#if defined( __CL_UINT16__ ) - __cl_uint16 v16; -#endif -}cl_uint16; - -/* ---- cl_longn ---- */ -typedef union -{ - cl_long CL_ALIGNED(16) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_long x, y; }; - __extension__ struct{ cl_long s0, s1; }; - __extension__ struct{ cl_long lo, hi; }; -#endif -#if defined( __CL_LONG2__) - __cl_long2 v2; -#endif -}cl_long2; - -typedef union -{ - cl_long CL_ALIGNED(32) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_long x, y, z, w; }; - __extension__ struct{ cl_long s0, s1, s2, s3; }; - __extension__ struct{ cl_long2 lo, hi; }; -#endif -#if defined( __CL_LONG2__) - __cl_long2 v2[2]; -#endif -#if defined( __CL_LONG4__) - __cl_long4 v4; -#endif -}cl_long4; - -/* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */ -typedef cl_long4 cl_long3; - -typedef union -{ - cl_long CL_ALIGNED(64) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_long x, y, z, w; }; - __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_long4 lo, hi; }; -#endif -#if defined( __CL_LONG2__) - __cl_long2 v2[4]; -#endif -#if defined( __CL_LONG4__) - __cl_long4 v4[2]; -#endif -#if defined( __CL_LONG8__ ) - __cl_long8 v8; -#endif -}cl_long8; - -typedef union -{ - cl_long CL_ALIGNED(128) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_long8 lo, hi; }; -#endif -#if defined( __CL_LONG2__) - __cl_long2 v2[8]; -#endif -#if defined( __CL_LONG4__) - __cl_long4 v4[4]; -#endif -#if defined( __CL_LONG8__ ) - __cl_long8 v8[2]; -#endif -#if defined( __CL_LONG16__ ) - __cl_long16 v16; -#endif -}cl_long16; - - -/* ---- cl_ulongn ---- */ -typedef union -{ - cl_ulong CL_ALIGNED(16) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ulong x, y; }; - __extension__ struct{ cl_ulong s0, s1; }; - __extension__ struct{ cl_ulong lo, hi; }; -#endif -#if defined( __CL_ULONG2__) - __cl_ulong2 v2; -#endif -}cl_ulong2; - -typedef union -{ - cl_ulong CL_ALIGNED(32) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ulong x, y, z, w; }; - __extension__ struct{ cl_ulong s0, s1, s2, s3; }; - __extension__ struct{ cl_ulong2 lo, hi; }; -#endif -#if defined( __CL_ULONG2__) - __cl_ulong2 v2[2]; -#endif -#if defined( __CL_ULONG4__) - __cl_ulong4 v4; -#endif -}cl_ulong4; - -/* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */ -typedef cl_ulong4 cl_ulong3; - -typedef union -{ - cl_ulong CL_ALIGNED(64) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ulong x, y, z, w; }; - __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_ulong4 lo, hi; }; -#endif -#if defined( __CL_ULONG2__) - __cl_ulong2 v2[4]; -#endif -#if defined( __CL_ULONG4__) - __cl_ulong4 v4[2]; -#endif -#if defined( __CL_ULONG8__ ) - __cl_ulong8 v8; -#endif -}cl_ulong8; - -typedef union -{ - cl_ulong CL_ALIGNED(128) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_ulong8 lo, hi; }; -#endif -#if defined( __CL_ULONG2__) - __cl_ulong2 v2[8]; -#endif -#if defined( __CL_ULONG4__) - __cl_ulong4 v4[4]; -#endif -#if defined( __CL_ULONG8__ ) - __cl_ulong8 v8[2]; -#endif -#if defined( __CL_ULONG16__ ) - __cl_ulong16 v16; -#endif -}cl_ulong16; - - -/* --- cl_floatn ---- */ - -typedef union -{ - cl_float CL_ALIGNED(8) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_float x, y; }; - __extension__ struct{ cl_float s0, s1; }; - __extension__ struct{ cl_float lo, hi; }; -#endif -#if defined( __CL_FLOAT2__) - __cl_float2 v2; -#endif -}cl_float2; - -typedef union -{ - cl_float CL_ALIGNED(16) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_float x, y, z, w; }; - __extension__ struct{ cl_float s0, s1, s2, s3; }; - __extension__ struct{ cl_float2 lo, hi; }; -#endif -#if defined( __CL_FLOAT2__) - __cl_float2 v2[2]; -#endif -#if defined( __CL_FLOAT4__) - __cl_float4 v4; -#endif -}cl_float4; - -/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */ -typedef cl_float4 cl_float3; - -typedef union -{ - cl_float CL_ALIGNED(32) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_float x, y, z, w; }; - __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_float4 lo, hi; }; -#endif -#if defined( __CL_FLOAT2__) - __cl_float2 v2[4]; -#endif -#if defined( __CL_FLOAT4__) - __cl_float4 v4[2]; -#endif -#if defined( __CL_FLOAT8__ ) - __cl_float8 v8; -#endif -}cl_float8; - -typedef union -{ - cl_float CL_ALIGNED(64) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_float8 lo, hi; }; -#endif -#if defined( __CL_FLOAT2__) - __cl_float2 v2[8]; -#endif -#if defined( __CL_FLOAT4__) - __cl_float4 v4[4]; -#endif -#if defined( __CL_FLOAT8__ ) - __cl_float8 v8[2]; -#endif -#if defined( __CL_FLOAT16__ ) - __cl_float16 v16; -#endif -}cl_float16; - -/* --- cl_doublen ---- */ - -typedef union -{ - cl_double CL_ALIGNED(16) s[2]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_double x, y; }; - __extension__ struct{ cl_double s0, s1; }; - __extension__ struct{ cl_double lo, hi; }; -#endif -#if defined( __CL_DOUBLE2__) - __cl_double2 v2; -#endif -}cl_double2; - -typedef union -{ - cl_double CL_ALIGNED(32) s[4]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_double x, y, z, w; }; - __extension__ struct{ cl_double s0, s1, s2, s3; }; - __extension__ struct{ cl_double2 lo, hi; }; -#endif -#if defined( __CL_DOUBLE2__) - __cl_double2 v2[2]; -#endif -#if defined( __CL_DOUBLE4__) - __cl_double4 v4; -#endif -}cl_double4; - -/* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */ -typedef cl_double4 cl_double3; - -typedef union -{ - cl_double CL_ALIGNED(64) s[8]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_double x, y, z, w; }; - __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; }; - __extension__ struct{ cl_double4 lo, hi; }; -#endif -#if defined( __CL_DOUBLE2__) - __cl_double2 v2[4]; -#endif -#if defined( __CL_DOUBLE4__) - __cl_double4 v4[2]; -#endif -#if defined( __CL_DOUBLE8__ ) - __cl_double8 v8; -#endif -}cl_double8; - -typedef union -{ - cl_double CL_ALIGNED(128) s[16]; -#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) - __extension__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; - __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; - __extension__ struct{ cl_double8 lo, hi; }; -#endif -#if defined( __CL_DOUBLE2__) - __cl_double2 v2[8]; -#endif -#if defined( __CL_DOUBLE4__) - __cl_double4 v4[4]; -#endif -#if defined( __CL_DOUBLE8__ ) - __cl_double8 v8[2]; -#endif -#if defined( __CL_DOUBLE16__ ) - __cl_double16 v16; -#endif -}cl_double16; - -/* Macro to facilitate debugging - * Usage: - * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source. - * The first line ends with: CL_PROGRAM_STRING_BEGIN \" - * Each line thereafter of OpenCL C source must end with: \n\ - * The last line ends in "; - * - * Example: - * - * const char *my_program = CL_PROGRAM_STRING_BEGIN "\ - * kernel void foo( int a, float * b ) \n\ - * { \n\ - * // my comment \n\ - * *b[ get_global_id(0)] = a; \n\ - * } \n\ - * "; - * - * This should correctly set up the line, (column) and file information for your source - * string so you can do source level debugging. - */ -#define __CL_STRINGIFY( _x ) # _x -#define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x ) -#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n" - -#ifdef __cplusplus -} -#endif - -#endif /* __CL_PLATFORM_H */ diff --git a/OpenCL4Java/src/main/headers/1.2/CL/opencl.h b/OpenCL4Java/src/main/headers/1.2/CL/opencl.h deleted file mode 100644 index 685b90c0..00000000 --- a/OpenCL4Java/src/main/headers/1.2/CL/opencl.h +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2010 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - ******************************************************************************/ - -/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ - -#ifndef __OPENCL_H -#define __OPENCL_H - -#ifdef __cplusplus -extern "C" { -#endif - -//#ifdef __APPLE__ -// -//#include -//#include -//#include -//#include -// -//#else - -#include -#include -#include -#include - -//#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __OPENCL_H */ - diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/IOpenCLLibrary.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/IOpenCLLibrary.java deleted file mode 100644 index f7efb325..00000000 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/IOpenCLLibrary.java +++ /dev/null @@ -1,901 +0,0 @@ -package com.nativelibs4java.opencl.library; -import org.bridj.Callback; -import org.bridj.Pointer; -import org.bridj.SizeT; -import org.bridj.TypedPointer; -import org.bridj.ann.Optional; -import org.bridj.ann.Ptr; -/** - * Interface for library OpenCL
    - * This file was autogenerated by
    JNAerator,
    - * a tool written by Olivier Chafik that uses a few opensource projects..
    - * For help, please visit NativeLibs4Java or BridJ . - */ -public interface IOpenCLLibrary { - public static final int CL_CHAR_BIT = 8; - public static final int CL_SCHAR_MAX = 127; - public static final int CL_SCHAR_MIN = (-127 - 1); - public static final int CL_CHAR_MAX = 127; - public static final int CL_CHAR_MIN = (-127 - 1); - public static final int CL_UCHAR_MAX = 255; - public static final int CL_SHRT_MAX = 32767; - public static final int CL_SHRT_MIN = (-32767 - 1); - public static final int CL_USHRT_MAX = 65535; - public static final int CL_INT_MAX = 2147483647; - public static final int CL_INT_MIN = (-2147483647 - 1); - public static final long CL_UINT_MAX = 0xffffffffL; - public static final int CL_FLT_DIG = 6; - public static final int CL_FLT_MANT_DIG = 24; - public static final int CL_FLT_MAX_10_EXP = +38; - public static final int CL_FLT_MAX_EXP = +128; - public static final int CL_FLT_MIN_10_EXP = -37; - public static final int CL_FLT_MIN_EXP = -125; - public static final int CL_FLT_RADIX = 2; - public static final int CL_DBL_DIG = 15; - public static final int CL_DBL_MANT_DIG = 53; - public static final int CL_DBL_MAX_10_EXP = +308; - public static final int CL_DBL_MAX_EXP = +1024; - public static final int CL_DBL_MIN_10_EXP = -307; - public static final int CL_DBL_MIN_EXP = -1021; - public static final int CL_DBL_RADIX = 2; - public static final double CL_M_E = 2.718281828459045090796; - public static final double CL_M_LOG2E = 1.442695040888963387005; - public static final double CL_M_LOG10E = 0.434294481903251816668; - public static final double CL_M_LN2 = 0.693147180559945286227; - public static final double CL_M_LN10 = 2.302585092994045901094; - public static final double CL_M_PI = 3.141592653589793115998; - public static final double CL_M_PI_2 = 1.570796326794896557999; - public static final double CL_M_PI_4 = 0.785398163397448278999; - public static final double CL_M_1_PI = 0.318309886183790691216; - public static final double CL_M_2_PI = 0.636619772367581382433; - public static final double CL_M_2_SQRTPI = 1.128379167095512558561; - public static final double CL_M_SQRT2 = 1.414213562373095145475; - public static final double CL_M_SQRT1_2 = 0.707106781186547572737; - public static final float CL_M_E_F = 2.71828174591064f; - public static final float CL_M_LOG2E_F = 1.44269502162933f; - public static final float CL_M_LOG10E_F = 0.43429449200630f; - public static final float CL_M_LN2_F = 0.69314718246460f; - public static final float CL_M_LN10_F = 2.30258512496948f; - public static final float CL_M_PI_F = 3.14159274101257f; - public static final float CL_M_PI_2_F = 1.57079637050629f; - public static final float CL_M_PI_4_F = 0.78539818525314f; - public static final float CL_M_1_PI_F = 0.31830987334251f; - public static final float CL_M_2_PI_F = 0.63661974668503f; - public static final float CL_M_2_SQRTPI_F = 1.12837922573090f; - public static final float CL_M_SQRT2_F = 1.41421353816986f; - public static final float CL_M_SQRT1_2_F = 0.70710676908493f; - public static final int CL_HAS_NAMED_VECTOR_FIELDS = 1; - public static final int CL_HAS_HI_LO_VECTOR_FIELDS = 1; - public static final String CL_PROGRAM_STRING_DEBUG_INFO = "#line "; - public static final int CL_SUCCESS = 0; - public static final int CL_DEVICE_NOT_FOUND = -1; - public static final int CL_DEVICE_NOT_AVAILABLE = -2; - public static final int CL_COMPILER_NOT_AVAILABLE = -3; - public static final int CL_MEM_OBJECT_ALLOCATION_FAILURE = -4; - public static final int CL_OUT_OF_RESOURCES = -5; - public static final int CL_OUT_OF_HOST_MEMORY = -6; - public static final int CL_PROFILING_INFO_NOT_AVAILABLE = -7; - public static final int CL_MEM_COPY_OVERLAP = -8; - public static final int CL_IMAGE_FORMAT_MISMATCH = -9; - public static final int CL_IMAGE_FORMAT_NOT_SUPPORTED = -10; - public static final int CL_BUILD_PROGRAM_FAILURE = -11; - public static final int CL_MAP_FAILURE = -12; - public static final int CL_MISALIGNED_SUB_BUFFER_OFFSET = -13; - public static final int CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST = -14; - public static final int CL_COMPILE_PROGRAM_FAILURE = -15; - public static final int CL_LINKER_NOT_AVAILABLE = -16; - public static final int CL_LINK_PROGRAM_FAILURE = -17; - public static final int CL_DEVICE_PARTITION_FAILED = -18; - public static final int CL_KERNEL_ARG_INFO_NOT_AVAILABLE = -19; - public static final int CL_INVALID_VALUE = -30; - public static final int CL_INVALID_DEVICE_TYPE = -31; - public static final int CL_INVALID_PLATFORM = -32; - public static final int CL_INVALID_DEVICE = -33; - public static final int CL_INVALID_CONTEXT = -34; - public static final int CL_INVALID_QUEUE_PROPERTIES = -35; - public static final int CL_INVALID_COMMAND_QUEUE = -36; - public static final int CL_INVALID_HOST_PTR = -37; - public static final int CL_INVALID_MEM_OBJECT = -38; - public static final int CL_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39; - public static final int CL_INVALID_IMAGE_SIZE = -40; - public static final int CL_INVALID_SAMPLER = -41; - public static final int CL_INVALID_BINARY = -42; - public static final int CL_INVALID_BUILD_OPTIONS = -43; - public static final int CL_INVALID_PROGRAM = -44; - public static final int CL_INVALID_PROGRAM_EXECUTABLE = -45; - public static final int CL_INVALID_KERNEL_NAME = -46; - public static final int CL_INVALID_KERNEL_DEFINITION = -47; - public static final int CL_INVALID_KERNEL = -48; - public static final int CL_INVALID_ARG_INDEX = -49; - public static final int CL_INVALID_ARG_VALUE = -50; - public static final int CL_INVALID_ARG_SIZE = -51; - public static final int CL_INVALID_KERNEL_ARGS = -52; - public static final int CL_INVALID_WORK_DIMENSION = -53; - public static final int CL_INVALID_WORK_GROUP_SIZE = -54; - public static final int CL_INVALID_WORK_ITEM_SIZE = -55; - public static final int CL_INVALID_GLOBAL_OFFSET = -56; - public static final int CL_INVALID_EVENT_WAIT_LIST = -57; - public static final int CL_INVALID_EVENT = -58; - public static final int CL_INVALID_OPERATION = -59; - public static final int CL_INVALID_GL_OBJECT = -60; - public static final int CL_INVALID_BUFFER_SIZE = -61; - public static final int CL_INVALID_MIP_LEVEL = -62; - public static final int CL_INVALID_GLOBAL_WORK_SIZE = -63; - public static final int CL_INVALID_PROPERTY = -64; - public static final int CL_INVALID_IMAGE_DESCRIPTOR = -65; - public static final int CL_INVALID_COMPILER_OPTIONS = -66; - public static final int CL_INVALID_LINKER_OPTIONS = -67; - public static final int CL_INVALID_DEVICE_PARTITION_COUNT = -68; - public static final int CL_VERSION_1_0 = 1; - public static final int CL_VERSION_1_1 = 1; - public static final int CL_VERSION_1_2 = 1; - public static final int CL_FALSE = 0; - public static final int CL_TRUE = 1; - public static final int CL_BLOCKING = 1; - public static final int CL_NON_BLOCKING = 0; - public static final int CL_PLATFORM_PROFILE = 0x0900; - public static final int CL_PLATFORM_VERSION = 0x0901; - public static final int CL_PLATFORM_NAME = 0x0902; - public static final int CL_PLATFORM_VENDOR = 0x0903; - public static final int CL_PLATFORM_EXTENSIONS = 0x0904; - public static final int CL_DEVICE_TYPE_DEFAULT = (1 << 0); - public static final int CL_DEVICE_TYPE_CPU = (1 << 1); - public static final int CL_DEVICE_TYPE_GPU = (1 << 2); - public static final int CL_DEVICE_TYPE_ACCELERATOR = (1 << 3); - public static final int CL_DEVICE_TYPE_CUSTOM = (1 << 4); - public static final long CL_DEVICE_TYPE_ALL = 0xFFFFFFFFL; - public static final int CL_DEVICE_TYPE = 0x1000; - public static final int CL_DEVICE_VENDOR_ID = 0x1001; - public static final int CL_DEVICE_MAX_COMPUTE_UNITS = 0x1002; - public static final int CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 0x1003; - public static final int CL_DEVICE_MAX_WORK_GROUP_SIZE = 0x1004; - public static final int CL_DEVICE_MAX_WORK_ITEM_SIZES = 0x1005; - public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 0x1006; - public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 0x1007; - public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT = 0x1008; - public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 0x1009; - public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A; - public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B; - public static final int CL_DEVICE_MAX_CLOCK_FREQUENCY = 0x100C; - public static final int CL_DEVICE_ADDRESS_BITS = 0x100D; - public static final int CL_DEVICE_MAX_READ_IMAGE_ARGS = 0x100E; - public static final int CL_DEVICE_MAX_WRITE_IMAGE_ARGS = 0x100F; - public static final int CL_DEVICE_MAX_MEM_ALLOC_SIZE = 0x1010; - public static final int CL_DEVICE_IMAGE2D_MAX_WIDTH = 0x1011; - public static final int CL_DEVICE_IMAGE2D_MAX_HEIGHT = 0x1012; - public static final int CL_DEVICE_IMAGE3D_MAX_WIDTH = 0x1013; - public static final int CL_DEVICE_IMAGE3D_MAX_HEIGHT = 0x1014; - public static final int CL_DEVICE_IMAGE3D_MAX_DEPTH = 0x1015; - public static final int CL_DEVICE_IMAGE_SUPPORT = 0x1016; - public static final int CL_DEVICE_MAX_PARAMETER_SIZE = 0x1017; - public static final int CL_DEVICE_MAX_SAMPLERS = 0x1018; - public static final int CL_DEVICE_MEM_BASE_ADDR_ALIGN = 0x1019; - public static final int CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 0x101A; - public static final int CL_DEVICE_SINGLE_FP_CONFIG = 0x101B; - public static final int CL_DEVICE_GLOBAL_MEM_CACHE_TYPE = 0x101C; - public static final int CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 0x101D; - public static final int CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = 0x101E; - public static final int CL_DEVICE_GLOBAL_MEM_SIZE = 0x101F; - public static final int CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 0x1020; - public static final int CL_DEVICE_MAX_CONSTANT_ARGS = 0x1021; - public static final int CL_DEVICE_LOCAL_MEM_TYPE = 0x1022; - public static final int CL_DEVICE_LOCAL_MEM_SIZE = 0x1023; - public static final int CL_DEVICE_ERROR_CORRECTION_SUPPORT = 0x1024; - public static final int CL_DEVICE_PROFILING_TIMER_RESOLUTION = 0x1025; - public static final int CL_DEVICE_ENDIAN_LITTLE = 0x1026; - public static final int CL_DEVICE_AVAILABLE = 0x1027; - public static final int CL_DEVICE_COMPILER_AVAILABLE = 0x1028; - public static final int CL_DEVICE_EXECUTION_CAPABILITIES = 0x1029; - public static final int CL_DEVICE_QUEUE_PROPERTIES = 0x102A; - public static final int CL_DEVICE_NAME = 0x102B; - public static final int CL_DEVICE_VENDOR = 0x102C; - public static final int CL_DRIVER_VERSION = 0x102D; - public static final int CL_DEVICE_PROFILE = 0x102E; - public static final int CL_DEVICE_VERSION = 0x102F; - public static final int CL_DEVICE_EXTENSIONS = 0x1030; - public static final int CL_DEVICE_PLATFORM = 0x1031; - public static final int CL_DEVICE_DOUBLE_FP_CONFIG = 0x1032; - public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 0x1034; - public static final int CL_DEVICE_HOST_UNIFIED_MEMORY = 0x1035; - public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR = 0x1036; - public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT = 0x1037; - public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_INT = 0x1038; - public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG = 0x1039; - public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT = 0x103A; - public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE = 0x103B; - public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF = 0x103C; - public static final int CL_DEVICE_OPENCL_C_VERSION = 0x103D; - public static final int CL_DEVICE_LINKER_AVAILABLE = 0x103E; - public static final int CL_DEVICE_BUILT_IN_KERNELS = 0x103F; - public static final int CL_DEVICE_IMAGE_MAX_BUFFER_SIZE = 0x1040; - public static final int CL_DEVICE_IMAGE_MAX_ARRAY_SIZE = 0x1041; - public static final int CL_DEVICE_PARENT_DEVICE = 0x1042; - public static final int CL_DEVICE_PARTITION_MAX_SUB_DEVICES = 0x1043; - public static final int CL_DEVICE_PARTITION_PROPERTIES = 0x1044; - public static final int CL_DEVICE_PARTITION_AFFINITY_DOMAIN = 0x1045; - public static final int CL_DEVICE_PARTITION_TYPE = 0x1046; - public static final int CL_DEVICE_REFERENCE_COUNT = 0x1047; - public static final int CL_DEVICE_PREFERRED_INTEROP_USER_SYNC = 0x1048; - public static final int CL_DEVICE_PRINTF_BUFFER_SIZE = 0x1049; - public static final int CL_FP_DENORM = (1 << 0); - public static final int CL_FP_INF_NAN = (1 << 1); - public static final int CL_FP_ROUND_TO_NEAREST = (1 << 2); - public static final int CL_FP_ROUND_TO_ZERO = (1 << 3); - public static final int CL_FP_ROUND_TO_INF = (1 << 4); - public static final int CL_FP_FMA = (1 << 5); - public static final int CL_FP_SOFT_FLOAT = (1 << 6); - public static final int CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = (1 << 7); - public static final int CL_NONE = 0x0; - public static final int CL_READ_ONLY_CACHE = 0x1; - public static final int CL_READ_WRITE_CACHE = 0x2; - public static final int CL_LOCAL = 0x1; - public static final int CL_GLOBAL = 0x2; - public static final int CL_EXEC_KERNEL = (1 << 0); - public static final int CL_EXEC_NATIVE_KERNEL = (1 << 1); - public static final int CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0); - public static final int CL_QUEUE_PROFILING_ENABLE = (1 << 1); - public static final int CL_CONTEXT_REFERENCE_COUNT = 0x1080; - public static final int CL_CONTEXT_DEVICES = 0x1081; - public static final int CL_CONTEXT_PROPERTIES = 0x1082; - public static final int CL_CONTEXT_NUM_DEVICES = 0x1083; - public static final int CL_CONTEXT_PLATFORM = 0x1084; - public static final int CL_CONTEXT_INTEROP_USER_SYNC = 0x1085; - public static final int CL_DEVICE_PARTITION_EQUALLY = 0x1086; - public static final int CL_DEVICE_PARTITION_BY_COUNTS = 0x1087; - public static final int CL_DEVICE_PARTITION_BY_COUNTS_LIST_END = 0x0; - public static final int CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = 0x1088; - public static final int CL_DEVICE_AFFINITY_DOMAIN_NUMA = (1 << 0); - public static final int CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE = (1 << 1); - public static final int CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE = (1 << 2); - public static final int CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE = (1 << 3); - public static final int CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE = (1 << 4); - public static final int CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5); - public static final int CL_QUEUE_CONTEXT = 0x1090; - public static final int CL_QUEUE_DEVICE = 0x1091; - public static final int CL_QUEUE_REFERENCE_COUNT = 0x1092; - public static final int CL_QUEUE_PROPERTIES = 0x1093; - public static final int CL_MEM_READ_WRITE = (1 << 0); - public static final int CL_MEM_WRITE_ONLY = (1 << 1); - public static final int CL_MEM_READ_ONLY = (1 << 2); - public static final int CL_MEM_USE_HOST_PTR = (1 << 3); - public static final int CL_MEM_ALLOC_HOST_PTR = (1 << 4); - public static final int CL_MEM_COPY_HOST_PTR = (1 << 5); - public static final int CL_MEM_HOST_WRITE_ONLY = (1 << 7); - public static final int CL_MEM_HOST_READ_ONLY = (1 << 8); - public static final int CL_MEM_HOST_NO_ACCESS = (1 << 9); - public static final int CL_MIGRATE_MEM_OBJECT_HOST = (1 << 0); - public static final int CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED = (1 << 1); - public static final int CL_R = 0x10B0; - public static final int CL_A = 0x10B1; - public static final int CL_RG = 0x10B2; - public static final int CL_RA = 0x10B3; - public static final int CL_RGB = 0x10B4; - public static final int CL_RGBA = 0x10B5; - public static final int CL_BGRA = 0x10B6; - public static final int CL_ARGB = 0x10B7; - public static final int CL_INTENSITY = 0x10B8; - public static final int CL_LUMINANCE = 0x10B9; - public static final int CL_Rx = 0x10BA; - public static final int CL_RGx = 0x10BB; - public static final int CL_RGBx = 0x10BC; - public static final int CL_SNORM_INT8 = 0x10D0; - public static final int CL_SNORM_INT16 = 0x10D1; - public static final int CL_UNORM_INT8 = 0x10D2; - public static final int CL_UNORM_INT16 = 0x10D3; - public static final int CL_UNORM_SHORT_565 = 0x10D4; - public static final int CL_UNORM_SHORT_555 = 0x10D5; - public static final int CL_UNORM_INT_101010 = 0x10D6; - public static final int CL_SIGNED_INT8 = 0x10D7; - public static final int CL_SIGNED_INT16 = 0x10D8; - public static final int CL_SIGNED_INT32 = 0x10D9; - public static final int CL_UNSIGNED_INT8 = 0x10DA; - public static final int CL_UNSIGNED_INT16 = 0x10DB; - public static final int CL_UNSIGNED_INT32 = 0x10DC; - public static final int CL_HALF_FLOAT = 0x10DD; - public static final int CL_FLOAT = 0x10DE; - public static final int CL_MEM_OBJECT_BUFFER = 0x10F0; - public static final int CL_MEM_OBJECT_IMAGE2D = 0x10F1; - public static final int CL_MEM_OBJECT_IMAGE3D = 0x10F2; - public static final int CL_MEM_OBJECT_IMAGE2D_ARRAY = 0x10F3; - public static final int CL_MEM_OBJECT_IMAGE1D = 0x10F4; - public static final int CL_MEM_OBJECT_IMAGE1D_ARRAY = 0x10F5; - public static final int CL_MEM_OBJECT_IMAGE1D_BUFFER = 0x10F6; - public static final int CL_MEM_TYPE = 0x1100; - public static final int CL_MEM_FLAGS = 0x1101; - public static final int CL_MEM_SIZE = 0x1102; - public static final int CL_MEM_HOST_PTR = 0x1103; - public static final int CL_MEM_MAP_COUNT = 0x1104; - public static final int CL_MEM_REFERENCE_COUNT = 0x1105; - public static final int CL_MEM_CONTEXT = 0x1106; - public static final int CL_MEM_ASSOCIATED_MEMOBJECT = 0x1107; - public static final int CL_MEM_OFFSET = 0x1108; - public static final int CL_IMAGE_FORMAT = 0x1110; - public static final int CL_IMAGE_ELEMENT_SIZE = 0x1111; - public static final int CL_IMAGE_ROW_PITCH = 0x1112; - public static final int CL_IMAGE_SLICE_PITCH = 0x1113; - public static final int CL_IMAGE_WIDTH = 0x1114; - public static final int CL_IMAGE_HEIGHT = 0x1115; - public static final int CL_IMAGE_DEPTH = 0x1116; - public static final int CL_IMAGE_ARRAY_SIZE = 0x1117; - public static final int CL_IMAGE_BUFFER = 0x1118; - public static final int CL_IMAGE_NUM_MIP_LEVELS = 0x1119; - public static final int CL_IMAGE_NUM_SAMPLES = 0x111A; - public static final int CL_ADDRESS_NONE = 0x1130; - public static final int CL_ADDRESS_CLAMP_TO_EDGE = 0x1131; - public static final int CL_ADDRESS_CLAMP = 0x1132; - public static final int CL_ADDRESS_REPEAT = 0x1133; - public static final int CL_ADDRESS_MIRRORED_REPEAT = 0x1134; - public static final int CL_FILTER_NEAREST = 0x1140; - public static final int CL_FILTER_LINEAR = 0x1141; - public static final int CL_SAMPLER_REFERENCE_COUNT = 0x1150; - public static final int CL_SAMPLER_CONTEXT = 0x1151; - public static final int CL_SAMPLER_NORMALIZED_COORDS = 0x1152; - public static final int CL_SAMPLER_ADDRESSING_MODE = 0x1153; - public static final int CL_SAMPLER_FILTER_MODE = 0x1154; - public static final int CL_MAP_READ = (1 << 0); - public static final int CL_MAP_WRITE = (1 << 1); - public static final int CL_MAP_WRITE_INVALIDATE_REGION = (1 << 2); - public static final int CL_PROGRAM_REFERENCE_COUNT = 0x1160; - public static final int CL_PROGRAM_CONTEXT = 0x1161; - public static final int CL_PROGRAM_NUM_DEVICES = 0x1162; - public static final int CL_PROGRAM_DEVICES = 0x1163; - public static final int CL_PROGRAM_SOURCE = 0x1164; - public static final int CL_PROGRAM_BINARY_SIZES = 0x1165; - public static final int CL_PROGRAM_BINARIES = 0x1166; - public static final int CL_PROGRAM_NUM_KERNELS = 0x1167; - public static final int CL_PROGRAM_KERNEL_NAMES = 0x1168; - public static final int CL_PROGRAM_BUILD_STATUS = 0x1181; - public static final int CL_PROGRAM_BUILD_OPTIONS = 0x1182; - public static final int CL_PROGRAM_BUILD_LOG = 0x1183; - public static final int CL_PROGRAM_BINARY_TYPE = 0x1184; - public static final int CL_PROGRAM_BINARY_TYPE_NONE = 0x0; - public static final int CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1; - public static final int CL_PROGRAM_BINARY_TYPE_LIBRARY = 0x2; - public static final int CL_PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4; - public static final int CL_BUILD_SUCCESS = 0; - public static final int CL_BUILD_NONE = -1; - public static final int CL_BUILD_ERROR = -2; - public static final int CL_BUILD_IN_PROGRESS = -3; - public static final int CL_KERNEL_FUNCTION_NAME = 0x1190; - public static final int CL_KERNEL_NUM_ARGS = 0x1191; - public static final int CL_KERNEL_REFERENCE_COUNT = 0x1192; - public static final int CL_KERNEL_CONTEXT = 0x1193; - public static final int CL_KERNEL_PROGRAM = 0x1194; - public static final int CL_KERNEL_ATTRIBUTES = 0x1195; - public static final int CL_KERNEL_ARG_ADDRESS_QUALIFIER = 0x1196; - public static final int CL_KERNEL_ARG_ACCESS_QUALIFIER = 0x1197; - public static final int CL_KERNEL_ARG_TYPE_NAME = 0x1198; - public static final int CL_KERNEL_ARG_TYPE_QUALIFIER = 0x1199; - public static final int CL_KERNEL_ARG_NAME = 0x119A; - public static final int CL_KERNEL_ARG_ADDRESS_GLOBAL = 0x119B; - public static final int CL_KERNEL_ARG_ADDRESS_LOCAL = 0x119C; - public static final int CL_KERNEL_ARG_ADDRESS_CONSTANT = 0x119D; - public static final int CL_KERNEL_ARG_ADDRESS_PRIVATE = 0x119E; - public static final int CL_KERNEL_ARG_ACCESS_READ_ONLY = 0x11A0; - public static final int CL_KERNEL_ARG_ACCESS_WRITE_ONLY = 0x11A1; - public static final int CL_KERNEL_ARG_ACCESS_READ_WRITE = 0x11A2; - public static final int CL_KERNEL_ARG_ACCESS_NONE = 0x11A3; - public static final int CL_KERNEL_ARG_TYPE_NONE = 0; - public static final int CL_KERNEL_ARG_TYPE_CONST = (1 << 0); - public static final int CL_KERNEL_ARG_TYPE_RESTRICT = (1 << 1); - public static final int CL_KERNEL_ARG_TYPE_VOLATILE = (1 << 2); - public static final int CL_KERNEL_WORK_GROUP_SIZE = 0x11B0; - public static final int CL_KERNEL_COMPILE_WORK_GROUP_SIZE = 0x11B1; - public static final int CL_KERNEL_LOCAL_MEM_SIZE = 0x11B2; - public static final int CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3; - public static final int CL_KERNEL_PRIVATE_MEM_SIZE = 0x11B4; - public static final int CL_KERNEL_GLOBAL_WORK_SIZE = 0x11B5; - public static final int CL_EVENT_COMMAND_QUEUE = 0x11D0; - public static final int CL_EVENT_COMMAND_TYPE = 0x11D1; - public static final int CL_EVENT_REFERENCE_COUNT = 0x11D2; - public static final int CL_EVENT_COMMAND_EXECUTION_STATUS = 0x11D3; - public static final int CL_EVENT_CONTEXT = 0x11D4; - public static final int CL_COMMAND_NDRANGE_KERNEL = 0x11F0; - public static final int CL_COMMAND_TASK = 0x11F1; - public static final int CL_COMMAND_NATIVE_KERNEL = 0x11F2; - public static final int CL_COMMAND_READ_BUFFER = 0x11F3; - public static final int CL_COMMAND_WRITE_BUFFER = 0x11F4; - public static final int CL_COMMAND_COPY_BUFFER = 0x11F5; - public static final int CL_COMMAND_READ_IMAGE = 0x11F6; - public static final int CL_COMMAND_WRITE_IMAGE = 0x11F7; - public static final int CL_COMMAND_COPY_IMAGE = 0x11F8; - public static final int CL_COMMAND_COPY_IMAGE_TO_BUFFER = 0x11F9; - public static final int CL_COMMAND_COPY_BUFFER_TO_IMAGE = 0x11FA; - public static final int CL_COMMAND_MAP_BUFFER = 0x11FB; - public static final int CL_COMMAND_MAP_IMAGE = 0x11FC; - public static final int CL_COMMAND_UNMAP_MEM_OBJECT = 0x11FD; - public static final int CL_COMMAND_MARKER = 0x11FE; - public static final int CL_COMMAND_ACQUIRE_GL_OBJECTS = 0x11FF; - public static final int CL_COMMAND_RELEASE_GL_OBJECTS = 0x1200; - public static final int CL_COMMAND_READ_BUFFER_RECT = 0x1201; - public static final int CL_COMMAND_WRITE_BUFFER_RECT = 0x1202; - public static final int CL_COMMAND_COPY_BUFFER_RECT = 0x1203; - public static final int CL_COMMAND_USER = 0x1204; - public static final int CL_COMMAND_BARRIER = 0x1205; - public static final int CL_COMMAND_MIGRATE_MEM_OBJECTS = 0x1206; - public static final int CL_COMMAND_FILL_BUFFER = 0x1207; - public static final int CL_COMMAND_FILL_IMAGE = 0x1208; - public static final int CL_COMPLETE = 0x0; - public static final int CL_RUNNING = 0x1; - public static final int CL_SUBMITTED = 0x2; - public static final int CL_QUEUED = 0x3; - public static final int CL_BUFFER_CREATE_TYPE_REGION = 0x1220; - public static final int CL_PROFILING_COMMAND_QUEUED = 0x1280; - public static final int CL_PROFILING_COMMAND_SUBMIT = 0x1281; - public static final int CL_PROFILING_COMMAND_START = 0x1282; - public static final int CL_PROFILING_COMMAND_END = 0x1283; - public static final int CL_GL_OBJECT_BUFFER = 0x2000; - public static final int CL_GL_OBJECT_TEXTURE2D = 0x2001; - public static final int CL_GL_OBJECT_TEXTURE3D = 0x2002; - public static final int CL_GL_OBJECT_RENDERBUFFER = 0x2003; - public static final int CL_GL_OBJECT_TEXTURE2D_ARRAY = 0x200E; - public static final int CL_GL_OBJECT_TEXTURE1D = 0x200F; - public static final int CL_GL_OBJECT_TEXTURE1D_ARRAY = 0x2010; - public static final int CL_GL_OBJECT_TEXTURE_BUFFER = 0x2011; - public static final int CL_GL_TEXTURE_TARGET = 0x2004; - public static final int CL_GL_MIPMAP_LEVEL = 0x2005; - public static final int cl_khr_gl_sharing = 1; - public static final int CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000; - public static final int CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006; - public static final int CL_DEVICES_FOR_GL_CONTEXT_KHR = 0x2007; - public static final int CL_GL_CONTEXT_KHR = 0x2008; - public static final int CL_EGL_DISPLAY_KHR = 0x2009; - public static final int CL_GLX_DISPLAY_KHR = 0x200A; - public static final int CL_WGL_HDC_KHR = 0x200B; - public static final int CL_CGL_SHAREGROUP_KHR = 0x200C; - public static final int CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 0x200D; - public static final int CL_DEVICE_HALF_FP_CONFIG = 0x1033; - public static final int cl_APPLE_SetMemObjectDestructor = 1; - public static final int cl_APPLE_ContextLoggingFunctions = 1; - public static final int cl_khr_icd = 1; - public static final int CL_PLATFORM_ICD_SUFFIX_KHR = 0x0920; - public static final int CL_PLATFORM_NOT_FOUND_KHR = -1001; - public static final int CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 0x4000; - public static final int CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV = 0x4001; - public static final int CL_DEVICE_REGISTERS_PER_BLOCK_NV = 0x4002; - public static final int CL_DEVICE_WARP_SIZE_NV = 0x4003; - public static final int CL_DEVICE_GPU_OVERLAP_NV = 0x4004; - public static final int CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV = 0x4005; - public static final int CL_DEVICE_INTEGRATED_MEMORY_NV = 0x4006; - public static final int CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036; - public static final int cl_ext_device_fission = 1; - public static final int CL_DEVICE_PARTITION_EQUALLY_EXT = 0x4050; - public static final int CL_DEVICE_PARTITION_BY_COUNTS_EXT = 0x4051; - public static final int CL_DEVICE_PARTITION_BY_NAMES_EXT = 0x4052; - public static final int CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053; - public static final int CL_DEVICE_PARENT_DEVICE_EXT = 0x4054; - public static final int CL_DEVICE_PARTITION_TYPES_EXT = 0x4055; - public static final int CL_DEVICE_AFFINITY_DOMAINS_EXT = 0x4056; - public static final int CL_DEVICE_REFERENCE_COUNT_EXT = 0x4057; - public static final int CL_DEVICE_PARTITION_STYLE_EXT = 0x4058; - public static final int CL_DEVICE_PARTITION_FAILED_EXT = -1057; - public static final int CL_INVALID_PARTITION_COUNT_EXT = -1058; - public static final int CL_INVALID_PARTITION_NAME_EXT = -1059; - public static final int CL_AFFINITY_DOMAIN_L1_CACHE_EXT = 0x1; - public static final int CL_AFFINITY_DOMAIN_L2_CACHE_EXT = 0x2; - public static final int CL_AFFINITY_DOMAIN_L3_CACHE_EXT = 0x3; - public static final int CL_AFFINITY_DOMAIN_L4_CACHE_EXT = 0x4; - public static final int CL_AFFINITY_DOMAIN_NUMA_EXT = 0x10; - public static final int CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 0x100; - public static final int CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE = 0x10000000; - public static final int CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE = 0x10000002; - public static final int CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE = 0x10000003; - public static final int CL_INVALID_GL_CONTEXT_APPLE = -1000; - public static abstract class clGetGLContextInfoKHR_fn extends Callback { - public int apply(Pointer properties, int param_name, @Ptr long param_value_size, Pointer param_value, Pointer param_value_size_ret) { - return apply(Pointer.getPeer(properties), param_name, param_value_size, Pointer.getPeer(param_value), Pointer.getPeer(param_value_size_ret)); - } - public int apply(@Ptr long properties, int param_name, @Ptr long param_value_size, @Ptr long param_value, @Ptr long param_value_size_ret) { - return apply((Pointer)Pointer.pointerToAddress(properties, SizeT.class), param_name, param_value_size, Pointer.pointerToAddress(param_value), (Pointer)Pointer.pointerToAddress(param_value_size_ret, SizeT.class)); - } - }; - public static abstract class clIcdGetPlatformIDsKHR_fn extends Callback { - public int apply(int cl_uint1, Pointer cl_platform_idPtr1, Pointer cl_uintPtr1) { - return apply(cl_uint1, Pointer.getPeer(cl_platform_idPtr1), Pointer.getPeer(cl_uintPtr1)); - } - public int apply(int cl_uint1, @Ptr long cl_platform_idPtr1, @Ptr long cl_uintPtr1) { - return apply(cl_uint1, (Pointer)Pointer.pointerToAddress(cl_platform_idPtr1, IOpenCLLibrary.cl_platform_id.class), (Pointer)Pointer.pointerToAddress(cl_uintPtr1, Integer.class)); - } - }; - public static abstract class clReleaseDeviceEXT_fn extends Callback { - public int apply(IOpenCLLibrary.cl_device_id cl_device_id1) { - return apply(Pointer.getPeer(cl_device_id1)); - } - public int apply(@Ptr long cl_device_id1) { - return apply(new IOpenCLLibrary.cl_device_id(cl_device_id1)); - } - }; - public static abstract class clRetainDeviceEXT_fn extends Callback { - public int apply(IOpenCLLibrary.cl_device_id cl_device_id1) { - return apply(Pointer.getPeer(cl_device_id1)); - } - public int apply(@Ptr long cl_device_id1) { - return apply(new IOpenCLLibrary.cl_device_id(cl_device_id1)); - } - }; - public static abstract class clCreateSubDevicesEXT_fn extends Callback { - public int apply(IOpenCLLibrary.cl_device_id cl_device_id1, Pointer cl_device_partition_property_extPtr1, int cl_uint1, Pointer cl_device_idPtr1, Pointer cl_uintPtr1) { - return apply(Pointer.getPeer(cl_device_id1), Pointer.getPeer(cl_device_partition_property_extPtr1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(cl_uintPtr1)); - } - public int apply(@Ptr long cl_device_id1, @Ptr long cl_device_partition_property_extPtr1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long cl_uintPtr1) { - return apply(new IOpenCLLibrary.cl_device_id(cl_device_id1), (Pointer)Pointer.pointerToAddress(cl_device_partition_property_extPtr1, Long.class), cl_uint1, (Pointer)Pointer.pointerToAddress(cl_device_idPtr1, IOpenCLLibrary.cl_device_id.class), (Pointer)Pointer.pointerToAddress(cl_uintPtr1, Integer.class)); - } - }; - public static abstract class clCreateContext_arg1_callback extends Callback { - public void apply(Pointer charPtr1, Pointer voidPtr1, @Ptr long size_t1, Pointer voidPtr2) { - apply(Pointer.getPeer(charPtr1), Pointer.getPeer(voidPtr1), size_t1, Pointer.getPeer(voidPtr2)); - } - public void apply(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2) { - apply((Pointer)Pointer.pointerToAddress(charPtr1, Byte.class), Pointer.pointerToAddress(voidPtr1), size_t1, Pointer.pointerToAddress(voidPtr2)); - } - }; - public static abstract class clCreateContextFromType_arg1_callback extends Callback { - public void apply(Pointer charPtr1, Pointer voidPtr1, @Ptr long size_t1, Pointer voidPtr2) { - apply(Pointer.getPeer(charPtr1), Pointer.getPeer(voidPtr1), size_t1, Pointer.getPeer(voidPtr2)); - } - public void apply(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2) { - apply((Pointer)Pointer.pointerToAddress(charPtr1, Byte.class), Pointer.pointerToAddress(voidPtr1), size_t1, Pointer.pointerToAddress(voidPtr2)); - } - }; - public static abstract class clSetMemObjectDestructorCallback_arg1_callback extends Callback { - /** @param cl_mem1 user_data */ - public void apply(IOpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1) { - apply(Pointer.getPeer(cl_mem1), Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long cl_mem1, @Ptr long voidPtr1) { - apply(new IOpenCLLibrary.cl_mem(cl_mem1), Pointer.pointerToAddress(voidPtr1)); - } - }; - public static abstract class clBuildProgram_arg1_callback extends Callback { - /** @param cl_program1 user_data */ - public void apply(IOpenCLLibrary.cl_program cl_program1, Pointer voidPtr1) { - apply(Pointer.getPeer(cl_program1), Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long cl_program1, @Ptr long voidPtr1) { - apply(new IOpenCLLibrary.cl_program(cl_program1), Pointer.pointerToAddress(voidPtr1)); - } - }; - public static abstract class clCompileProgram_arg1_callback extends Callback { - /** @param cl_program1 user_data */ - public void apply(IOpenCLLibrary.cl_program cl_program1, Pointer voidPtr1) { - apply(Pointer.getPeer(cl_program1), Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long cl_program1, @Ptr long voidPtr1) { - apply(new IOpenCLLibrary.cl_program(cl_program1), Pointer.pointerToAddress(voidPtr1)); - } - }; - public static abstract class clLinkProgram_arg1_callback extends Callback { - /** @param cl_program1 user_data */ - public void apply(IOpenCLLibrary.cl_program cl_program1, Pointer voidPtr1) { - apply(Pointer.getPeer(cl_program1), Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long cl_program1, @Ptr long voidPtr1) { - apply(new IOpenCLLibrary.cl_program(cl_program1), Pointer.pointerToAddress(voidPtr1)); - } - }; - public static abstract class clSetEventCallback_arg1_callback extends Callback { - public void apply(IOpenCLLibrary.cl_event cl_event1, int cl_int1, Pointer voidPtr1) { - apply(Pointer.getPeer(cl_event1), cl_int1, Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long cl_event1, int cl_int1, @Ptr long voidPtr1) { - apply(new IOpenCLLibrary.cl_event(cl_event1), cl_int1, Pointer.pointerToAddress(voidPtr1)); - } - }; - public static abstract class clEnqueueNativeKernel_arg1_callback extends Callback { - public void apply(Pointer voidPtr1) { - apply(Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long voidPtr1) { - apply(Pointer.pointerToAddress(voidPtr1)); - } - }; - public static abstract class clSetPrintfCallback_arg1_callback extends Callback { - public void apply(IOpenCLLibrary.cl_context cl_context1, int cl_uint1, Pointer charPtr1, Pointer voidPtr1) { - apply(Pointer.getPeer(cl_context1), cl_uint1, Pointer.getPeer(charPtr1), Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long cl_context1, int cl_uint1, @Ptr long charPtr1, @Ptr long voidPtr1) { - apply(new IOpenCLLibrary.cl_context(cl_context1), cl_uint1, (Pointer)Pointer.pointerToAddress(charPtr1, Byte.class), Pointer.pointerToAddress(voidPtr1)); - } - }; - public static abstract class clSetMemObjectDestructorAPPLE_arg1_callback extends Callback { - /** @param cl_mem1 user_data */ - public void apply(IOpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1) { - apply(Pointer.getPeer(cl_mem1), Pointer.getPeer(voidPtr1)); - } - public void apply(@Ptr long cl_mem1, @Ptr long voidPtr1) { - apply(new IOpenCLLibrary.cl_mem(cl_mem1), Pointer.pointerToAddress(voidPtr1)); - } - }; - int clGetPlatformIDs(int cl_uint1, @Ptr long cl_platform_idPtr1, @Ptr long cl_uintPtr1); - int clGetPlatformInfo(@Ptr long cl_platform_id1, int cl_platform_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - int clGetDeviceIDs(@Ptr long cl_platform_id1, long cl_device_type1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long cl_uintPtr1); - int clGetDeviceInfo(@Ptr long cl_device_id1, int cl_device_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Optional - int clCreateSubDevices(@Ptr long cl_device_id1, @Ptr long cl_device_partition_propertyPtr1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long cl_uintPtr1); - @Optional - int clRetainDevice(@Ptr long cl_device_id1); - @Optional - int clReleaseDevice(@Ptr long cl_device_id1); - @Ptr - long clCreateContext(@Ptr long cl_context_propertiesPtr1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - @Ptr - long clCreateContextFromType(@Ptr long cl_context_propertiesPtr1, long cl_device_type1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - int clRetainContext(@Ptr long cl_context1); - int clReleaseContext(@Ptr long cl_context1); - int clGetContextInfo(@Ptr long cl_context1, int cl_context_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Ptr - long clCreateCommandQueue(@Ptr long cl_context1, @Ptr long cl_device_id1, long cl_command_queue_properties1, @Ptr long cl_intPtr1); - int clRetainCommandQueue(@Ptr long cl_command_queue1); - int clReleaseCommandQueue(@Ptr long cl_command_queue1); - int clGetCommandQueueInfo(@Ptr long cl_command_queue1, int cl_command_queue_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Ptr - long clCreateBuffer(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - @Ptr - @Optional - long clCreateSubBuffer(@Ptr long cl_mem1, long cl_mem_flags1, int cl_buffer_create_type1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - @Ptr - @Optional - long clCreateImage(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long cl_image_formatPtr1, @Ptr long cl_image_descPtr1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - int clRetainMemObject(@Ptr long cl_mem1); - int clReleaseMemObject(@Ptr long cl_mem1); - int clGetSupportedImageFormats(@Ptr long cl_context1, long cl_mem_flags1, int cl_mem_object_type1, int cl_uint1, @Ptr long cl_image_formatPtr1, @Ptr long cl_uintPtr1); - int clGetMemObjectInfo(@Ptr long cl_mem1, int cl_mem_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - int clGetImageInfo(@Ptr long cl_mem1, int cl_image_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Optional - int clSetMemObjectDestructorCallback(@Ptr long cl_mem1, @Ptr long arg1, @Ptr long voidPtr1); - @Ptr - long clCreateSampler(@Ptr long cl_context1, int cl_bool1, int cl_addressing_mode1, int cl_filter_mode1, @Ptr long cl_intPtr1); - int clRetainSampler(@Ptr long cl_sampler1); - int clReleaseSampler(@Ptr long cl_sampler1); - int clGetSamplerInfo(@Ptr long cl_sampler1, int cl_sampler_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Ptr - long clCreateProgramWithSource(@Ptr long cl_context1, int cl_uint1, @Ptr long charPtrPtr1, @Ptr long size_tPtr1, @Ptr long cl_intPtr1); - @Ptr - long clCreateProgramWithBinary(@Ptr long cl_context1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long size_tPtr1, @Ptr long charPtrPtr1, @Ptr long cl_intPtr1, @Ptr long cl_intPtr2); - @Ptr - @Optional - long clCreateProgramWithBuiltInKernels(@Ptr long cl_context1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, @Ptr long cl_intPtr1); - int clRetainProgram(@Ptr long cl_program1); - int clReleaseProgram(@Ptr long cl_program1); - int clBuildProgram(@Ptr long cl_program1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, @Ptr long arg1, @Ptr long voidPtr1); - @Optional - int clCompileProgram(@Ptr long cl_program1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, int cl_uint2, @Ptr long cl_programPtr1, @Ptr long charPtrPtr1, @Ptr long arg1, @Ptr long voidPtr1); - @Ptr - @Optional - long clLinkProgram(@Ptr long cl_context1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, int cl_uint2, @Ptr long cl_programPtr1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - @Optional - int clUnloadPlatformCompiler(@Ptr long cl_platform_id1); - int clGetProgramInfo(@Ptr long cl_program1, int cl_program_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - int clGetProgramBuildInfo(@Ptr long cl_program1, @Ptr long cl_device_id1, int cl_program_build_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Ptr - long clCreateKernel(@Ptr long cl_program1, @Ptr long charPtr1, @Ptr long cl_intPtr1); - int clCreateKernelsInProgram(@Ptr long cl_program1, int cl_uint1, @Ptr long cl_kernelPtr1, @Ptr long cl_uintPtr1); - int clRetainKernel(@Ptr long cl_kernel1); - int clReleaseKernel(@Ptr long cl_kernel1); - int clSetKernelArg(@Ptr long cl_kernel1, int cl_uint1, @Ptr long size_t1, @Ptr long voidPtr1); - int clGetKernelInfo(@Ptr long cl_kernel1, int cl_kernel_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Optional - int clGetKernelArgInfo(@Ptr long cl_kernel1, int cl_uint1, int cl_kernel_arg_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - int clGetKernelWorkGroupInfo(@Ptr long cl_kernel1, @Ptr long cl_device_id1, int cl_kernel_work_group_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - int clWaitForEvents(int cl_uint1, @Ptr long cl_eventPtr1); - int clGetEventInfo(@Ptr long cl_event1, int cl_event_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Ptr - @Optional - long clCreateUserEvent(@Ptr long cl_context1, @Ptr long cl_intPtr1); - int clRetainEvent(@Ptr long cl_event1); - int clReleaseEvent(@Ptr long cl_event1); - @Optional - int clSetUserEventStatus(@Ptr long cl_event1, int cl_int1); - @Optional - int clSetEventCallback(@Ptr long cl_event1, int cl_int1, @Ptr long arg1, @Ptr long voidPtr1); - int clGetEventProfilingInfo(@Ptr long cl_event1, int cl_profiling_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - int clFlush(@Ptr long cl_command_queue1); - int clFinish(@Ptr long cl_command_queue1); - int clEnqueueReadBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueReadBufferRect(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueWriteBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueWriteBufferRect(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueFillBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueCopyBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueCopyBufferRect(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueReadImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueWriteImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueFillImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long voidPtr1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueCopyImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueCopyImageToBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_t1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueCopyBufferToImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_t1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Ptr - long clEnqueueMapBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, long cl_map_flags1, @Ptr long size_t1, @Ptr long size_t2, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2, @Ptr long cl_intPtr1); - @Ptr - long clEnqueueMapImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, long cl_map_flags1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_tPtr4, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2, @Ptr long cl_intPtr1); - int clEnqueueUnmapMemObject(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueMigrateMemObjects(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_memPtr1, long cl_mem_migration_flags1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueNDRangeKernel(@Ptr long cl_command_queue1, @Ptr long cl_kernel1, int cl_uint1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueTask(@Ptr long cl_command_queue1, @Ptr long cl_kernel1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueNativeKernel(@Ptr long cl_command_queue1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long size_t1, int cl_uint1, @Ptr long cl_memPtr1, @Ptr long voidPtrPtr1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueMarkerWithWaitList(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clEnqueueBarrierWithWaitList(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Optional - int clSetPrintfCallback(@Ptr long cl_context1, @Ptr long arg1, @Ptr long voidPtr1); - @Ptr - @Optional - long clGetExtensionFunctionAddressForPlatform(@Ptr long cl_platform_id1, @Ptr long charPtr1); - int clSetCommandQueueProperty(@Ptr long cl_command_queue1, long cl_command_queue_properties1, int cl_bool1, @Ptr long cl_command_queue_propertiesPtr1); - @Ptr - long clCreateImage2D(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long cl_image_formatPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - @Ptr - long clCreateImage3D(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long cl_image_formatPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, @Ptr long size_t5, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - int clEnqueueMarker(@Ptr long cl_command_queue1, @Ptr long cl_eventPtr1); - int clEnqueueWaitForEvents(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_eventPtr1); - int clEnqueueBarrier(@Ptr long cl_command_queue1); - /** Original signature : cl_int clUnloadCompiler() */ - int clUnloadCompiler(); - @Ptr - long clGetExtensionFunctionAddress(@Ptr long charPtr1); - @Ptr - long clCreateFromGLBuffer(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLuint1, @Ptr long intPtr1); - @Ptr - @Optional - long clCreateFromGLTexture(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, @Ptr long cl_intPtr1); - @Ptr - long clCreateFromGLRenderbuffer(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLuint1, @Ptr long cl_intPtr1); - int clGetGLObjectInfo(@Ptr long cl_mem1, @Ptr long cl_gl_object_typePtr1, @Ptr long cl_GLuintPtr1); - int clGetGLTextureInfo(@Ptr long cl_mem1, int cl_gl_texture_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - int clEnqueueAcquireGLObjects(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_memPtr1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - int clEnqueueReleaseGLObjects(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_memPtr1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - @Ptr - long clCreateFromGLTexture2D(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, @Ptr long cl_intPtr1); - @Ptr - long clCreateFromGLTexture3D(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, @Ptr long cl_intPtr1); - @Optional - int clGetGLContextInfoKHR(@Ptr long cl_context_propertiesPtr1, int cl_gl_context_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - @Ptr - @Optional - long clCreateEventFromGLsyncKHR(@Ptr long cl_context1, @Ptr long cl_GLsync1, @Ptr long cl_intPtr1); - @Optional - int clSetMemObjectDestructorAPPLE(@Ptr long cl_mem1, @Ptr long arg1, @Ptr long voidPtr1); - @Optional - void clLogMessagesToSystemLogAPPLE(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2); - @Optional - void clLogMessagesToStdoutAPPLE(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2); - @Optional - void clLogMessagesToStderrAPPLE(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2); - @Optional - int clIcdGetPlatformIDsKHR(int cl_uint1, @Ptr long cl_platform_idPtr1, @Ptr long cl_uintPtr1); - @Optional - int clReleaseDeviceEXT(@Ptr long cl_device_id1); - @Optional - int clRetainDeviceEXT(@Ptr long cl_device_id1); - @Optional - int clCreateSubDevicesEXT(@Ptr long cl_device_id1, @Ptr long cl_device_partition_property_extPtr1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long cl_uintPtr1); - @Optional - int clGetGLContextInfoAPPLE(@Ptr long cl_context1, @Ptr long voidPtr1, int cl_gl_platform_info1, @Ptr long size_t1, @Ptr long voidPtr2, @Ptr long size_tPtr1); - public static class cl_mem extends TypedPointer { - public cl_mem(long address) { - super(address); - } - public cl_mem(Pointer address) { - super(address); - } - }; - public static class cl_kernel extends TypedPointer { - public cl_kernel(long address) { - super(address); - } - public cl_kernel(Pointer address) { - super(address); - } - }; - public static class cl_context extends TypedPointer { - public cl_context(long address) { - super(address); - } - public cl_context(Pointer address) { - super(address); - } - }; - public static class cl_GLsync extends TypedPointer { - public cl_GLsync(long address) { - super(address); - } - public cl_GLsync(Pointer address) { - super(address); - } - }; - public static class cl_platform_id extends TypedPointer { - public cl_platform_id(long address) { - super(address); - } - public cl_platform_id(Pointer address) { - super(address); - } - }; - public static class cl_program extends TypedPointer { - public cl_program(long address) { - super(address); - } - public cl_program(Pointer address) { - super(address); - } - }; - public static class cl_event extends TypedPointer { - public cl_event(long address) { - super(address); - } - public cl_event(Pointer address) { - super(address); - } - }; - public static class cl_device_id extends TypedPointer { - public cl_device_id(long address) { - super(address); - } - public cl_device_id(Pointer address) { - super(address); - } - }; - public static class cl_sampler extends TypedPointer { - public cl_sampler(long address) { - super(address); - } - public cl_sampler(Pointer address) { - super(address); - } - }; - public static class cl_command_queue extends TypedPointer { - public cl_command_queue(long address) { - super(address); - } - public cl_command_queue(Pointer address) { - super(address); - } - }; - /** Undefined type */ - public static interface _cl_mem { - - }; - /** Undefined type */ - public static interface _cl_device_id { - - }; - /** Undefined type */ - public static interface _cl_context { - - }; - /** Undefined type */ - public static interface _cl_platform_id { - - }; - /** Undefined type */ - public static interface _cl_command_queue { - - }; - /** Undefined type */ - public static interface _cl_kernel { - - }; - /** Undefined type */ - public static interface _cl_sampler { - - }; - /** Undefined type */ - public static interface __GLsync { - - }; - /** Undefined type */ - public static interface _cl_event { - - }; - /** Undefined type */ - public static interface _cl_program { - - }; -} diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenCLLibrary.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenCLLibrary.java index 3ae4f4ef..16cbeaa6 100644 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenCLLibrary.java +++ b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenCLLibrary.java @@ -1,736 +1,1496 @@ package com.nativelibs4java.opencl.library; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_GLsync; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_command_queue; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_context; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_device_id; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_event; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_kernel; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_platform_id; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_program; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_sampler; -import org.bridj.CRuntime; -import org.bridj.Pointer; -import org.bridj.SizeT; -import org.bridj.ann.Library; -import org.bridj.ann.Optional; -import org.bridj.ann.Ptr; -import org.bridj.ann.Runtime; +import com.ochafik.lang.jnaerator.runtime.LibraryExtractor; +import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.NativeSizeByReference; +import com.ochafik.lang.jnaerator.runtime.globals.GlobalCallback; +import com.sun.jna.Callback; +import com.sun.jna.Library; +import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.Native; +import com.sun.jna.NativeLibrary; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.ptr.LongByReference; +import com.sun.jna.ptr.PointerByReference; +import java.nio.IntBuffer; +import java.nio.LongBuffer; /** - * Wrapper for library OpenCL
    + * JNA Wrapper for library OpenCL
    * This file was autogenerated by JNAerator,
    * a tool written by Olivier Chafik that uses a few opensource projects..
    - * For help, please visit NativeLibs4Java or BridJ . + * For help, please visit NativeLibs4Java , Rococoa, or JNA. */ -@Library("OpenCL") -@Runtime(CRuntime.class) -public class OpenCLLibrary implements IOpenCLLibrary { +public interface OpenCLLibrary extends Library { + public static final int CL_DEVICE_TYPE_CPU = (1 << 1); + public static final int CL_SCHAR_MAX = 127; + public static final int CL_FP_INF_NAN = (1 << 1); + public static final int CL_GLX_DISPLAY_KHR = 8202; + public static final int CL_GLOBAL = 2; + public static final int CL_DEVICE_GLOBAL_MEM_SIZE = 4127; + public static final int CL_KERNEL_LOCAL_MEM_SIZE = 4530; + public static final int CL_MEM_READ_ONLY = (1 << 2); + public static final int CL_PROGRAM_REFERENCE_COUNT = 4448; + public static final double CL_M_PI_2 = 1.5707963267948966; + public static final float CL_M_LOG2E_F = 1.442695F; + public static final double CL_M_PI_4 = 0.7853981633974483; + public static final int CL_FLT_MIN_EXP = -125; + public static final int CL_DEVICE_VENDOR_ID = 4097; + public static final int CL_FLOAT = 4318; + public static final int CL_NONE = 0; + public static final int CL_BGRA = 4278; + public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR = 4150; + public static final int CL_UNSIGNED_INT32 = 4316; + public static final int CL_DEVICE_MAX_COMPUTE_UNITS = 4098; + public static final int CL_RGBx = 4284; + public static final int CL_DEVICE_REGISTERS_PER_BLOCK_NV = 16386; + public static final int CL_PLATFORM_EXTENSIONS = 2308; + public static final int CL_DEVICE_TYPE_GPU = (1 << 2); + public static final float CL_M_PI_F = 3.1415927F; + public static final int CL_READ_ONLY_CACHE = 1; + public static final int CL_IMAGE_FORMAT_MISMATCH = -9; + public static final int CL_OUT_OF_RESOURCES = -5; + public static final int CL_INVALID_IMAGE_SIZE = -40; + public static final int CL_INVALID_EVENT_WAIT_LIST = -57; + public static final int cl_APPLE_SetMemObjectDestructor = 1; + public static final int CL_UNSIGNED_INT16 = 4315; + public static final int CL_COMMAND_NDRANGE_KERNEL = 4592; + public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 4106; + public static final int CL_DEVICE_MAX_CONSTANT_ARGS = 4129; + public static final int CL_CHAR_BIT = 8; + public static final int CL_DEVICE_TYPE_ALL = -1; + public static final int CL_QUEUED = 3; + public static final double CL_M_LN10 = 2.302585092994046; + public static final int CL_INVALID_MIP_LEVEL = -62; + public static final int CL_ADDRESS_NONE = 4400; + public static final int CL_RGBA = 4277; + public static final int CL_CONTEXT_DEVICES = 4225; + public static final int CL_INVALID_PARTITION_NAME_EXT = -1059; + public static final int CL_INVALID_WORK_ITEM_SIZE = -55; + public static final int CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV = 16389; + public static final int CL_INVALID_WORK_GROUP_SIZE = -54; + public static final int CL_DEVICE_ERROR_CORRECTION_SUPPORT = 4132; + public static final int CL_DBL_RADIX = 2; + public static final int CL_DEVICE_LOCAL_MEM_SIZE = 4131; + public static final int CL_COMMAND_RELEASE_GL_OBJECTS = 4608; + public static final int CL_ADDRESS_MIRRORED_REPEAT = 4404; + public static final int CL_INVALID_KERNEL_ARGS = -52; + public static final int CL_CONTEXT_PLATFORM = 4228; + public static final int CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE = 0x10000000; + public static final int CL_HAS_HI_LO_VECTOR_FIELDS = 1; + public static final int CL_MEM_MAP_COUNT = 4356; + public static final int CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 256; + public static final int CL_PROFILING_COMMAND_SUBMIT = 4737; + public static final int CL_DBL_MIN_EXP = -1021; + public static final double CL_M_SQRT2 = 1.4142135623730951; + public static final int CL_COMMAND_ACQUIRE_GL_OBJECTS = 4607; + public static final int CL_UINT_MAX = -1; + public static final float CL_M_SQRT1_2_F = 0.70710677F; + public static final double CL_M_2_SQRTPI = 1.1283791670955126; + public static final int CL_COMMAND_NATIVE_KERNEL = 4594; + public static final int CL_IMAGE_WIDTH = 4372; + public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 4105; + public static final int CL_INVALID_DEVICE_TYPE = -31; + public static final int CL_COMMAND_COPY_IMAGE_TO_BUFFER = 4601; + public static final int CL_GL_TEXTURE_TARGET = 8196; + public static final int CL_QUEUE_PROPERTIES = 4243; + public static final float CL_M_2_PI_F = 0.63661975F; + public static final int CL_COMMAND_WRITE_BUFFER_RECT = 4610; + public static final int CL_MEM_ASSOCIATED_MEMOBJECT = 4359; + public static final int CL_INVALID_ARG_VALUE = -50; + public static final int CL_CONTEXT_REFERENCE_COUNT = 4224; + public static final int CL_DEVICE_TYPE = 4096; + public static final int CL_QUEUE_CONTEXT = 4240; + public static final int CL_DEVICE_SINGLE_FP_CONFIG = 4123; + public static final int CL_SNORM_INT16 = 4305; + public static final int CL_ARGB = 4279; + public static final int CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV = 16385; + public static final int CL_EVENT_COMMAND_QUEUE = 4560; + public static final int CL_SUCCESS = 0; + public static final int CL_PROFILING_INFO_NOT_AVAILABLE = -7; + public static final int CL_INVALID_BUFFER_SIZE = -61; + public static final int CL_INVALID_ARG_SIZE = -51; + public static final int CL_QUEUE_PROFILING_ENABLE = (1 << 1); + public static final int CL_KERNEL_REFERENCE_COUNT = 4498; + public static final int CL_MEM_ALLOC_HOST_PTR = (1 << 4); + public static final int CL_DEVICE_IMAGE2D_MAX_WIDTH = 4113; + public static final int CL_BUILD_PROGRAM_FAILURE = -11; + public static final int CL_COMMAND_COPY_BUFFER = 4597; + public static final int CL_KERNEL_NUM_ARGS = 4497; + public static final int CL_BUFFER_CREATE_TYPE_REGION = 4640; + public static final int CL_UNORM_SHORT_555 = 4309; + public static final int CL_PROGRAM_SOURCE = 4452; + public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 4102; + public static final int CL_DEVICE_COMPILER_AVAILABLE = 4136; + public static final int CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 4125; + public static final int CL_FP_ROUND_TO_INF = (1 << 4); + public static final int CL_IMAGE_ROW_PITCH = 4370; + public static final int CL_INVALID_ARG_INDEX = -49; + public static final int CL_DEVICE_ENDIAN_LITTLE = 4134; + public static final int CL_COMMAND_READ_BUFFER = 4595; + public static final int CL_UNORM_INT_101010 = 4310; + public static final int CL_KERNEL_WORK_GROUP_SIZE = 4528; + public static final int CL_COMMAND_UNMAP_MEM_OBJECT = 4605; + public static final int CL_INVALID_PLATFORM = -32; + public static final int CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000; + public static final int CL_FLT_RADIX = 2; + public static final int CL_DEVICE_PARTITION_BY_NAMES_EXT = 16466; + public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT = 4104; + public static final int CL_SHRT_MIN = (-32767 - 1); + public static final int CL_INVALID_EVENT = -58; + public static final int CL_RG = 4274; + public static final int CL_RA = 4275; + public static final int CL_PROGRAM_BUILD_OPTIONS = 4482; + public static final int CL_INVALID_COMMAND_QUEUE = -36; + public static final int cl_khr_icd = 1; + public static final int CL_FP_ROUND_TO_NEAREST = (1 << 2); + public static final int CL_HALF_FLOAT = 4317; + public static final int CL_INVALID_BINARY = -42; + public static final int CL_COMMAND_WRITE_IMAGE = 4599; + public static final int CL_INVALID_KERNEL_DEFINITION = -47; + public static final int CL_ADDRESS_CLAMP = 4402; + public static final int CL_COMMAND_USER = 4612; + public static final int CL_UNORM_SHORT_565 = 4308; + public static final int CL_UNORM_INT16 = 4307; + public static final double CL_M_2_PI = 0.6366197723675814; + public static final int CL_ADDRESS_REPEAT = 4403; + public static final int CL_FALSE = 0; + public static final int CL_Rx = 4282; + public static final int CL_INVALID_GLOBAL_OFFSET = -56; + public static final int CL_INVALID_PROGRAM = -44; + public static final int CL_INVALID_KERNEL = -48; + public static final int CL_MEM_SIZE = 4354; + public static final int CL_AFFINITY_DOMAIN_L1_CACHE_EXT = 1; + public static final int CL_PROGRAM_BINARIES = 4454; + public static final int CL_DEVICE_TYPE_DEFAULT = (1 << 0); + public static final int CL_DEVICE_IMAGE2D_MAX_HEIGHT = 4114; + public static final int CL_INVALID_BUILD_OPTIONS = -43; + public static final int CL_DEVICE_NOT_AVAILABLE = -2; + public static final int CL_INVALID_VALUE = -30; + public static final int CL_AFFINITY_DOMAIN_L3_CACHE_EXT = 3; + public static final int CL_DEVICE_MEM_BASE_ADDR_ALIGN = 4121; + public static final int CL_DEVICE_MAX_WORK_GROUP_SIZE = 4100; + public static final int CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0); + public static final int CL_SAMPLER_NORMALIZED_COORDS = 4434; + public static final int CL_EVENT_REFERENCE_COUNT = 4562; + public static final int CL_MEM_HOST_PTR = 4355; + public static final float CL_M_1_PI_F = 0.31830987F; + public static final int CL_MEM_OBJECT_ALLOCATION_FAILURE = -4; + public static final int CL_INVALID_MEM_OBJECT = -38; + public static final double CL_M_LN2 = 0.6931471805599453; + public static final int CL_COMPLETE = 0; + public static final int CL_INTENSITY = 4280; + public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF = 4156; + public static final int CL_INVALID_PROGRAM_EXECUTABLE = -45; + public static final int CL_MEM_WRITE_ONLY = (1 << 1); + public static final int CL_PROGRAM_CONTEXT = 4449; + public static final int CL_PLATFORM_ICD_SUFFIX_KHR = 2336; + public static final int CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST = -14; + public static final int CL_SAMPLER_ADDRESSING_MODE = 4435; + public static final int CL_MEM_CONTEXT = 4358; + public static final int CL_DEVICE_IMAGE3D_MAX_HEIGHT = 4116; + public static final int CL_DEVICE_MAX_READ_IMAGE_ARGS = 4110; + public static final int CL_DEVICE_NOT_FOUND = -1; + public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 4148; + public static final int CL_RGx = 4283; + public static final int CL_DEVICE_MAX_PARAMETER_SIZE = 4119; + public static final int CL_DEVICE_IMAGE3D_MAX_DEPTH = 4117; + public static final int CL_GL_OBJECT_TEXTURE2D = 8193; + public static final int CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 16467; + public static final int CL_MEM_USE_HOST_PTR = (1 << 3); + public static final int CL_SIGNED_INT8 = 4311; + public static final int CL_DEVICE_WARP_SIZE_NV = 16387; + public static final int CL_DEVICE_OPENCL_C_VERSION = 4157; + public static final int CL_DEVICE_ADDRESS_BITS = 4109; + public static final int CL_DEVICE_PARTITION_BY_COUNTS_EXT = 16465; + public static final int CL_GL_OBJECT_BUFFER = 8192; + public static final int CL_SAMPLER_CONTEXT = 4433; + public static final int CL_GL_OBJECT_TEXTURE3D = 8194; + public static final int CL_PLATFORM_VERSION = 2305; + public static final int CL_DEVICE_LOCAL_MEM_TYPE = 4130; + public static final int CL_DRIVER_VERSION = 4141; + public static final int CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 4122; + public static final int CL_DEVICE_VERSION = 4143; + public static final int CL_PLATFORM_NOT_FOUND_KHR = -1001; + public static final float CL_M_2_SQRTPI_F = 1.1283792F; + public static final int CL_SIGNED_INT32 = 4313; + public static final int CL_READ_WRITE_CACHE = 2; + public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT = 4151; + public static final int CL_KERNEL_COMPILE_WORK_GROUP_SIZE = 4529; + public static final int CL_PLATFORM_PROFILE = 2304; + public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT = 4154; + public static final float CL_M_PI_4_F = 0.7853982F; + public static final int CL_PROFILING_COMMAND_END = 4739; + public static final int CL_DEVICE_PROFILE = 4142; + public static final int CL_INVALID_OPERATION = -59; + public static final int CL_DEVICE_REFERENCE_COUNT_EXT = 16471; + public static final int CL_MEM_TYPE = 4352; + public static final int CL_KERNEL_CONTEXT = 4499; + public static final int CL_DEVICE_MAX_CLOCK_FREQUENCY = 4108; + public static final int CL_EVENT_CONTEXT = 4564; + public static final int CL_CONTEXT_NUM_DEVICES = 4227; + public static final int CL_HAS_NAMED_VECTOR_FIELDS = 1; + public static final int CL_GL_CONTEXT_KHR = 8200; + public static final int CL_DEVICE_PROFILING_TIMER_RESOLUTION = 4133; + public static final int CL_PROGRAM_BUILD_STATUS = 4481; + public static final int CL_DEVICE_GLOBAL_MEM_CACHE_TYPE = 4124; + public static final int CL_SUBMITTED = 2; + public static final int CL_PLATFORM_NAME = 2306; + public static final int CL_COMMAND_COPY_BUFFER_RECT = 4611; + public static final int CL_COMPILER_NOT_AVAILABLE = -3; + public static final int CL_SNORM_INT8 = 4304; + public static final int CL_FP_FMA = (1 << 5); + public static final int CL_PROFILING_COMMAND_START = 4738; + public static final int CL_COMMAND_COPY_IMAGE = 4600; + public static final int CL_DEVICE_MAX_WORK_ITEM_SIZES = 4101; + public static final int CL_IMAGE_ELEMENT_SIZE = 4369; + public static final int CL_DEVICE_PARTITION_EQUALLY_EXT = 16464; + public static final int CL_INVALID_CONTEXT = -34; + public static final int CL_IMAGE_HEIGHT = 4373; + public static final int CL_DEVICE_HOST_UNIFIED_MEMORY = 4149; + public static final int CL_COMMAND_MARKER = 4606; + public static final int CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 8205; + public static final int CL_AFFINITY_DOMAIN_L2_CACHE_EXT = 2; + public static final int CL_EXEC_NATIVE_KERNEL = (1 << 1); + public static final int CL_USHRT_MAX = 65535; + public static final int CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 8198; + public static final int CL_KERNEL_PRIVATE_MEM_SIZE = 4532; + public static final int CL_COMMAND_MAP_IMAGE = 4604; + public static final int CL_EXEC_KERNEL = (1 << 0); + public static final int CL_INVALID_GL_OBJECT = -60; + public static final int CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 16384; + public static final int CL_COMMAND_READ_BUFFER_RECT = 4609; + public static final int CL_QUEUE_DEVICE = 4241; + public static final int CL_DEVICE_GPU_OVERLAP_NV = 16388; + public static final int CL_DEVICE_EXTENSIONS = 4144; + public static final int CL_DEVICE_PARENT_DEVICE_EXT = 16468; + public static final int CL_MISALIGNED_SUB_BUFFER_OFFSET = -13; + public static final int CL_EVENT_COMMAND_EXECUTION_STATUS = 4563; + public static final int CL_DEVICE_MAX_WRITE_IMAGE_ARGS = 4111; + public static final int CL_INVALID_HOST_PTR = -37; + public static final float CL_M_SQRT2_F = 1.4142135F; + public static final int CL_VERSION_1_1 = 1; + public static final int CL_VERSION_1_0 = 1; + public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 4107; + public static final double CL_M_LOG2E = 1.4426950408889634; + public static final int CL_SHRT_MAX = 32767; + public static final int CL_UNORM_INT8 = 4306; + public static final int CL_DEVICE_QUEUE_PROPERTIES = 4138; + public static final int CL_BUILD_SUCCESS = 0; + public static final int CL_FP_DENORM = (1 << 0); + public static final float CL_M_LOG10E_F = 0.4342945F; + public static final int CL_GL_MIPMAP_LEVEL = 8197; + public static final int CL_SIGNED_INT16 = 4312; + public static final int CL_INT_MIN = (-2147483647 - 1); + public static final int CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 4103; + public static final int CL_DEVICE_PARTITION_STYLE_EXT = 16472; + public static final int CL_COMMAND_MAP_BUFFER = 4603; + public static final int CL_MAP_WRITE = (1 << 1); + public static final double CL_M_SQRT1_2 = 0.7071067811865476; + public static final float CL_M_LN10_F = 2.3025851F; + public static final int CL_FILTER_NEAREST = 4416; + public static final int CL_KERNEL_FUNCTION_NAME = 4496; + public static final int cl_khr_gl_sharing = 1; + public static final int CL_BUILD_ERROR = -2; + public static final int CL_OUT_OF_HOST_MEMORY = -6; + public static final int CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = 4126; + public static final int CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 4099; + public static final int CL_EVENT_COMMAND_TYPE = 4561; + public static final int CL_A = 4273; + public static final int CL_DEVICES_FOR_GL_CONTEXT_KHR = 8199; + public static final int CL_MEM_OFFSET = 4360; + public static final int CL_RGB = 4276; + public static final int CL_PROGRAM_BINARY_SIZES = 4453; + public static final int CL_INVALID_DEVICE = -33; + public static final int CL_R = 4272; + public static final int CL_COMMAND_WRITE_BUFFER = 4596; + public static final int CL_INVALID_PARTITION_COUNT_EXT = -1058; + public static final int CL_EGL_DISPLAY_KHR = 8201; + public static final int CL_TRUE = 1; + public static final int CL_BUILD_IN_PROGRESS = -3; + public static final int CL_MEM_OBJECT_BUFFER = 4336; + public static final float CL_M_PI_2_F = 1.5707964F; + public static final int CL_DEVICE_AFFINITY_DOMAINS_EXT = 16470; + public static final int CL_CONTEXT_PROPERTIES = 4226; + public static final int CL_SCHAR_MIN = (-127 - 1); + public static final int CL_FP_SOFT_FLOAT = (1 << 6); + public static final int CL_DEVICE_VENDOR = 4140; + public static final int CL_BUILD_NONE = -1; + public static final int CL_FLT_DIG = 6; + public static final int CL_MEM_OBJECT_IMAGE2D = 4337; + public static final double CL_M_PI = 3.141592653589793; + public static final int CL_IMAGE_FORMAT = 4368; + public static final int CL_PLATFORM_VENDOR = 2307; + public static final int CL_DEVICE_MAX_MEM_ALLOC_SIZE = 4112; + public static final int CL_PROFILING_COMMAND_QUEUED = 4736; + public static final float CL_M_LN2_F = 0.6931472F; + public static final int CL_DEVICE_PARTITION_TYPES_EXT = 16469; + public static final int CL_FILTER_LINEAR = 4417; + public static final int CL_DEVICE_TYPE_ACCELERATOR = (1 << 3); + public static final int CL_DEVICE_IMAGE_SUPPORT = 4118; + public static final int CL_PROGRAM_BUILD_LOG = 4483; + public static final int CL_IMAGE_DEPTH = 4374; + public static final int CL_KERNEL_PROGRAM = 4500; + public static final int CL_MEM_OBJECT_IMAGE3D = 4338; + public static final double CL_M_1_PI = 0.3183098861837907; + public static final float CL_M_E_F = 2.7182817F; + public static final int CL_FLT_MANT_DIG = 24; + public static final int CL_LOCAL = 1; + public static final int CL_DEVICE_PROFILING_TIMER_OFFSET_AMD = 16438; + public static final int CL_QUEUE_REFERENCE_COUNT = 4242; + public static final int CL_DEVICE_PARTITION_FAILED_EXT = -1057; + public static final double CL_M_LOG10E = 0.4342944819032518; + public static final int CL_IMAGE_FORMAT_NOT_SUPPORTED = -10; + public static final int CL_DEVICE_AVAILABLE = 4135; + public static final int CL_UCHAR_MAX = 255; + public static final int CL_DBL_MIN_10_EXP = -307; + public static final int CL_DEVICE_MAX_SAMPLERS = 4120; + public static final int CL_MEM_COPY_OVERLAP = -8; + public static final int CL_MAP_READ = (1 << 0); + public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE = 4155; + public static final int CL_COMMAND_READ_IMAGE = 4598; + public static final int CL_PROGRAM_NUM_DEVICES = 4450; + public static final int CL_UNSIGNED_INT8 = 4314; + public static final int CL_DBL_DIG = 15; + public static final int cl_APPLE_ContextLoggingFunctions = 1; + public static final int CL_WGL_HDC_KHR = 8203; + public static final int CL_DBL_MANT_DIG = 53; + public static final int CL_COMMAND_COPY_BUFFER_TO_IMAGE = 4602; + public static final int CL_CGL_SHAREGROUP_KHR = 8204; + public static final int CL_PROGRAM_DEVICES = 4451; + public static final int CL_SAMPLER_REFERENCE_COUNT = 4432; + public static final int CL_MEM_READ_WRITE = (1 << 0); + public static final int CL_INVALID_KERNEL_NAME = -46; + public static final int CL_DEVICE_EXECUTION_CAPABILITIES = 4137; + public static final int CL_DEVICE_NAME = 4139; + public static final int CL_DEVICE_INTEGRATED_MEMORY_NV = 16390; + public static final int CL_MEM_REFERENCE_COUNT = 4357; + public static final int CL_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39; + public static final int cl_ext_device_fission = 1; + public static final int CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 4128; + public static final int CL_MAP_FAILURE = -12; + public static final int CL_IMAGE_SLICE_PITCH = 4371; + public static final int CL_LUMINANCE = 4281; + public static final int CL_ADDRESS_CLAMP_TO_EDGE = 4401; + public static final int CL_GL_OBJECT_RENDERBUFFER = 8195; + public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_INT = 4152; + public static final int CL_SAMPLER_FILTER_MODE = 4436; + public static final int CL_INVALID_QUEUE_PROPERTIES = -35; + public static final int CL_INVALID_GLOBAL_WORK_SIZE = -63; + public static final int CL_INT_MAX = 2147483647; + public static final int CL_AFFINITY_DOMAIN_NUMA_EXT = 16; + public static final int CL_FLT_MIN_10_EXP = -37; + public static final int CL_AFFINITY_DOMAIN_L4_CACHE_EXT = 4; + public static final int CL_MEM_COPY_HOST_PTR = (1 << 5); + public static final int CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 4531; + public static final int CL_MEM_FLAGS = 4353; + public static final int CL_DEVICE_DOUBLE_FP_CONFIG = 4146; + public static final int CL_COMMAND_TASK = 4593; + public static final int CL_DEVICE_HALF_FP_CONFIG = 4147; + public static final int CL_FP_ROUND_TO_ZERO = (1 << 3); + public static final int CL_RUNNING = 1; + public static final int CL_DEVICE_IMAGE3D_MAX_WIDTH = 4115; + public static final int CL_INVALID_WORK_DIMENSION = -53; + public static final int CL_DEVICE_PLATFORM = 4145; + public static final int CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG = 4153; + public static final double CL_M_E = 2.718281828459045; + public static final int CL_INVALID_SAMPLER = -41; + public static final int CL_CHAR_MIN = -127 - 1; + public static final int CL_CHAR_MAX = OpenCLLibrary.CL_SCHAR_MAX; + public interface clGetGLContextInfoKHR_fn extends Callback { + int invoke(NativeSizeByReference properties, int param_name, NativeSize param_value_size, Pointer param_value, NativeSizeByReference param_value_size_ret); + }; + public interface clIcdGetPlatformIDsKHR_fn extends Callback { + int invoke(int cl_uint1, PointerByReference cl_platform_idPtr1, IntByReference cl_uintPtr1); + }; + public interface clReleaseDeviceEXT_fn extends Callback { + int invoke(OpenCLLibrary.cl_device_id cl_device_id1); + }; + public interface clRetainDeviceEXT_fn extends Callback { + int invoke(OpenCLLibrary.cl_device_id cl_device_id1); + }; + public interface clCreateContext_arg1_callback extends Callback { + void invoke(Pointer charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); + }; + public interface clCreateContextFromType_arg1_callback extends Callback { + void invoke(Pointer charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); + }; + public interface clSetMemObjectDestructorCallback_arg1_callback extends Callback { + /// @param cl_mem1 user_data + void invoke(OpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1); + }; + public interface clBuildProgram_arg1_callback extends Callback { + /// @param cl_program1 user_data + void invoke(OpenCLLibrary.cl_program cl_program1, Pointer voidPtr1); + }; + public interface clSetEventCallback_arg1_callback extends Callback { + void invoke(OpenCLLibrary.cl_event cl_event1, int cl_int1, Pointer voidPtr1); + }; + public interface user_func extends Callback { + void invoke(Pointer voidPtr1); + }; + public interface clSetMemObjectDestructorAPPLE_arg1_callback extends Callback { + /// @param cl_mem1 user_data + void invoke(OpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1); + }; + public interface clCreateSubDevicesEXT_fn_callback extends Callback { + int invoke(OpenCLLibrary.cl_device_id cl_device_id1, LongByReference cl_device_partition_property_extPtr1, int cl_uint1, PointerByReference cl_device_idPtr1, IntByReference cl_uintPtr1); + }; /** * Platform API
    - * Original signature : cl_int clGetPlatformIDs(cl_uint, cl_platform_id*, cl_uint*) - */ - public int clGetPlatformIDs(int cl_uint1, Pointer cl_platform_idPtr1, Pointer cl_uintPtr1) { - return clGetPlatformIDs(cl_uint1, Pointer.getPeer(cl_platform_idPtr1), Pointer.getPeer(cl_uintPtr1)); - } - public native int clGetPlatformIDs(int cl_uint1, @Ptr long cl_platform_idPtr1, @Ptr long cl_uintPtr1); - /** Original signature : cl_int clGetPlatformInfo(cl_platform_id, cl_platform_info, size_t, void*, size_t*) */ - public int clGetPlatformInfo(IOpenCLLibrary.cl_platform_id cl_platform_id1, int cl_platform_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetPlatformInfo(Pointer.getPeer(cl_platform_id1), cl_platform_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetPlatformInfo(@Ptr long cl_platform_id1, int cl_platform_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); + * Original signature : cl_int clGetPlatformIDs(cl_uint, cl_platform_id*, cl_uint*)
    + * @see Khronos Documentation for clGetPlatformIDs
    + * @deprecated use the safer methods {@link #clGetPlatformIDs(int, com.sun.jna.ptr.PointerByReference, java.nio.IntBuffer)} and {@link #clGetPlatformIDs(int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_platform_id[], com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + int clGetPlatformIDs(int cl_uint1, PointerByReference cl_platform_idPtr1, IntByReference cl_uintPtr1); + /** + * Platform API
    + * Original signature : cl_int clGetPlatformIDs(cl_uint, cl_platform_id*, cl_uint*)
    + * @see Khronos Documentation for clGetPlatformIDs + */ + int clGetPlatformIDs(int cl_uint1, PointerByReference cl_platform_idPtr1, IntBuffer cl_uintPtr1); + /** + * Platform API
    + * Original signature : cl_int clGetPlatformIDs(cl_uint, cl_platform_id*, cl_uint*)
    + * @see Khronos Documentation for clGetPlatformIDs + */ + int clGetPlatformIDs(int cl_uint1, OpenCLLibrary.cl_platform_id cl_platform_idPtr1[], IntByReference cl_uintPtr1); + /** + * Original signature : cl_int clGetPlatformInfo(cl_platform_id, cl_platform_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetPlatformInfo + */ + int clGetPlatformInfo(OpenCLLibrary.cl_platform_id cl_platform_id1, int cl_platform_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); /** * Device APIs
    - * Original signature : cl_int clGetDeviceIDs(cl_platform_id, cl_device_type, cl_uint, cl_device_id*, cl_uint*) - */ - public int clGetDeviceIDs(IOpenCLLibrary.cl_platform_id cl_platform_id1, long cl_device_type1, int cl_uint1, Pointer cl_device_idPtr1, Pointer cl_uintPtr1) { - return clGetDeviceIDs(Pointer.getPeer(cl_platform_id1), cl_device_type1, cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(cl_uintPtr1)); - } - public native int clGetDeviceIDs(@Ptr long cl_platform_id1, long cl_device_type1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long cl_uintPtr1); - /** Original signature : cl_int clGetDeviceInfo(cl_device_id, cl_device_info, size_t, void*, size_t*) */ - public int clGetDeviceInfo(IOpenCLLibrary.cl_device_id cl_device_id1, int cl_device_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetDeviceInfo(Pointer.getPeer(cl_device_id1), cl_device_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetDeviceInfo(@Ptr long cl_device_id1, int cl_device_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_int clCreateSubDevices(cl_device_id, const cl_device_partition_property*, cl_uint, cl_device_id*, cl_uint*) */ - public int clCreateSubDevices(IOpenCLLibrary.cl_device_id cl_device_id1, Pointer cl_device_partition_propertyPtr1, int cl_uint1, Pointer cl_device_idPtr1, Pointer cl_uintPtr1) { - return clCreateSubDevices(Pointer.getPeer(cl_device_id1), Pointer.getPeer(cl_device_partition_propertyPtr1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(cl_uintPtr1)); - } - @Optional - public native int clCreateSubDevices(@Ptr long cl_device_id1, @Ptr long cl_device_partition_propertyPtr1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long cl_uintPtr1); - /** Original signature : cl_int clRetainDevice(cl_device_id) */ - public int clRetainDevice(IOpenCLLibrary.cl_device_id cl_device_id1) { - return clRetainDevice(Pointer.getPeer(cl_device_id1)); - } - @Optional - public native int clRetainDevice(@Ptr long cl_device_id1); - /** Original signature : cl_int clReleaseDevice(cl_device_id) */ - public int clReleaseDevice(IOpenCLLibrary.cl_device_id cl_device_id1) { - return clReleaseDevice(Pointer.getPeer(cl_device_id1)); - } - @Optional - public native int clReleaseDevice(@Ptr long cl_device_id1); + * Original signature : cl_int clGetDeviceIDs(cl_platform_id, cl_device_type, cl_uint, cl_device_id*, cl_uint*)
    + * @see Khronos Documentation for clGetDeviceIDs
    + * @deprecated use the safer methods {@link #clGetDeviceIDs(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_platform_id, long, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], java.nio.IntBuffer)} and {@link #clGetDeviceIDs(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_platform_id, long, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + int clGetDeviceIDs(OpenCLLibrary.cl_platform_id cl_platform_id1, long cl_device_type1, int cl_uint1, PointerByReference cl_device_idPtr1, IntByReference cl_uintPtr1); + /** + * Device APIs
    + * Original signature : cl_int clGetDeviceIDs(cl_platform_id, cl_device_type, cl_uint, cl_device_id*, cl_uint*)
    + * @see Khronos Documentation for clGetDeviceIDs + */ + int clGetDeviceIDs(OpenCLLibrary.cl_platform_id cl_platform_id1, long cl_device_type1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], IntBuffer cl_uintPtr1); + /** + * Device APIs
    + * Original signature : cl_int clGetDeviceIDs(cl_platform_id, cl_device_type, cl_uint, cl_device_id*, cl_uint*)
    + * @see Khronos Documentation for clGetDeviceIDs + */ + int clGetDeviceIDs(OpenCLLibrary.cl_platform_id cl_platform_id1, long cl_device_type1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], IntByReference cl_uintPtr1); + /** + * Original signature : cl_int clGetDeviceInfo(cl_device_id, cl_device_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetDeviceInfo + */ + int clGetDeviceInfo(OpenCLLibrary.cl_device_id cl_device_id1, int cl_device_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); /** * Context APIs
    - * Original signature : cl_context clCreateContext(const cl_context_properties*, cl_uint, const cl_device_id*, clCreateContext_arg1_callback*, void*, cl_int*) - */ - public IOpenCLLibrary.cl_context clCreateContext(Pointer cl_context_propertiesPtr1, int cl_uint1, Pointer cl_device_idPtr1, Pointer arg1, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_context(clCreateContext(Pointer.getPeer(cl_context_propertiesPtr1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateContext(@Ptr long cl_context_propertiesPtr1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_context clCreateContextFromType(const cl_context_properties*, cl_device_type, clCreateContextFromType_arg1_callback*, void*, cl_int*) */ - public IOpenCLLibrary.cl_context clCreateContextFromType(Pointer cl_context_propertiesPtr1, long cl_device_type1, Pointer arg1, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_context(clCreateContextFromType(Pointer.getPeer(cl_context_propertiesPtr1), cl_device_type1, Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateContextFromType(@Ptr long cl_context_propertiesPtr1, long cl_device_type1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clRetainContext(cl_context) */ - public int clRetainContext(IOpenCLLibrary.cl_context cl_context1) { - return clRetainContext(Pointer.getPeer(cl_context1)); - } - public native int clRetainContext(@Ptr long cl_context1); - /** Original signature : cl_int clReleaseContext(cl_context) */ - public int clReleaseContext(IOpenCLLibrary.cl_context cl_context1) { - return clReleaseContext(Pointer.getPeer(cl_context1)); - } - public native int clReleaseContext(@Ptr long cl_context1); - /** Original signature : cl_int clGetContextInfo(cl_context, cl_context_info, size_t, void*, size_t*) */ - public int clGetContextInfo(IOpenCLLibrary.cl_context cl_context1, int cl_context_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetContextInfo(Pointer.getPeer(cl_context1), cl_context_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetContextInfo(@Ptr long cl_context1, int cl_context_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); + * Original signature : cl_context clCreateContext(const cl_context_properties*, cl_uint, const cl_device_id*, clCreateContext_arg1_callback, void*, cl_int*)
    + * @see Khronos Documentation for clCreateContext
    + * @deprecated use the safer methods {@link #clCreateContext(com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], com.nativelibs4java.opencl.library.OpenCLLibrary.clCreateContext_arg1_callback, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clCreateContext(com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], com.nativelibs4java.opencl.library.OpenCLLibrary.clCreateContext_arg1_callback, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_context clCreateContext(NativeSizeByReference cl_context_propertiesPtr1, int cl_uint1, PointerByReference cl_device_idPtr1, OpenCLLibrary.clCreateContext_arg1_callback arg1, Pointer voidPtr1, IntByReference cl_intPtr1); + /** + * Context APIs
    + * Original signature : cl_context clCreateContext(const cl_context_properties*, cl_uint, const cl_device_id*, clCreateContext_arg1_callback, void*, cl_int*)
    + * @see Khronos Documentation for clCreateContext + */ + OpenCLLibrary.cl_context clCreateContext(NativeSizeByReference cl_context_propertiesPtr1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], OpenCLLibrary.clCreateContext_arg1_callback arg1, Pointer voidPtr1, IntBuffer cl_intPtr1); + /** + * Context APIs
    + * Original signature : cl_context clCreateContext(const cl_context_properties*, cl_uint, const cl_device_id*, clCreateContext_arg1_callback, void*, cl_int*)
    + * @see Khronos Documentation for clCreateContext + */ + OpenCLLibrary.cl_context clCreateContext(NativeSizeByReference cl_context_propertiesPtr1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], OpenCLLibrary.clCreateContext_arg1_callback arg1, Pointer voidPtr1, IntByReference cl_intPtr1); + /** + * Original signature : cl_context clCreateContextFromType(const cl_context_properties*, cl_device_type, clCreateContextFromType_arg1_callback, void*, cl_int*)
    + * @see Khronos Documentation for clCreateContextFromType
    + * @deprecated use the safer methods {@link #clCreateContextFromType(com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, long, com.nativelibs4java.opencl.library.OpenCLLibrary.clCreateContextFromType_arg1_callback, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clCreateContextFromType(com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, long, com.nativelibs4java.opencl.library.OpenCLLibrary.clCreateContextFromType_arg1_callback, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_context clCreateContextFromType(NativeSizeByReference cl_context_propertiesPtr1, long cl_device_type1, OpenCLLibrary.clCreateContextFromType_arg1_callback arg1, Pointer voidPtr1, IntByReference cl_intPtr1); + /** + * Original signature : cl_context clCreateContextFromType(const cl_context_properties*, cl_device_type, clCreateContextFromType_arg1_callback, void*, cl_int*)
    + * @see Khronos Documentation for clCreateContextFromType + */ + OpenCLLibrary.cl_context clCreateContextFromType(NativeSizeByReference cl_context_propertiesPtr1, long cl_device_type1, OpenCLLibrary.clCreateContextFromType_arg1_callback arg1, Pointer voidPtr1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_int clRetainContext(cl_context)
    + * @see Khronos Documentation for clRetainContext + */ + int clRetainContext(OpenCLLibrary.cl_context cl_context1); + /** + * Original signature : cl_int clReleaseContext(cl_context)
    + * @see Khronos Documentation for clReleaseContext + */ + int clReleaseContext(OpenCLLibrary.cl_context cl_context1); + /** + * Original signature : cl_int clGetContextInfo(cl_context, cl_context_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetContextInfo + */ + int clGetContextInfo(OpenCLLibrary.cl_context cl_context1, int cl_context_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Command Queue APIs
    + * Original signature : cl_command_queue clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*)
    + * @see Khronos Documentation for clCreateCommandQueue
    + * @deprecated use the safer methods {@link #clCreateCommandQueue(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id, long, java.nio.IntBuffer)} and {@link #clCreateCommandQueue(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id, long, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_command_queue clCreateCommandQueue(OpenCLLibrary.cl_context cl_context1, OpenCLLibrary.cl_device_id cl_device_id1, long cl_command_queue_properties1, IntByReference cl_intPtr1); /** * Command Queue APIs
    - * Original signature : cl_command_queue clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*) - */ - public IOpenCLLibrary.cl_command_queue clCreateCommandQueue(IOpenCLLibrary.cl_context cl_context1, IOpenCLLibrary.cl_device_id cl_device_id1, long cl_command_queue_properties1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_command_queue(clCreateCommandQueue(Pointer.getPeer(cl_context1), Pointer.getPeer(cl_device_id1), cl_command_queue_properties1, Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateCommandQueue(@Ptr long cl_context1, @Ptr long cl_device_id1, long cl_command_queue_properties1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clRetainCommandQueue(cl_command_queue) */ - public int clRetainCommandQueue(IOpenCLLibrary.cl_command_queue cl_command_queue1) { - return clRetainCommandQueue(Pointer.getPeer(cl_command_queue1)); - } - public native int clRetainCommandQueue(@Ptr long cl_command_queue1); - /** Original signature : cl_int clReleaseCommandQueue(cl_command_queue) */ - public int clReleaseCommandQueue(IOpenCLLibrary.cl_command_queue cl_command_queue1) { - return clReleaseCommandQueue(Pointer.getPeer(cl_command_queue1)); - } - public native int clReleaseCommandQueue(@Ptr long cl_command_queue1); - /** Original signature : cl_int clGetCommandQueueInfo(cl_command_queue, cl_command_queue_info, size_t, void*, size_t*) */ - public int clGetCommandQueueInfo(IOpenCLLibrary.cl_command_queue cl_command_queue1, int cl_command_queue_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetCommandQueueInfo(Pointer.getPeer(cl_command_queue1), cl_command_queue_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetCommandQueueInfo(@Ptr long cl_command_queue1, int cl_command_queue_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); + * Original signature : cl_command_queue clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*)
    + * @see Khronos Documentation for clCreateCommandQueue + */ + OpenCLLibrary.cl_command_queue clCreateCommandQueue(OpenCLLibrary.cl_context cl_context1, OpenCLLibrary.cl_device_id cl_device_id1, long cl_command_queue_properties1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_int clRetainCommandQueue(cl_command_queue)
    + * @see Khronos Documentation for clRetainCommandQueue + */ + int clRetainCommandQueue(OpenCLLibrary.cl_command_queue cl_command_queue1); + /** + * Original signature : cl_int clReleaseCommandQueue(cl_command_queue)
    + * @see Khronos Documentation for clReleaseCommandQueue + */ + int clReleaseCommandQueue(OpenCLLibrary.cl_command_queue cl_command_queue1); + /** + * Original signature : cl_int clGetCommandQueueInfo(cl_command_queue, cl_command_queue_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetCommandQueueInfo + */ + int clGetCommandQueueInfo(OpenCLLibrary.cl_command_queue cl_command_queue1, int cl_command_queue_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * WARNING:
    + * This API introduces mutable state into the OpenCL implementation. It has been REMOVED
    + * to better facilitate thread safety. The 1.0 API is not thread safe. It is not tested by the
    + * OpenCL 1.1 conformance test, and consequently may not work or may not work dependably.
    + * It is likely to be non-performant. Use of this API is not advised. Use at your own risk.
    + * * Software developers previously relying on this API are instructed to set the command queue
    + * properties when creating the queue, instead.
    + * Original signature : cl_int clSetCommandQueueProperty(cl_command_queue, cl_command_queue_properties, cl_bool, cl_command_queue_properties*)
    + * @see Khronos Documentation for clSetCommandQueueProperty
    + * @deprecated use the safer methods {@link #clSetCommandQueueProperty(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, long, int, java.nio.LongBuffer)} and {@link #clSetCommandQueueProperty(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, long, int, com.sun.jna.ptr.LongByReference)} instead + */ + @java.lang.Deprecated + int clSetCommandQueueProperty(OpenCLLibrary.cl_command_queue cl_command_queue1, long cl_command_queue_properties1, int cl_bool1, LongByReference cl_command_queue_propertiesPtr1); + /** + * WARNING:
    + * This API introduces mutable state into the OpenCL implementation. It has been REMOVED
    + * to better facilitate thread safety. The 1.0 API is not thread safe. It is not tested by the
    + * OpenCL 1.1 conformance test, and consequently may not work or may not work dependably.
    + * It is likely to be non-performant. Use of this API is not advised. Use at your own risk.
    + * * Software developers previously relying on this API are instructed to set the command queue
    + * properties when creating the queue, instead.
    + * Original signature : cl_int clSetCommandQueueProperty(cl_command_queue, cl_command_queue_properties, cl_bool, cl_command_queue_properties*)
    + * @see Khronos Documentation for clSetCommandQueueProperty + */ + int clSetCommandQueueProperty(OpenCLLibrary.cl_command_queue cl_command_queue1, long cl_command_queue_properties1, int cl_bool1, LongBuffer cl_command_queue_propertiesPtr1); + /** + * Memory Object APIs
    + * Original signature : cl_mem clCreateBuffer(cl_context, cl_mem_flags, size_t, void*, cl_int*)
    + * @see Khronos Documentation for clCreateBuffer
    + * @deprecated use the safer methods {@link #clCreateBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clCreateBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateBuffer(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, NativeSize size_t1, Pointer voidPtr1, IntByReference cl_intPtr1); /** * Memory Object APIs
    - * Original signature : cl_mem clCreateBuffer(cl_context, cl_mem_flags, size_t, void*, cl_int*) - */ - public IOpenCLLibrary.cl_mem clCreateBuffer(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, @Ptr long size_t1, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateBuffer(Pointer.getPeer(cl_context1), cl_mem_flags1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateBuffer(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_mem clCreateSubBuffer(cl_mem, cl_mem_flags, cl_buffer_create_type, const void*, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateSubBuffer(IOpenCLLibrary.cl_mem cl_mem1, long cl_mem_flags1, int cl_buffer_create_type1, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateSubBuffer(Pointer.getPeer(cl_mem1), cl_mem_flags1, cl_buffer_create_type1, Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - @Optional - public native long clCreateSubBuffer(@Ptr long cl_mem1, long cl_mem_flags1, int cl_buffer_create_type1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_mem clCreateImage(cl_context, cl_mem_flags, const cl_image_format*, const cl_image_desc*, void*, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateImage(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, Pointer cl_image_formatPtr1, Pointer cl_image_descPtr1, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateImage(Pointer.getPeer(cl_context1), cl_mem_flags1, Pointer.getPeer(cl_image_formatPtr1), Pointer.getPeer(cl_image_descPtr1), Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - @Optional - public native long clCreateImage(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long cl_image_formatPtr1, @Ptr long cl_image_descPtr1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clRetainMemObject(cl_mem) */ - public int clRetainMemObject(IOpenCLLibrary.cl_mem cl_mem1) { - return clRetainMemObject(Pointer.getPeer(cl_mem1)); - } - public native int clRetainMemObject(@Ptr long cl_mem1); - /** Original signature : cl_int clReleaseMemObject(cl_mem) */ - public int clReleaseMemObject(IOpenCLLibrary.cl_mem cl_mem1) { - return clReleaseMemObject(Pointer.getPeer(cl_mem1)); - } - public native int clReleaseMemObject(@Ptr long cl_mem1); - /** Original signature : cl_int clGetSupportedImageFormats(cl_context, cl_mem_flags, cl_mem_object_type, cl_uint, cl_image_format*, cl_uint*) */ - public int clGetSupportedImageFormats(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_mem_object_type1, int cl_uint1, Pointer cl_image_formatPtr1, Pointer cl_uintPtr1) { - return clGetSupportedImageFormats(Pointer.getPeer(cl_context1), cl_mem_flags1, cl_mem_object_type1, cl_uint1, Pointer.getPeer(cl_image_formatPtr1), Pointer.getPeer(cl_uintPtr1)); - } - public native int clGetSupportedImageFormats(@Ptr long cl_context1, long cl_mem_flags1, int cl_mem_object_type1, int cl_uint1, @Ptr long cl_image_formatPtr1, @Ptr long cl_uintPtr1); - /** Original signature : cl_int clGetMemObjectInfo(cl_mem, cl_mem_info, size_t, void*, size_t*) */ - public int clGetMemObjectInfo(IOpenCLLibrary.cl_mem cl_mem1, int cl_mem_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetMemObjectInfo(Pointer.getPeer(cl_mem1), cl_mem_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetMemObjectInfo(@Ptr long cl_mem1, int cl_mem_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_int clGetImageInfo(cl_mem, cl_image_info, size_t, void*, size_t*) */ - public int clGetImageInfo(IOpenCLLibrary.cl_mem cl_mem1, int cl_image_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetImageInfo(Pointer.getPeer(cl_mem1), cl_image_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetImageInfo(@Ptr long cl_mem1, int cl_image_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_int clSetMemObjectDestructorCallback(cl_mem, clSetMemObjectDestructorCallback_arg1_callback*, void*) */ - public int clSetMemObjectDestructorCallback(IOpenCLLibrary.cl_mem cl_mem1, Pointer arg1, Pointer voidPtr1) { - return clSetMemObjectDestructorCallback(Pointer.getPeer(cl_mem1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1)); - } - @Optional - public native int clSetMemObjectDestructorCallback(@Ptr long cl_mem1, @Ptr long arg1, @Ptr long voidPtr1); + * Original signature : cl_mem clCreateBuffer(cl_context, cl_mem_flags, size_t, void*, cl_int*)
    + * @see Khronos Documentation for clCreateBuffer + */ + OpenCLLibrary.cl_mem clCreateBuffer(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, NativeSize size_t1, Pointer voidPtr1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_mem clCreateSubBuffer(cl_mem, cl_mem_flags, cl_buffer_create_type, const void*, cl_int*)
    + * @see Khronos Documentation for clCreateSubBuffer
    + * @deprecated use the safer methods {@link #clCreateSubBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, long, int, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clCreateSubBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, long, int, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateSubBuffer(OpenCLLibrary.cl_mem cl_mem1, long cl_mem_flags1, int cl_buffer_create_type1, Pointer voidPtr1, IntByReference cl_intPtr1); + /** + * Original signature : cl_mem clCreateSubBuffer(cl_mem, cl_mem_flags, cl_buffer_create_type, const void*, cl_int*)
    + * @see Khronos Documentation for clCreateSubBuffer + */ + OpenCLLibrary.cl_mem clCreateSubBuffer(OpenCLLibrary.cl_mem cl_mem1, long cl_mem_flags1, int cl_buffer_create_type1, Pointer voidPtr1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_mem clCreateImage2D(cl_context, cl_mem_flags, const cl_image_format*, size_t, size_t, size_t, void*, cl_int*)
    + * @see Khronos Documentation for clCreateImage2D
    + * @deprecated use the safer methods {@link #clCreateImage2D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, com.nativelibs4java.opencl.library.cl_image_format, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clCreateImage2D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, com.nativelibs4java.opencl.library.cl_image_format, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateImage2D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, com.nativelibs4java.opencl.library.cl_image_format cl_image_formatPtr1, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, Pointer voidPtr1, IntByReference cl_intPtr1); + /** + * Original signature : cl_mem clCreateImage2D(cl_context, cl_mem_flags, const cl_image_format*, size_t, size_t, size_t, void*, cl_int*)
    + * @see Khronos Documentation for clCreateImage2D + */ + OpenCLLibrary.cl_mem clCreateImage2D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, com.nativelibs4java.opencl.library.cl_image_format cl_image_formatPtr1, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, Pointer voidPtr1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_mem clCreateImage3D(cl_context, cl_mem_flags, const cl_image_format*, size_t, size_t, size_t, size_t, size_t, void*, cl_int*)
    + * @see Khronos Documentation for clCreateImage3D
    + * @deprecated use the safer methods {@link #clCreateImage3D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, com.nativelibs4java.opencl.library.cl_image_format, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, java.nio.IntBuffer)} and {@link #clCreateImage3D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, com.nativelibs4java.opencl.library.cl_image_format, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateImage3D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, com.nativelibs4java.opencl.library.cl_image_format cl_image_formatPtr1, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, NativeSize size_t5, Pointer voidPtr1, IntByReference cl_intPtr1); + /** + * Original signature : cl_mem clCreateImage3D(cl_context, cl_mem_flags, const cl_image_format*, size_t, size_t, size_t, size_t, size_t, void*, cl_int*)
    + * @see Khronos Documentation for clCreateImage3D + */ + OpenCLLibrary.cl_mem clCreateImage3D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, com.nativelibs4java.opencl.library.cl_image_format cl_image_formatPtr1, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, NativeSize size_t5, Pointer voidPtr1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_int clRetainMemObject(cl_mem)
    + * @see Khronos Documentation for clRetainMemObject + */ + int clRetainMemObject(OpenCLLibrary.cl_mem cl_mem1); + /** + * Original signature : cl_int clReleaseMemObject(cl_mem)
    + * @see Khronos Documentation for clReleaseMemObject + */ + int clReleaseMemObject(OpenCLLibrary.cl_mem cl_mem1); + /** + * Original signature : cl_int clGetSupportedImageFormats(cl_context, cl_mem_flags, cl_mem_object_type, cl_uint, cl_image_format*, cl_uint*)
    + * @see Khronos Documentation for clGetSupportedImageFormats
    + * @deprecated use the safer methods {@link #clGetSupportedImageFormats(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, int, com.nativelibs4java.opencl.library.cl_image_format, java.nio.IntBuffer)} and {@link #clGetSupportedImageFormats(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, int, com.nativelibs4java.opencl.library.cl_image_format, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + int clGetSupportedImageFormats(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_mem_object_type1, int cl_uint1, com.nativelibs4java.opencl.library.cl_image_format cl_image_formatPtr1, IntByReference cl_uintPtr1); + /** + * Original signature : cl_int clGetSupportedImageFormats(cl_context, cl_mem_flags, cl_mem_object_type, cl_uint, cl_image_format*, cl_uint*)
    + * @see Khronos Documentation for clGetSupportedImageFormats + */ + int clGetSupportedImageFormats(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_mem_object_type1, int cl_uint1, com.nativelibs4java.opencl.library.cl_image_format cl_image_formatPtr1, IntBuffer cl_uintPtr1); + /** + * Original signature : cl_int clGetMemObjectInfo(cl_mem, cl_mem_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetMemObjectInfo + */ + int clGetMemObjectInfo(OpenCLLibrary.cl_mem cl_mem1, int cl_mem_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Original signature : cl_int clGetImageInfo(cl_mem, cl_image_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetImageInfo + */ + int clGetImageInfo(OpenCLLibrary.cl_mem cl_mem1, int cl_image_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Original signature : cl_int clSetMemObjectDestructorCallback(cl_mem, clSetMemObjectDestructorCallback_arg1_callback, void*)
    + * @see Khronos Documentation for clSetMemObjectDestructorCallback + */ + int clSetMemObjectDestructorCallback(OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.clSetMemObjectDestructorCallback_arg1_callback arg1, Pointer voidPtr1); /** * Sampler APIs
    - * Original signature : cl_sampler clCreateSampler(cl_context, cl_bool, cl_addressing_mode, cl_filter_mode, cl_int*) - */ - public IOpenCLLibrary.cl_sampler clCreateSampler(IOpenCLLibrary.cl_context cl_context1, int cl_bool1, int cl_addressing_mode1, int cl_filter_mode1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_sampler(clCreateSampler(Pointer.getPeer(cl_context1), cl_bool1, cl_addressing_mode1, cl_filter_mode1, Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateSampler(@Ptr long cl_context1, int cl_bool1, int cl_addressing_mode1, int cl_filter_mode1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clRetainSampler(cl_sampler) */ - public int clRetainSampler(IOpenCLLibrary.cl_sampler cl_sampler1) { - return clRetainSampler(Pointer.getPeer(cl_sampler1)); - } - public native int clRetainSampler(@Ptr long cl_sampler1); - /** Original signature : cl_int clReleaseSampler(cl_sampler) */ - public int clReleaseSampler(IOpenCLLibrary.cl_sampler cl_sampler1) { - return clReleaseSampler(Pointer.getPeer(cl_sampler1)); - } - public native int clReleaseSampler(@Ptr long cl_sampler1); - /** Original signature : cl_int clGetSamplerInfo(cl_sampler, cl_sampler_info, size_t, void*, size_t*) */ - public int clGetSamplerInfo(IOpenCLLibrary.cl_sampler cl_sampler1, int cl_sampler_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetSamplerInfo(Pointer.getPeer(cl_sampler1), cl_sampler_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetSamplerInfo(@Ptr long cl_sampler1, int cl_sampler_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); + * Original signature : cl_sampler clCreateSampler(cl_context, cl_bool, cl_addressing_mode, cl_filter_mode, cl_int*)
    + * @see Khronos Documentation for clCreateSampler
    + * @deprecated use the safer methods {@link #clCreateSampler(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, int, int, int, java.nio.IntBuffer)} and {@link #clCreateSampler(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, int, int, int, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_sampler clCreateSampler(OpenCLLibrary.cl_context cl_context1, int cl_bool1, int cl_addressing_mode1, int cl_filter_mode1, IntByReference cl_intPtr1); + /** + * Sampler APIs
    + * Original signature : cl_sampler clCreateSampler(cl_context, cl_bool, cl_addressing_mode, cl_filter_mode, cl_int*)
    + * @see Khronos Documentation for clCreateSampler + */ + OpenCLLibrary.cl_sampler clCreateSampler(OpenCLLibrary.cl_context cl_context1, int cl_bool1, int cl_addressing_mode1, int cl_filter_mode1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_int clRetainSampler(cl_sampler)
    + * @see Khronos Documentation for clRetainSampler + */ + int clRetainSampler(OpenCLLibrary.cl_sampler cl_sampler1); + /** + * Original signature : cl_int clReleaseSampler(cl_sampler)
    + * @see Khronos Documentation for clReleaseSampler + */ + int clReleaseSampler(OpenCLLibrary.cl_sampler cl_sampler1); + /** + * Original signature : cl_int clGetSamplerInfo(cl_sampler, cl_sampler_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetSamplerInfo + */ + int clGetSamplerInfo(OpenCLLibrary.cl_sampler cl_sampler1, int cl_sampler_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Program Object APIs
    + * Original signature : cl_program clCreateProgramWithSource(cl_context, cl_uint, const char**, const size_t*, cl_int*)
    + * @see Khronos Documentation for clCreateProgramWithSource
    + * @deprecated use the safer methods {@link #clCreateProgramWithSource(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, int, java.lang.String[], com.ochafik.lang.jnaerator.runtime.NativeSize[], java.nio.IntBuffer)} and {@link #clCreateProgramWithSource(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, int, com.sun.jna.ptr.PointerByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_program clCreateProgramWithSource(OpenCLLibrary.cl_context cl_context1, int cl_uint1, PointerByReference charPtrPtr1, NativeSizeByReference size_tPtr1, IntByReference cl_intPtr1); /** * Program Object APIs
    - * Original signature : cl_program clCreateProgramWithSource(cl_context, cl_uint, const char**, const size_t*, cl_int*) - */ - public IOpenCLLibrary.cl_program clCreateProgramWithSource(IOpenCLLibrary.cl_context cl_context1, int cl_uint1, Pointer > charPtrPtr1, Pointer size_tPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_program(clCreateProgramWithSource(Pointer.getPeer(cl_context1), cl_uint1, Pointer.getPeer(charPtrPtr1), Pointer.getPeer(size_tPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateProgramWithSource(@Ptr long cl_context1, int cl_uint1, @Ptr long charPtrPtr1, @Ptr long size_tPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_program clCreateProgramWithBinary(cl_context, cl_uint, const cl_device_id*, const size_t*, const unsigned char**, cl_int*, cl_int*) */ - public IOpenCLLibrary.cl_program clCreateProgramWithBinary(IOpenCLLibrary.cl_context cl_context1, int cl_uint1, Pointer cl_device_idPtr1, Pointer size_tPtr1, Pointer > charPtrPtr1, Pointer cl_intPtr1, Pointer cl_intPtr2) { - return new IOpenCLLibrary.cl_program(clCreateProgramWithBinary(Pointer.getPeer(cl_context1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(size_tPtr1), Pointer.getPeer(charPtrPtr1), Pointer.getPeer(cl_intPtr1), Pointer.getPeer(cl_intPtr2))); - } - @Ptr - public native long clCreateProgramWithBinary(@Ptr long cl_context1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long size_tPtr1, @Ptr long charPtrPtr1, @Ptr long cl_intPtr1, @Ptr long cl_intPtr2); - /** Original signature : cl_program clCreateProgramWithBuiltInKernels(cl_context, cl_uint, const cl_device_id*, const char*, cl_int*) */ - public IOpenCLLibrary.cl_program clCreateProgramWithBuiltInKernels(IOpenCLLibrary.cl_context cl_context1, int cl_uint1, Pointer cl_device_idPtr1, Pointer charPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_program(clCreateProgramWithBuiltInKernels(Pointer.getPeer(cl_context1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(charPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - @Optional - public native long clCreateProgramWithBuiltInKernels(@Ptr long cl_context1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clRetainProgram(cl_program) */ - public int clRetainProgram(IOpenCLLibrary.cl_program cl_program1) { - return clRetainProgram(Pointer.getPeer(cl_program1)); - } - public native int clRetainProgram(@Ptr long cl_program1); - /** Original signature : cl_int clReleaseProgram(cl_program) */ - public int clReleaseProgram(IOpenCLLibrary.cl_program cl_program1) { - return clReleaseProgram(Pointer.getPeer(cl_program1)); - } - public native int clReleaseProgram(@Ptr long cl_program1); - /** Original signature : cl_int clBuildProgram(cl_program, cl_uint, const cl_device_id*, const char*, clBuildProgram_arg1_callback*, void*) */ - public int clBuildProgram(IOpenCLLibrary.cl_program cl_program1, int cl_uint1, Pointer cl_device_idPtr1, Pointer charPtr1, Pointer arg1, Pointer voidPtr1) { - return clBuildProgram(Pointer.getPeer(cl_program1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(charPtr1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1)); - } - public native int clBuildProgram(@Ptr long cl_program1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, @Ptr long arg1, @Ptr long voidPtr1); - /** Original signature : cl_int clCompileProgram(cl_program, cl_uint, const cl_device_id*, const char*, cl_uint, const cl_program*, const char**, clCompileProgram_arg1_callback*, void*) */ - public int clCompileProgram(IOpenCLLibrary.cl_program cl_program1, int cl_uint1, Pointer cl_device_idPtr1, Pointer charPtr1, int cl_uint2, Pointer cl_programPtr1, Pointer > charPtrPtr1, Pointer arg1, Pointer voidPtr1) { - return clCompileProgram(Pointer.getPeer(cl_program1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(charPtr1), cl_uint2, Pointer.getPeer(cl_programPtr1), Pointer.getPeer(charPtrPtr1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1)); - } - @Optional - public native int clCompileProgram(@Ptr long cl_program1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, int cl_uint2, @Ptr long cl_programPtr1, @Ptr long charPtrPtr1, @Ptr long arg1, @Ptr long voidPtr1); - /** Original signature : cl_program clLinkProgram(cl_context, cl_uint, const cl_device_id*, const char*, cl_uint, const cl_program*, clLinkProgram_arg1_callback*, void*, cl_int*) */ - public IOpenCLLibrary.cl_program clLinkProgram(IOpenCLLibrary.cl_context cl_context1, int cl_uint1, Pointer cl_device_idPtr1, Pointer charPtr1, int cl_uint2, Pointer cl_programPtr1, Pointer arg1, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_program(clLinkProgram(Pointer.getPeer(cl_context1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(charPtr1), cl_uint2, Pointer.getPeer(cl_programPtr1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - @Optional - public native long clLinkProgram(@Ptr long cl_context1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long charPtr1, int cl_uint2, @Ptr long cl_programPtr1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clUnloadPlatformCompiler(cl_platform_id) */ - public int clUnloadPlatformCompiler(IOpenCLLibrary.cl_platform_id cl_platform_id1) { - return clUnloadPlatformCompiler(Pointer.getPeer(cl_platform_id1)); - } - @Optional - public native int clUnloadPlatformCompiler(@Ptr long cl_platform_id1); - /** Original signature : cl_int clGetProgramInfo(cl_program, cl_program_info, size_t, void*, size_t*) */ - public int clGetProgramInfo(IOpenCLLibrary.cl_program cl_program1, int cl_program_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetProgramInfo(Pointer.getPeer(cl_program1), cl_program_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetProgramInfo(@Ptr long cl_program1, int cl_program_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_int clGetProgramBuildInfo(cl_program, cl_device_id, cl_program_build_info, size_t, void*, size_t*) */ - public int clGetProgramBuildInfo(IOpenCLLibrary.cl_program cl_program1, IOpenCLLibrary.cl_device_id cl_device_id1, int cl_program_build_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetProgramBuildInfo(Pointer.getPeer(cl_program1), Pointer.getPeer(cl_device_id1), cl_program_build_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetProgramBuildInfo(@Ptr long cl_program1, @Ptr long cl_device_id1, int cl_program_build_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); + * Original signature : cl_program clCreateProgramWithSource(cl_context, cl_uint, const char**, const size_t*, cl_int*)
    + * @see Khronos Documentation for clCreateProgramWithSource + */ + OpenCLLibrary.cl_program clCreateProgramWithSource(OpenCLLibrary.cl_context cl_context1, int cl_uint1, java.lang.String charPtrPtr1[], NativeSize size_tPtr1[], IntBuffer cl_intPtr1); + /** + * Original signature : cl_program clCreateProgramWithBinary(cl_context, cl_uint, const cl_device_id*, const size_t*, const unsigned char**, cl_int*, cl_int*)
    + * @see Khronos Documentation for clCreateProgramWithBinary
    + * @deprecated use the safer methods {@link #clCreateProgramWithBinary(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.sun.jna.ptr.PointerByReference, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #clCreateProgramWithBinary(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.sun.jna.ptr.PointerByReference, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_program clCreateProgramWithBinary(OpenCLLibrary.cl_context cl_context1, int cl_uint1, PointerByReference cl_device_idPtr1, NativeSizeByReference size_tPtr1, PointerByReference charPtrPtr1, IntByReference cl_intPtr1, IntByReference cl_intPtr2); + /** + * Original signature : cl_program clCreateProgramWithBinary(cl_context, cl_uint, const cl_device_id*, const size_t*, const unsigned char**, cl_int*, cl_int*)
    + * @see Khronos Documentation for clCreateProgramWithBinary + */ + OpenCLLibrary.cl_program clCreateProgramWithBinary(OpenCLLibrary.cl_context cl_context1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], NativeSize size_tPtr1[], PointerByReference charPtrPtr1, IntBuffer cl_intPtr1, IntBuffer cl_intPtr2); + /** + * Original signature : cl_program clCreateProgramWithBinary(cl_context, cl_uint, const cl_device_id*, const size_t*, const unsigned char**, cl_int*, cl_int*)
    + * @see Khronos Documentation for clCreateProgramWithBinary + */ + OpenCLLibrary.cl_program clCreateProgramWithBinary(OpenCLLibrary.cl_context cl_context1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], NativeSize size_tPtr1[], String[] charPtrPtr1, IntBuffer cl_intPtr1, IntBuffer cl_intPtr2); + /** + * Original signature : cl_program clCreateProgramWithBinary(cl_context, cl_uint, const cl_device_id*, const size_t*, const unsigned char**, cl_int*, cl_int*)
    + * @see Khronos Documentation for clCreateProgramWithBinary + */ + OpenCLLibrary.cl_program clCreateProgramWithBinary(OpenCLLibrary.cl_context cl_context1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], NativeSizeByReference size_tPtr1, PointerByReference charPtrPtr1, IntByReference cl_intPtr1, IntByReference cl_intPtr2); + /** + * Original signature : cl_int clRetainProgram(cl_program)
    + * @see Khronos Documentation for clRetainProgram + */ + int clRetainProgram(OpenCLLibrary.cl_program cl_program1); + /** + * Original signature : cl_int clReleaseProgram(cl_program)
    + * @see Khronos Documentation for clReleaseProgram + */ + int clReleaseProgram(OpenCLLibrary.cl_program cl_program1); + /** + * Original signature : cl_int clBuildProgram(cl_program, cl_uint, const cl_device_id*, const char*, clBuildProgram_arg1_callback, void*)
    + * @see Khronos Documentation for clBuildProgram
    + * @deprecated use the safer methods {@link #clBuildProgram(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_program, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], java.lang.String, com.nativelibs4java.opencl.library.OpenCLLibrary.clBuildProgram_arg1_callback, com.sun.jna.Pointer)} and {@link #clBuildProgram(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_program, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], com.sun.jna.Pointer, com.nativelibs4java.opencl.library.OpenCLLibrary.clBuildProgram_arg1_callback, com.sun.jna.Pointer)} instead + */ + @java.lang.Deprecated + int clBuildProgram(OpenCLLibrary.cl_program cl_program1, int cl_uint1, PointerByReference cl_device_idPtr1, Pointer charPtr1, OpenCLLibrary.clBuildProgram_arg1_callback arg1, Pointer voidPtr1); + /** + * Original signature : cl_int clBuildProgram(cl_program, cl_uint, const cl_device_id*, const char*, clBuildProgram_arg1_callback, void*)
    + * @see Khronos Documentation for clBuildProgram + */ + int clBuildProgram(OpenCLLibrary.cl_program cl_program1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], java.lang.String charPtr1, OpenCLLibrary.clBuildProgram_arg1_callback arg1, Pointer voidPtr1); + /** + * Original signature : cl_int clBuildProgram(cl_program, cl_uint, const cl_device_id*, const char*, clBuildProgram_arg1_callback, void*)
    + * @see Khronos Documentation for clBuildProgram + */ + int clBuildProgram(OpenCLLibrary.cl_program cl_program1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], Pointer charPtr1, OpenCLLibrary.clBuildProgram_arg1_callback arg1, Pointer voidPtr1); + /** + * Original signature : cl_int clUnloadCompiler()
    + * @see Khronos Documentation for clUnloadCompiler + */ + int clUnloadCompiler(); + /** + * Original signature : cl_int clGetProgramInfo(cl_program, cl_program_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetProgramInfo + */ + int clGetProgramInfo(OpenCLLibrary.cl_program cl_program1, int cl_program_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Original signature : cl_int clGetProgramBuildInfo(cl_program, cl_device_id, cl_program_build_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetProgramBuildInfo + */ + int clGetProgramBuildInfo(OpenCLLibrary.cl_program cl_program1, OpenCLLibrary.cl_device_id cl_device_id1, int cl_program_build_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); /** * Kernel Object APIs
    - * Original signature : cl_kernel clCreateKernel(cl_program, const char*, cl_int*) - */ - public IOpenCLLibrary.cl_kernel clCreateKernel(IOpenCLLibrary.cl_program cl_program1, Pointer charPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_kernel(clCreateKernel(Pointer.getPeer(cl_program1), Pointer.getPeer(charPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateKernel(@Ptr long cl_program1, @Ptr long charPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clCreateKernelsInProgram(cl_program, cl_uint, cl_kernel*, cl_uint*) */ - public int clCreateKernelsInProgram(IOpenCLLibrary.cl_program cl_program1, int cl_uint1, Pointer cl_kernelPtr1, Pointer cl_uintPtr1) { - return clCreateKernelsInProgram(Pointer.getPeer(cl_program1), cl_uint1, Pointer.getPeer(cl_kernelPtr1), Pointer.getPeer(cl_uintPtr1)); - } - public native int clCreateKernelsInProgram(@Ptr long cl_program1, int cl_uint1, @Ptr long cl_kernelPtr1, @Ptr long cl_uintPtr1); - /** Original signature : cl_int clRetainKernel(cl_kernel) */ - public int clRetainKernel(IOpenCLLibrary.cl_kernel cl_kernel1) { - return clRetainKernel(Pointer.getPeer(cl_kernel1)); - } - public native int clRetainKernel(@Ptr long cl_kernel1); - /** Original signature : cl_int clReleaseKernel(cl_kernel) */ - public int clReleaseKernel(IOpenCLLibrary.cl_kernel cl_kernel1) { - return clReleaseKernel(Pointer.getPeer(cl_kernel1)); - } - public native int clReleaseKernel(@Ptr long cl_kernel1); - /** Original signature : cl_int clSetKernelArg(cl_kernel, cl_uint, size_t, const void*) */ - public int clSetKernelArg(IOpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, @Ptr long size_t1, Pointer voidPtr1) { - return clSetKernelArg(Pointer.getPeer(cl_kernel1), cl_uint1, size_t1, Pointer.getPeer(voidPtr1)); - } - public native int clSetKernelArg(@Ptr long cl_kernel1, int cl_uint1, @Ptr long size_t1, @Ptr long voidPtr1); - /** Original signature : cl_int clGetKernelInfo(cl_kernel, cl_kernel_info, size_t, void*, size_t*) */ - public int clGetKernelInfo(IOpenCLLibrary.cl_kernel cl_kernel1, int cl_kernel_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetKernelInfo(Pointer.getPeer(cl_kernel1), cl_kernel_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetKernelInfo(@Ptr long cl_kernel1, int cl_kernel_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_int clGetKernelArgInfo(cl_kernel, cl_uint, cl_kernel_arg_info, size_t, void*, size_t*) */ - public int clGetKernelArgInfo(IOpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, int cl_kernel_arg_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetKernelArgInfo(Pointer.getPeer(cl_kernel1), cl_uint1, cl_kernel_arg_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - @Optional - public native int clGetKernelArgInfo(@Ptr long cl_kernel1, int cl_uint1, int cl_kernel_arg_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_int clGetKernelWorkGroupInfo(cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void*, size_t*) */ - public int clGetKernelWorkGroupInfo(IOpenCLLibrary.cl_kernel cl_kernel1, IOpenCLLibrary.cl_device_id cl_device_id1, int cl_kernel_work_group_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetKernelWorkGroupInfo(Pointer.getPeer(cl_kernel1), Pointer.getPeer(cl_device_id1), cl_kernel_work_group_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetKernelWorkGroupInfo(@Ptr long cl_kernel1, @Ptr long cl_device_id1, int cl_kernel_work_group_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); + * Original signature : cl_kernel clCreateKernel(cl_program, const char*, cl_int*)
    + * @see Khronos Documentation for clCreateKernel
    + * @deprecated use the safer methods {@link #clCreateKernel(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_program, java.lang.String, java.nio.IntBuffer)} and {@link #clCreateKernel(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_program, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_kernel clCreateKernel(OpenCLLibrary.cl_program cl_program1, Pointer charPtr1, IntByReference cl_intPtr1); + /** + * Kernel Object APIs
    + * Original signature : cl_kernel clCreateKernel(cl_program, const char*, cl_int*)
    + * @see Khronos Documentation for clCreateKernel + */ + OpenCLLibrary.cl_kernel clCreateKernel(OpenCLLibrary.cl_program cl_program1, java.lang.String charPtr1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_int clCreateKernelsInProgram(cl_program, cl_uint, cl_kernel*, cl_uint*)
    + * @see Khronos Documentation for clCreateKernelsInProgram
    + * @deprecated use the safer methods {@link #clCreateKernelsInProgram(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_program, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_kernel[], java.nio.IntBuffer)} and {@link #clCreateKernelsInProgram(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_program, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_kernel[], com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + int clCreateKernelsInProgram(OpenCLLibrary.cl_program cl_program1, int cl_uint1, PointerByReference cl_kernelPtr1, IntByReference cl_uintPtr1); + /** + * Original signature : cl_int clCreateKernelsInProgram(cl_program, cl_uint, cl_kernel*, cl_uint*)
    + * @see Khronos Documentation for clCreateKernelsInProgram + */ + int clCreateKernelsInProgram(OpenCLLibrary.cl_program cl_program1, int cl_uint1, OpenCLLibrary.cl_kernel cl_kernelPtr1[], IntBuffer cl_uintPtr1); + /** + * Original signature : cl_int clCreateKernelsInProgram(cl_program, cl_uint, cl_kernel*, cl_uint*)
    + * @see Khronos Documentation for clCreateKernelsInProgram + */ + int clCreateKernelsInProgram(OpenCLLibrary.cl_program cl_program1, int cl_uint1, OpenCLLibrary.cl_kernel cl_kernelPtr1[], IntByReference cl_uintPtr1); + /** + * Original signature : cl_int clRetainKernel(cl_kernel)
    + * @see Khronos Documentation for clRetainKernel + */ + int clRetainKernel(OpenCLLibrary.cl_kernel cl_kernel1); + /** + * Original signature : cl_int clReleaseKernel(cl_kernel)
    + * @see Khronos Documentation for clReleaseKernel + */ + int clReleaseKernel(OpenCLLibrary.cl_kernel cl_kernel1); + /** + * Original signature : cl_int clSetKernelArg(cl_kernel, cl_uint, size_t, const void*)
    + * @see Khronos Documentation for clSetKernelArg + */ + int clSetKernelArg(OpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, NativeSize size_t1, Pointer voidPtr1); + /** + * Original signature : cl_int clGetKernelInfo(cl_kernel, cl_kernel_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetKernelInfo + */ + int clGetKernelInfo(OpenCLLibrary.cl_kernel cl_kernel1, int cl_kernel_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Original signature : cl_int clGetKernelWorkGroupInfo(cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetKernelWorkGroupInfo + */ + int clGetKernelWorkGroupInfo(OpenCLLibrary.cl_kernel cl_kernel1, OpenCLLibrary.cl_device_id cl_device_id1, int cl_kernel_work_group_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); /** * Event Object APIs
    - * Original signature : cl_int clWaitForEvents(cl_uint, const cl_event*) - */ - public int clWaitForEvents(int cl_uint1, Pointer cl_eventPtr1) { - return clWaitForEvents(cl_uint1, Pointer.getPeer(cl_eventPtr1)); - } - public native int clWaitForEvents(int cl_uint1, @Ptr long cl_eventPtr1); - /** Original signature : cl_int clGetEventInfo(cl_event, cl_event_info, size_t, void*, size_t*) */ - public int clGetEventInfo(IOpenCLLibrary.cl_event cl_event1, int cl_event_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetEventInfo(Pointer.getPeer(cl_event1), cl_event_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetEventInfo(@Ptr long cl_event1, int cl_event_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_event clCreateUserEvent(cl_context, cl_int*) */ - public IOpenCLLibrary.cl_event clCreateUserEvent(IOpenCLLibrary.cl_context cl_context1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_event(clCreateUserEvent(Pointer.getPeer(cl_context1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - @Optional - public native long clCreateUserEvent(@Ptr long cl_context1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clRetainEvent(cl_event) */ - public int clRetainEvent(IOpenCLLibrary.cl_event cl_event1) { - return clRetainEvent(Pointer.getPeer(cl_event1)); - } - public native int clRetainEvent(@Ptr long cl_event1); - /** Original signature : cl_int clReleaseEvent(cl_event) */ - public int clReleaseEvent(IOpenCLLibrary.cl_event cl_event1) { - return clReleaseEvent(Pointer.getPeer(cl_event1)); - } - public native int clReleaseEvent(@Ptr long cl_event1); - /** Original signature : cl_int clSetUserEventStatus(cl_event, cl_int) */ - public int clSetUserEventStatus(IOpenCLLibrary.cl_event cl_event1, int cl_int1) { - return clSetUserEventStatus(Pointer.getPeer(cl_event1), cl_int1); - } - @Optional - public native int clSetUserEventStatus(@Ptr long cl_event1, int cl_int1); - /** Original signature : cl_int clSetEventCallback(cl_event, cl_int, clSetEventCallback_arg1_callback*, void*) */ - public int clSetEventCallback(IOpenCLLibrary.cl_event cl_event1, int cl_int1, Pointer arg1, Pointer voidPtr1) { - return clSetEventCallback(Pointer.getPeer(cl_event1), cl_int1, Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1)); - } - @Optional - public native int clSetEventCallback(@Ptr long cl_event1, int cl_int1, @Ptr long arg1, @Ptr long voidPtr1); + * Original signature : cl_int clWaitForEvents(cl_uint, const cl_event*)
    + * @see Khronos Documentation for clWaitForEvents
    + * @deprecated use the safer method {@link #clWaitForEvents(int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clWaitForEvents(int cl_uint1, PointerByReference cl_eventPtr1); + /** + * Event Object APIs
    + * Original signature : cl_int clWaitForEvents(cl_uint, const cl_event*)
    + * @see Khronos Documentation for clWaitForEvents + */ + int clWaitForEvents(int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[]); + /** + * Original signature : cl_int clGetEventInfo(cl_event, cl_event_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetEventInfo + */ + int clGetEventInfo(OpenCLLibrary.cl_event cl_event1, int cl_event_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Original signature : cl_event clCreateUserEvent(cl_context, cl_int*)
    + * @see Khronos Documentation for clCreateUserEvent
    + * @deprecated use the safer methods {@link #clCreateUserEvent(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, java.nio.IntBuffer)} and {@link #clCreateUserEvent(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_event clCreateUserEvent(OpenCLLibrary.cl_context cl_context1, IntByReference cl_intPtr1); + /** + * Original signature : cl_event clCreateUserEvent(cl_context, cl_int*)
    + * @see Khronos Documentation for clCreateUserEvent + */ + OpenCLLibrary.cl_event clCreateUserEvent(OpenCLLibrary.cl_context cl_context1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_int clRetainEvent(cl_event)
    + * @see Khronos Documentation for clRetainEvent + */ + int clRetainEvent(OpenCLLibrary.cl_event cl_event1); + /** + * Original signature : cl_int clReleaseEvent(cl_event)
    + * @see Khronos Documentation for clReleaseEvent + */ + int clReleaseEvent(OpenCLLibrary.cl_event cl_event1); + /** + * Original signature : cl_int clSetUserEventStatus(cl_event, cl_int)
    + * @see Khronos Documentation for clSetUserEventStatus + */ + int clSetUserEventStatus(OpenCLLibrary.cl_event cl_event1, int cl_int1); + /** + * Original signature : cl_int clSetEventCallback(cl_event, cl_int, clSetEventCallback_arg1_callback, void*)
    + * @see Khronos Documentation for clSetEventCallback + */ + int clSetEventCallback(OpenCLLibrary.cl_event cl_event1, int cl_int1, OpenCLLibrary.clSetEventCallback_arg1_callback arg1, Pointer voidPtr1); /** * Profiling APIs
    - * Original signature : cl_int clGetEventProfilingInfo(cl_event, cl_profiling_info, size_t, void*, size_t*) + * Original signature : cl_int clGetEventProfilingInfo(cl_event, cl_profiling_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetEventProfilingInfo */ - public int clGetEventProfilingInfo(IOpenCLLibrary.cl_event cl_event1, int cl_profiling_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetEventProfilingInfo(Pointer.getPeer(cl_event1), cl_profiling_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetEventProfilingInfo(@Ptr long cl_event1, int cl_profiling_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); + int clGetEventProfilingInfo(OpenCLLibrary.cl_event cl_event1, int cl_profiling_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); /** * Flush and Finish APIs
    - * Original signature : cl_int clFlush(cl_command_queue) - */ - public int clFlush(IOpenCLLibrary.cl_command_queue cl_command_queue1) { - return clFlush(Pointer.getPeer(cl_command_queue1)); - } - public native int clFlush(@Ptr long cl_command_queue1); - /** Original signature : cl_int clFinish(cl_command_queue) */ - public int clFinish(IOpenCLLibrary.cl_command_queue cl_command_queue1) { - return clFinish(Pointer.getPeer(cl_command_queue1)); - } - public native int clFinish(@Ptr long cl_command_queue1); + * Original signature : cl_int clFlush(cl_command_queue)
    + * @see Khronos Documentation for clFlush + */ + int clFlush(OpenCLLibrary.cl_command_queue cl_command_queue1); + /** + * Original signature : cl_int clFinish(cl_command_queue)
    + * @see Khronos Documentation for clFinish + */ + int clFinish(OpenCLLibrary.cl_command_queue cl_command_queue1); + /** + * Enqueued Commands APIs
    + * Original signature : cl_int clEnqueueReadBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadBuffer
    + * @deprecated use the safer method {@link #clEnqueueReadBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueReadBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); /** * Enqueued Commands APIs
    - * Original signature : cl_int clEnqueueReadBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*) - */ - public int clEnqueueReadBuffer(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, @Ptr long size_t1, @Ptr long size_t2, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueReadBuffer(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, size_t1, size_t2, Pointer.getPeer(voidPtr1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueReadBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueReadBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueReadBufferRect(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueReadBufferRect(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), Pointer.getPeer(size_tPtr3), size_t1, size_t2, size_t3, size_t4, Pointer.getPeer(voidPtr1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueReadBufferRect(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueWriteBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueWriteBuffer(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, @Ptr long size_t1, @Ptr long size_t2, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueWriteBuffer(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, size_t1, size_t2, Pointer.getPeer(voidPtr1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueWriteBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueWriteBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueWriteBufferRect(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueWriteBufferRect(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), Pointer.getPeer(size_tPtr3), size_t1, size_t2, size_t3, size_t4, Pointer.getPeer(voidPtr1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueWriteBufferRect(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueFillBuffer(cl_command_queue, cl_mem, const void*, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueFillBuffer(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueFillBuffer(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(voidPtr1), size_t1, size_t2, size_t3, cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueFillBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueCopyBuffer(cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueCopyBuffer(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, IOpenCLLibrary.cl_mem cl_mem2, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueCopyBuffer(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(cl_mem2), size_t1, size_t2, size_t3, cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueCopyBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueCopyBufferRect(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueCopyBufferRect(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, IOpenCLLibrary.cl_mem cl_mem2, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueCopyBufferRect(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(cl_mem2), Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), Pointer.getPeer(size_tPtr3), size_t1, size_t2, size_t3, size_t4, cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueCopyBufferRect(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueReadImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueReadImage(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, Pointer size_tPtr1, Pointer size_tPtr2, @Ptr long size_t1, @Ptr long size_t2, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueReadImage(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), size_t1, size_t2, Pointer.getPeer(voidPtr1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueReadImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueWriteImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueWriteImage(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, Pointer size_tPtr1, Pointer size_tPtr2, @Ptr long size_t1, @Ptr long size_t2, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueWriteImage(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), size_t1, size_t2, Pointer.getPeer(voidPtr1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueWriteImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_t1, @Ptr long size_t2, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueFillImage(cl_command_queue, cl_mem, const void*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueFillImage(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1, Pointer size_tPtr1, Pointer size_tPtr2, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueFillImage(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueFillImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long voidPtr1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueCopyImage(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueCopyImage(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, IOpenCLLibrary.cl_mem cl_mem2, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueCopyImage(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(cl_mem2), Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), Pointer.getPeer(size_tPtr3), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueCopyImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueCopyImageToBuffer(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, size_t, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueCopyImageToBuffer(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, IOpenCLLibrary.cl_mem cl_mem2, Pointer size_tPtr1, Pointer size_tPtr2, @Ptr long size_t1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueCopyImageToBuffer(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(cl_mem2), Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), size_t1, cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueCopyImageToBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_t1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueCopyBufferToImage(cl_command_queue, cl_mem, cl_mem, size_t, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueCopyBufferToImage(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, IOpenCLLibrary.cl_mem cl_mem2, @Ptr long size_t1, Pointer size_tPtr1, Pointer size_tPtr2, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueCopyBufferToImage(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(cl_mem2), size_t1, Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueCopyBufferToImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long cl_mem2, @Ptr long size_t1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : void* clEnqueueMapBuffer(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint, const cl_event*, cl_event*, cl_int*) */ - public Pointer clEnqueueMapBuffer(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, @Ptr long size_t1, @Ptr long size_t2, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2, Pointer cl_intPtr1) { - return Pointer.pointerToAddress(clEnqueueMapBuffer(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, cl_map_flags1, size_t1, size_t2, cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clEnqueueMapBuffer(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, long cl_map_flags1, @Ptr long size_t1, @Ptr long size_t2, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2, @Ptr long cl_intPtr1); - /** Original signature : void* clEnqueueMapImage(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t*, const size_t*, size_t*, size_t*, cl_uint, const cl_event*, cl_event*, cl_int*) */ - public Pointer clEnqueueMapImage(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, Pointer size_tPtr4, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2, Pointer cl_intPtr1) { - return Pointer.pointerToAddress(clEnqueueMapImage(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), cl_bool1, cl_map_flags1, Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), Pointer.getPeer(size_tPtr3), Pointer.getPeer(size_tPtr4), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clEnqueueMapImage(@Ptr long cl_command_queue1, @Ptr long cl_mem1, int cl_bool1, long cl_map_flags1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, @Ptr long size_tPtr4, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2, @Ptr long cl_intPtr1); - /** Original signature : cl_int clEnqueueUnmapMemObject(cl_command_queue, cl_mem, void*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueUnmapMemObject(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueUnmapMemObject(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_mem1), Pointer.getPeer(voidPtr1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueUnmapMemObject(@Ptr long cl_command_queue1, @Ptr long cl_mem1, @Ptr long voidPtr1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueMigrateMemObjects(cl_command_queue, cl_uint, const cl_mem*, cl_mem_migration_flags, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueMigrateMemObjects(IOpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_memPtr1, long cl_mem_migration_flags1, int cl_uint2, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueMigrateMemObjects(Pointer.getPeer(cl_command_queue1), cl_uint1, Pointer.getPeer(cl_memPtr1), cl_mem_migration_flags1, cl_uint2, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueMigrateMemObjects(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_memPtr1, long cl_mem_migration_flags1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueNDRangeKernel(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, int cl_uint2, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueNDRangeKernel(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_kernel1), cl_uint1, Pointer.getPeer(size_tPtr1), Pointer.getPeer(size_tPtr2), Pointer.getPeer(size_tPtr3), cl_uint2, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueNDRangeKernel(@Ptr long cl_command_queue1, @Ptr long cl_kernel1, int cl_uint1, @Ptr long size_tPtr1, @Ptr long size_tPtr2, @Ptr long size_tPtr3, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueTask(cl_command_queue, cl_kernel, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueTask(IOpenCLLibrary.cl_command_queue cl_command_queue1, IOpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueTask(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_kernel1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueTask(@Ptr long cl_command_queue1, @Ptr long cl_kernel1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueNativeKernel(cl_command_queue, clEnqueueNativeKernel_arg1_callback*, void*, size_t, cl_uint, const cl_mem*, const void**, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueNativeKernel(IOpenCLLibrary.cl_command_queue cl_command_queue1, Pointer arg1, Pointer voidPtr1, @Ptr long size_t1, int cl_uint1, Pointer cl_memPtr1, Pointer > voidPtrPtr1, int cl_uint2, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueNativeKernel(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1), size_t1, cl_uint1, Pointer.getPeer(cl_memPtr1), Pointer.getPeer(voidPtrPtr1), cl_uint2, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueNativeKernel(@Ptr long cl_command_queue1, @Ptr long arg1, @Ptr long voidPtr1, @Ptr long size_t1, int cl_uint1, @Ptr long cl_memPtr1, @Ptr long voidPtrPtr1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueMarkerWithWaitList(cl_command_queue, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueMarkerWithWaitList(IOpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueMarkerWithWaitList(Pointer.getPeer(cl_command_queue1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueMarkerWithWaitList(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueBarrierWithWaitList(cl_command_queue, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueBarrierWithWaitList(IOpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueBarrierWithWaitList(Pointer.getPeer(cl_command_queue1), cl_uint1, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - @Optional - public native int clEnqueueBarrierWithWaitList(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clSetPrintfCallback(cl_context, clSetPrintfCallback_arg1_callback*, void*) */ - public int clSetPrintfCallback(IOpenCLLibrary.cl_context cl_context1, Pointer arg1, Pointer voidPtr1) { - return clSetPrintfCallback(Pointer.getPeer(cl_context1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1)); - } - @Optional - public native int clSetPrintfCallback(@Ptr long cl_context1, @Ptr long arg1, @Ptr long voidPtr1); + * Original signature : cl_int clEnqueueReadBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadBuffer + */ + int clEnqueueReadBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueReadBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadBufferRect
    + * @deprecated use the safer methods {@link #clEnqueueReadBufferRect(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueReadBufferRect(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueReadBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, Pointer voidPtr1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueReadBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadBufferRect + */ + int clEnqueueReadBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_tPtr3[], NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueReadBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadBufferRect + */ + int clEnqueueReadBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueWriteBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteBuffer
    + * @deprecated use the safer method {@link #clEnqueueWriteBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueWriteBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueWriteBuffer(cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteBuffer + */ + int clEnqueueWriteBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueWriteBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteBufferRect
    + * @deprecated use the safer methods {@link #clEnqueueWriteBufferRect(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueWriteBufferRect(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueWriteBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, Pointer voidPtr1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueWriteBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteBufferRect + */ + int clEnqueueWriteBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_tPtr3[], NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueWriteBufferRect(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteBufferRect + */ + int clEnqueueWriteBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyBuffer(cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBuffer
    + * @deprecated use the safer method {@link #clEnqueueCopyBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueCopyBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueCopyBuffer(cl_command_queue, cl_mem, cl_mem, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBuffer + */ + int clEnqueueCopyBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyBufferRect(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBufferRect
    + * @deprecated use the safer methods {@link #clEnqueueCopyBufferRect(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueCopyBufferRect(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueCopyBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueCopyBufferRect(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBufferRect + */ + int clEnqueueCopyBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_tPtr3[], NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyBufferRect(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, size_t, size_t, size_t, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBufferRect + */ + int clEnqueueCopyBufferRect(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSize size_t1, NativeSize size_t2, NativeSize size_t3, NativeSize size_t4, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueReadImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadImage
    + * @deprecated use the safer methods {@link #clEnqueueReadImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueReadImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueReadImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueReadImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadImage + */ + int clEnqueueReadImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueReadImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReadImage + */ + int clEnqueueReadImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueWriteImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteImage
    + * @deprecated use the safer methods {@link #clEnqueueWriteImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueWriteImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueWriteImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueWriteImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteImage + */ + int clEnqueueWriteImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueWriteImage(cl_command_queue, cl_mem, cl_bool, const size_t*, const size_t*, size_t, size_t, const void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueWriteImage + */ + int clEnqueueWriteImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSize size_t1, NativeSize size_t2, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyImage(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyImage
    + * @deprecated use the safer methods {@link #clEnqueueCopyImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueCopyImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueCopyImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueCopyImage(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyImage + */ + int clEnqueueCopyImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_tPtr3[], int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyImage(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyImage + */ + int clEnqueueCopyImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyImageToBuffer(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyImageToBuffer
    + * @deprecated use the safer methods {@link #clEnqueueCopyImageToBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueCopyImageToBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueCopyImageToBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSize size_t1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueCopyImageToBuffer(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyImageToBuffer + */ + int clEnqueueCopyImageToBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_t1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyImageToBuffer(cl_command_queue, cl_mem, cl_mem, const size_t*, const size_t*, size_t, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyImageToBuffer + */ + int clEnqueueCopyImageToBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSize size_t1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyBufferToImage(cl_command_queue, cl_mem, cl_mem, size_t, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBufferToImage
    + * @deprecated use the safer methods {@link #clEnqueueCopyBufferToImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueCopyBufferToImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueCopyBufferToImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_t1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueCopyBufferToImage(cl_command_queue, cl_mem, cl_mem, size_t, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBufferToImage + */ + int clEnqueueCopyBufferToImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_t1, NativeSize size_tPtr1[], NativeSize size_tPtr2[], int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueCopyBufferToImage(cl_command_queue, cl_mem, cl_mem, size_t, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueCopyBufferToImage + */ + int clEnqueueCopyBufferToImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.cl_mem cl_mem2, NativeSize size_t1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : void* clEnqueueMapBuffer(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint, const cl_event*, cl_event*, cl_int*)
    + * @see Khronos Documentation for clEnqueueMapBuffer
    + * @deprecated use the safer methods {@link #clEnqueueMapBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, long, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], java.nio.IntBuffer)} and {@link #clEnqueueMapBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, long, com.ochafik.lang.jnaerator.runtime.NativeSize, com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + Pointer clEnqueueMapBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, NativeSize size_t1, NativeSize size_t2, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2, IntByReference cl_intPtr1); + /** + * Original signature : void* clEnqueueMapBuffer(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint, const cl_event*, cl_event*, cl_int*)
    + * @see Khronos Documentation for clEnqueueMapBuffer + */ + Pointer clEnqueueMapBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, NativeSize size_t1, NativeSize size_t2, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[], IntBuffer cl_intPtr1); + /** + * Original signature : void* clEnqueueMapBuffer(cl_command_queue, cl_mem, cl_bool, cl_map_flags, size_t, size_t, cl_uint, const cl_event*, cl_event*, cl_int*)
    + * @see Khronos Documentation for clEnqueueMapBuffer + */ + Pointer clEnqueueMapBuffer(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, NativeSize size_t1, NativeSize size_t2, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[], IntByReference cl_intPtr1); + /** + * Original signature : void* clEnqueueMapImage(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t*, const size_t*, size_t*, size_t*, cl_uint, const cl_event*, cl_event*, cl_int*)
    + * @see Khronos Documentation for clEnqueueMapImage
    + * @deprecated use the safer methods {@link #clEnqueueMapImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, long, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], java.nio.IntBuffer)} and {@link #clEnqueueMapImage(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, int, long, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + Pointer clEnqueueMapImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSizeByReference size_tPtr4, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2, IntByReference cl_intPtr1); + /** + * Original signature : void* clEnqueueMapImage(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t*, const size_t*, size_t*, size_t*, cl_uint, const cl_event*, cl_event*, cl_int*)
    + * @see Khronos Documentation for clEnqueueMapImage + */ + Pointer clEnqueueMapImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSizeByReference size_tPtr3, NativeSizeByReference size_tPtr4, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[], IntBuffer cl_intPtr1); + /** + * Original signature : void* clEnqueueMapImage(cl_command_queue, cl_mem, cl_bool, cl_map_flags, const size_t*, const size_t*, size_t*, size_t*, cl_uint, const cl_event*, cl_event*, cl_int*)
    + * @see Khronos Documentation for clEnqueueMapImage + */ + Pointer clEnqueueMapImage(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, int cl_bool1, long cl_map_flags1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, NativeSizeByReference size_tPtr4, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[], IntByReference cl_intPtr1); + /** + * Original signature : cl_int clEnqueueUnmapMemObject(cl_command_queue, cl_mem, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueUnmapMemObject
    + * @deprecated use the safer method {@link #clEnqueueUnmapMemObject(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.sun.jna.Pointer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueUnmapMemObject(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueUnmapMemObject(cl_command_queue, cl_mem, void*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueUnmapMemObject + */ + int clEnqueueUnmapMemObject(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_mem cl_mem1, Pointer voidPtr1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueNDRangeKernel
    + * @deprecated use the safer methods {@link #clEnqueueNDRangeKernel(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_kernel, int, com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], com.ochafik.lang.jnaerator.runtime.NativeSize[], int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} and {@link #clEnqueueNDRangeKernel(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_kernel, int, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, com.ochafik.lang.jnaerator.runtime.NativeSizeByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueNDRangeKernel(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, int cl_uint2, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueNDRangeKernel + */ + int clEnqueueNDRangeKernel(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, NativeSize size_tPtr1[], NativeSize size_tPtr2[], NativeSize size_tPtr3[], int cl_uint2, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueNDRangeKernel(cl_command_queue, cl_kernel, cl_uint, const size_t*, const size_t*, const size_t*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueNDRangeKernel + */ + int clEnqueueNDRangeKernel(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, NativeSizeByReference size_tPtr1, NativeSizeByReference size_tPtr2, NativeSizeByReference size_tPtr3, int cl_uint2, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueTask(cl_command_queue, cl_kernel, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueTask
    + * @deprecated use the safer method {@link #clEnqueueTask(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_kernel, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueTask(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueTask(cl_command_queue, cl_kernel, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueTask + */ + int clEnqueueTask(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_kernel cl_kernel1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueNativeKernel(cl_command_queue, user_func, void*, size_t, cl_uint, const cl_mem*, const void**, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueNativeKernel
    + * @deprecated use the safer method {@link #clEnqueueNativeKernel(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.user_func, com.sun.jna.Pointer, com.ochafik.lang.jnaerator.runtime.NativeSize, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem[], com.sun.jna.ptr.PointerByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueNativeKernel(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.user_func arg1, Pointer voidPtr1, NativeSize size_t1, int cl_uint1, PointerByReference cl_memPtr1, PointerByReference voidPtrPtr1, int cl_uint2, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueNativeKernel(cl_command_queue, user_func, void*, size_t, cl_uint, const cl_mem*, const void**, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueNativeKernel + */ + int clEnqueueNativeKernel(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.user_func arg1, Pointer voidPtr1, NativeSize size_t1, int cl_uint1, OpenCLLibrary.cl_mem cl_memPtr1[], PointerByReference voidPtrPtr1, int cl_uint2, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueMarker(cl_command_queue, cl_event*)
    + * @see Khronos Documentation for clEnqueueMarker
    + * @deprecated use the safer method {@link #clEnqueueMarker(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueMarker(OpenCLLibrary.cl_command_queue cl_command_queue1, PointerByReference cl_eventPtr1); + /** + * Original signature : cl_int clEnqueueMarker(cl_command_queue, cl_event*)
    + * @see Khronos Documentation for clEnqueueMarker + */ + int clEnqueueMarker(OpenCLLibrary.cl_command_queue cl_command_queue1, OpenCLLibrary.cl_event cl_eventPtr1[]); + /** + * Original signature : cl_int clEnqueueWaitForEvents(cl_command_queue, cl_uint, const cl_event*)
    + * @see Khronos Documentation for clEnqueueWaitForEvents
    + * @deprecated use the safer method {@link #clEnqueueWaitForEvents(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueWaitForEvents(OpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, PointerByReference cl_eventPtr1); + /** + * Original signature : cl_int clEnqueueWaitForEvents(cl_command_queue, cl_uint, const cl_event*)
    + * @see Khronos Documentation for clEnqueueWaitForEvents + */ + int clEnqueueWaitForEvents(OpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, OpenCLLibrary.cl_event cl_eventPtr1[]); + /** + * Original signature : cl_int clEnqueueBarrier(cl_command_queue)
    + * @see Khronos Documentation for clEnqueueBarrier + */ + int clEnqueueBarrier(OpenCLLibrary.cl_command_queue cl_command_queue1); + /** + * Extension function access
    + * * Returns the extension function address for the given function name,
    + * or NULL if a valid function can not be found. The client must
    + * check to make sure the address is not NULL, before using or
    + * calling the returned function address.
    + * func_name
    + * Original signature : void* clGetExtensionFunctionAddress(const char*)
    + * @see Khronos Documentation for clGetExtensionFunctionAddress
    + * @deprecated use the safer methods {@link #clGetExtensionFunctionAddress(java.lang.String)} and {@link #clGetExtensionFunctionAddress(com.sun.jna.Pointer)} instead + */ + @java.lang.Deprecated + Pointer clGetExtensionFunctionAddress(Pointer charPtr1); /** * Extension function access
    - * Returns the extension function address for the given function name,
    + * * Returns the extension function address for the given function name,
    * or NULL if a valid function can not be found. The client must
    * check to make sure the address is not NULL, before using or
    * calling the returned function address.
    - * Original signature : void* clGetExtensionFunctionAddressForPlatform(cl_platform_id, const char*) - */ - public Pointer clGetExtensionFunctionAddressForPlatform(IOpenCLLibrary.cl_platform_id cl_platform_id1, Pointer charPtr1) { - return Pointer.pointerToAddress(clGetExtensionFunctionAddressForPlatform(Pointer.getPeer(cl_platform_id1), Pointer.getPeer(charPtr1))); - } - @Ptr - @Optional - public native long clGetExtensionFunctionAddressForPlatform(@Ptr long cl_platform_id1, @Ptr long charPtr1); - /** Original signature : cl_int clSetCommandQueueProperty(cl_command_queue, cl_command_queue_properties, cl_bool, cl_command_queue_properties*) */ - public int clSetCommandQueueProperty(IOpenCLLibrary.cl_command_queue cl_command_queue1, long cl_command_queue_properties1, int cl_bool1, Pointer cl_command_queue_propertiesPtr1) { - return clSetCommandQueueProperty(Pointer.getPeer(cl_command_queue1), cl_command_queue_properties1, cl_bool1, Pointer.getPeer(cl_command_queue_propertiesPtr1)); - } - public native int clSetCommandQueueProperty(@Ptr long cl_command_queue1, long cl_command_queue_properties1, int cl_bool1, @Ptr long cl_command_queue_propertiesPtr1); - /** Original signature : cl_mem clCreateImage2D(cl_context, cl_mem_flags, const cl_image_format*, size_t, size_t, size_t, void*, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateImage2D(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, Pointer cl_image_formatPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateImage2D(Pointer.getPeer(cl_context1), cl_mem_flags1, Pointer.getPeer(cl_image_formatPtr1), size_t1, size_t2, size_t3, Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateImage2D(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long cl_image_formatPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_mem clCreateImage3D(cl_context, cl_mem_flags, const cl_image_format*, size_t, size_t, size_t, size_t, size_t, void*, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateImage3D(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, Pointer cl_image_formatPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, @Ptr long size_t5, Pointer voidPtr1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateImage3D(Pointer.getPeer(cl_context1), cl_mem_flags1, Pointer.getPeer(cl_image_formatPtr1), size_t1, size_t2, size_t3, size_t4, size_t5, Pointer.getPeer(voidPtr1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateImage3D(@Ptr long cl_context1, long cl_mem_flags1, @Ptr long cl_image_formatPtr1, @Ptr long size_t1, @Ptr long size_t2, @Ptr long size_t3, @Ptr long size_t4, @Ptr long size_t5, @Ptr long voidPtr1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clEnqueueMarker(cl_command_queue, cl_event*) */ - public int clEnqueueMarker(IOpenCLLibrary.cl_command_queue cl_command_queue1, Pointer cl_eventPtr1) { - return clEnqueueMarker(Pointer.getPeer(cl_command_queue1), Pointer.getPeer(cl_eventPtr1)); - } - public native int clEnqueueMarker(@Ptr long cl_command_queue1, @Ptr long cl_eventPtr1); - /** Original signature : cl_int clEnqueueWaitForEvents(cl_command_queue, cl_uint, const cl_event*) */ - public int clEnqueueWaitForEvents(IOpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_eventPtr1) { - return clEnqueueWaitForEvents(Pointer.getPeer(cl_command_queue1), cl_uint1, Pointer.getPeer(cl_eventPtr1)); - } - public native int clEnqueueWaitForEvents(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_eventPtr1); - /** Original signature : cl_int clEnqueueBarrier(cl_command_queue) */ - public int clEnqueueBarrier(IOpenCLLibrary.cl_command_queue cl_command_queue1) { - return clEnqueueBarrier(Pointer.getPeer(cl_command_queue1)); - } - public native int clEnqueueBarrier(@Ptr long cl_command_queue1); - /** Original signature : cl_int clUnloadCompiler() */ - public native int clUnloadCompiler(); - /** Original signature : void* clGetExtensionFunctionAddress(const char*) */ - public Pointer clGetExtensionFunctionAddress(Pointer charPtr1) { - return Pointer.pointerToAddress(clGetExtensionFunctionAddress(Pointer.getPeer(charPtr1))); - } - @Ptr - public native long clGetExtensionFunctionAddress(@Ptr long charPtr1); - /** - * cl_gl_texture_info
    - * Original signature : cl_mem clCreateFromGLBuffer(cl_context, cl_mem_flags, cl_GLuint, int*) - */ - public IOpenCLLibrary.cl_mem clCreateFromGLBuffer(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLuint1, Pointer intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateFromGLBuffer(Pointer.getPeer(cl_context1), cl_mem_flags1, cl_GLuint1, Pointer.getPeer(intPtr1))); - } - @Ptr - public native long clCreateFromGLBuffer(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLuint1, @Ptr long intPtr1); - /** Original signature : cl_mem clCreateFromGLTexture(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateFromGLTexture(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateFromGLTexture(Pointer.getPeer(cl_context1), cl_mem_flags1, cl_GLenum1, cl_GLint1, cl_GLuint1, Pointer.getPeer(cl_intPtr1))); - } - @Ptr - @Optional - public native long clCreateFromGLTexture(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, @Ptr long cl_intPtr1); - /** Original signature : cl_mem clCreateFromGLRenderbuffer(cl_context, cl_mem_flags, cl_GLuint, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateFromGLRenderbuffer(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLuint1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateFromGLRenderbuffer(Pointer.getPeer(cl_context1), cl_mem_flags1, cl_GLuint1, Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateFromGLRenderbuffer(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLuint1, @Ptr long cl_intPtr1); - /** Original signature : cl_int clGetGLObjectInfo(cl_mem, cl_gl_object_type*, cl_GLuint*) */ - public int clGetGLObjectInfo(IOpenCLLibrary.cl_mem cl_mem1, Pointer cl_gl_object_typePtr1, Pointer cl_GLuintPtr1) { - return clGetGLObjectInfo(Pointer.getPeer(cl_mem1), Pointer.getPeer(cl_gl_object_typePtr1), Pointer.getPeer(cl_GLuintPtr1)); - } - public native int clGetGLObjectInfo(@Ptr long cl_mem1, @Ptr long cl_gl_object_typePtr1, @Ptr long cl_GLuintPtr1); - /** Original signature : cl_int clGetGLTextureInfo(cl_mem, cl_gl_texture_info, size_t, void*, size_t*) */ - public int clGetGLTextureInfo(IOpenCLLibrary.cl_mem cl_mem1, int cl_gl_texture_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetGLTextureInfo(Pointer.getPeer(cl_mem1), cl_gl_texture_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - public native int clGetGLTextureInfo(@Ptr long cl_mem1, int cl_gl_texture_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** Original signature : cl_int clEnqueueAcquireGLObjects(cl_command_queue, cl_uint, const cl_mem*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueAcquireGLObjects(IOpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_memPtr1, int cl_uint2, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueAcquireGLObjects(Pointer.getPeer(cl_command_queue1), cl_uint1, Pointer.getPeer(cl_memPtr1), cl_uint2, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueAcquireGLObjects(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_memPtr1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_int clEnqueueReleaseGLObjects(cl_command_queue, cl_uint, const cl_mem*, cl_uint, const cl_event*, cl_event*) */ - public int clEnqueueReleaseGLObjects(IOpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_memPtr1, int cl_uint2, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - return clEnqueueReleaseGLObjects(Pointer.getPeer(cl_command_queue1), cl_uint1, Pointer.getPeer(cl_memPtr1), cl_uint2, Pointer.getPeer(cl_eventPtr1), Pointer.getPeer(cl_eventPtr2)); - } - public native int clEnqueueReleaseGLObjects(@Ptr long cl_command_queue1, int cl_uint1, @Ptr long cl_memPtr1, int cl_uint2, @Ptr long cl_eventPtr1, @Ptr long cl_eventPtr2); - /** Original signature : cl_mem clCreateFromGLTexture2D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateFromGLTexture2D(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateFromGLTexture2D(Pointer.getPeer(cl_context1), cl_mem_flags1, cl_GLenum1, cl_GLint1, cl_GLuint1, Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateFromGLTexture2D(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, @Ptr long cl_intPtr1); - /** Original signature : cl_mem clCreateFromGLTexture3D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int*) */ - public IOpenCLLibrary.cl_mem clCreateFromGLTexture3D(IOpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_mem(clCreateFromGLTexture3D(Pointer.getPeer(cl_context1), cl_mem_flags1, cl_GLenum1, cl_GLint1, cl_GLuint1, Pointer.getPeer(cl_intPtr1))); - } - @Ptr - public native long clCreateFromGLTexture3D(@Ptr long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, @Ptr long cl_intPtr1); - /** - * Additional cl_context_properties
    - * Original signature : cl_int clGetGLContextInfoKHR(const cl_context_properties*, cl_gl_context_info, size_t, void*, size_t*) - */ - public int clGetGLContextInfoKHR(Pointer cl_context_propertiesPtr1, int cl_gl_context_info1, @Ptr long size_t1, Pointer voidPtr1, Pointer size_tPtr1) { - return clGetGLContextInfoKHR(Pointer.getPeer(cl_context_propertiesPtr1), cl_gl_context_info1, size_t1, Pointer.getPeer(voidPtr1), Pointer.getPeer(size_tPtr1)); - } - @Optional - public native int clGetGLContextInfoKHR(@Ptr long cl_context_propertiesPtr1, int cl_gl_context_info1, @Ptr long size_t1, @Ptr long voidPtr1, @Ptr long size_tPtr1); - /** - * cl_khr_gl_event extension
    - * See section 9.9 in the OpenCL 1.1 spec for more information
    - * Original signature : cl_event clCreateEventFromGLsyncKHR(cl_context, cl_GLsync, cl_int*) - */ - public IOpenCLLibrary.cl_event clCreateEventFromGLsyncKHR(IOpenCLLibrary.cl_context cl_context1, IOpenCLLibrary.cl_GLsync cl_GLsync1, Pointer cl_intPtr1) { - return new IOpenCLLibrary.cl_event(clCreateEventFromGLsyncKHR(Pointer.getPeer(cl_context1), Pointer.getPeer(cl_GLsync1), Pointer.getPeer(cl_intPtr1))); - } - @Ptr - @Optional - public native long clCreateEventFromGLsyncKHR(@Ptr long cl_context1, @Ptr long cl_GLsync1, @Ptr long cl_intPtr1); - /** - * Memory object destruction
    - * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
    - * Registers a user callback function that will be called when the memory object is deleted and its resources
    - * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
    - * stack associated with memobj. The registered user callback functions are called in the reverse order in
    - * which they were registered. The user callback functions are called and then the memory object is deleted
    - * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
    - * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
    - * the storage bits for the memory object, can be reused or freed.
    - * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
    - * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
    - * before using.
    + * func_name
    + * Original signature : void* clGetExtensionFunctionAddress(const char*)
    + * @see Khronos Documentation for clGetExtensionFunctionAddress + */ + Pointer clGetExtensionFunctionAddress(java.lang.String charPtr1); + /** + * Original signature : cl_mem clCreateFromGLBuffer(cl_context, cl_mem_flags, cl_GLuint, int*)
    + * @see Khronos Documentation for clCreateFromGLBuffer
    + * @deprecated use the safer methods {@link #clCreateFromGLBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, java.nio.IntBuffer)} and {@link #clCreateFromGLBuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateFromGLBuffer(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLuint1, IntByReference intPtr1); + /** + * Original signature : cl_mem clCreateFromGLBuffer(cl_context, cl_mem_flags, cl_GLuint, int*)
    + * @see Khronos Documentation for clCreateFromGLBuffer + */ + OpenCLLibrary.cl_mem clCreateFromGLBuffer(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLuint1, IntBuffer intPtr1); + /** + * Original signature : cl_mem clCreateFromGLTexture2D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int*)
    + * @see Khronos Documentation for clCreateFromGLTexture2D
    + * @deprecated use the safer methods {@link #clCreateFromGLTexture2D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, int, int, java.nio.IntBuffer)} and {@link #clCreateFromGLTexture2D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, int, int, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateFromGLTexture2D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, IntByReference cl_intPtr1); + /** + * Original signature : cl_mem clCreateFromGLTexture2D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int*)
    + * @see Khronos Documentation for clCreateFromGLTexture2D + */ + OpenCLLibrary.cl_mem clCreateFromGLTexture2D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_mem clCreateFromGLTexture3D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int*)
    + * @see Khronos Documentation for clCreateFromGLTexture3D
    + * @deprecated use the safer methods {@link #clCreateFromGLTexture3D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, int, int, java.nio.IntBuffer)} and {@link #clCreateFromGLTexture3D(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, int, int, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateFromGLTexture3D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, IntByReference cl_intPtr1); + /** + * Original signature : cl_mem clCreateFromGLTexture3D(cl_context, cl_mem_flags, cl_GLenum, cl_GLint, cl_GLuint, cl_int*)
    + * @see Khronos Documentation for clCreateFromGLTexture3D + */ + OpenCLLibrary.cl_mem clCreateFromGLTexture3D(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_mem clCreateFromGLRenderbuffer(cl_context, cl_mem_flags, cl_GLuint, cl_int*)
    + * @see Khronos Documentation for clCreateFromGLRenderbuffer
    + * @deprecated use the safer methods {@link #clCreateFromGLRenderbuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, java.nio.IntBuffer)} and {@link #clCreateFromGLRenderbuffer(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, long, int, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_mem clCreateFromGLRenderbuffer(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLuint1, IntByReference cl_intPtr1); + /** + * Original signature : cl_mem clCreateFromGLRenderbuffer(cl_context, cl_mem_flags, cl_GLuint, cl_int*)
    + * @see Khronos Documentation for clCreateFromGLRenderbuffer + */ + OpenCLLibrary.cl_mem clCreateFromGLRenderbuffer(OpenCLLibrary.cl_context cl_context1, long cl_mem_flags1, int cl_GLuint1, IntBuffer cl_intPtr1); + /** + * Original signature : cl_int clGetGLObjectInfo(cl_mem, cl_gl_object_type*, cl_GLuint*)
    + * @see Khronos Documentation for clGetGLObjectInfo
    + * @deprecated use the safer methods {@link #clGetGLObjectInfo(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #clGetGLObjectInfo(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + int clGetGLObjectInfo(OpenCLLibrary.cl_mem cl_mem1, IntByReference cl_gl_object_typePtr1, IntByReference cl_GLuintPtr1); + /** + * Original signature : cl_int clGetGLObjectInfo(cl_mem, cl_gl_object_type*, cl_GLuint*)
    + * @see Khronos Documentation for clGetGLObjectInfo + */ + int clGetGLObjectInfo(OpenCLLibrary.cl_mem cl_mem1, IntBuffer cl_gl_object_typePtr1, IntBuffer cl_GLuintPtr1); + /** + * Original signature : cl_int clGetGLTextureInfo(cl_mem, cl_gl_texture_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetGLTextureInfo + */ + int clGetGLTextureInfo(OpenCLLibrary.cl_mem cl_mem1, int cl_gl_texture_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Original signature : cl_int clEnqueueAcquireGLObjects(cl_command_queue, cl_uint, const cl_mem*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueAcquireGLObjects
    + * @deprecated use the safer method {@link #clEnqueueAcquireGLObjects(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem[], int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueAcquireGLObjects(OpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, PointerByReference cl_memPtr1, int cl_uint2, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueAcquireGLObjects(cl_command_queue, cl_uint, const cl_mem*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueAcquireGLObjects + */ + int clEnqueueAcquireGLObjects(OpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, OpenCLLibrary.cl_mem cl_memPtr1[], int cl_uint2, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clEnqueueReleaseGLObjects(cl_command_queue, cl_uint, const cl_mem*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReleaseGLObjects
    + * @deprecated use the safer method {@link #clEnqueueReleaseGLObjects(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_command_queue, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_mem[], int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[], com.nativelibs4java.opencl.library.OpenCLLibrary.cl_event[])} instead + */ + @java.lang.Deprecated + int clEnqueueReleaseGLObjects(OpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, PointerByReference cl_memPtr1, int cl_uint2, PointerByReference cl_eventPtr1, PointerByReference cl_eventPtr2); + /** + * Original signature : cl_int clEnqueueReleaseGLObjects(cl_command_queue, cl_uint, const cl_mem*, cl_uint, const cl_event*, cl_event*)
    + * @see Khronos Documentation for clEnqueueReleaseGLObjects + */ + int clEnqueueReleaseGLObjects(OpenCLLibrary.cl_command_queue cl_command_queue1, int cl_uint1, OpenCLLibrary.cl_mem cl_memPtr1[], int cl_uint2, OpenCLLibrary.cl_event cl_eventPtr1[], OpenCLLibrary.cl_event cl_eventPtr2[]); + /** + * Original signature : cl_int clGetGLContextInfoKHR(const cl_context_properties*, cl_gl_context_info, size_t, void*, size_t*)
    + * @see Khronos Documentation for clGetGLContextInfoKHR + */ + int clGetGLContextInfoKHR(NativeSizeByReference cl_context_propertiesPtr1, int cl_gl_context_info1, NativeSize size_t1, Pointer voidPtr1, NativeSizeByReference size_tPtr1); + /** + * Original signature : cl_event clCreateEventFromGLsyncKHR(cl_context, cl_GLsync, cl_int*)
    + * @see Khronos Documentation for clCreateEventFromGLsyncKHR
    + * @deprecated use the safer methods {@link #clCreateEventFromGLsyncKHR(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, com.nativelibs4java.opencl.library.OpenCLLibrary.__GLsync, java.nio.IntBuffer)} and {@link #clCreateEventFromGLsyncKHR(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_context, com.nativelibs4java.opencl.library.OpenCLLibrary.__GLsync, com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + OpenCLLibrary.cl_event clCreateEventFromGLsyncKHR(OpenCLLibrary.cl_context cl_context1, OpenCLLibrary.__GLsync cl_GLsync1, IntByReference cl_intPtr1); + /** + * Original signature : cl_event clCreateEventFromGLsyncKHR(cl_context, cl_GLsync, cl_int*)
    + * @see Khronos Documentation for clCreateEventFromGLsyncKHR + */ + OpenCLLibrary.cl_event clCreateEventFromGLsyncKHR(OpenCLLibrary.cl_context cl_context1, OpenCLLibrary.__GLsync cl_GLsync1, IntBuffer cl_intPtr1); + public static final int CL_INVALID_GL_CONTEXT_APPLE = -1000; + /** + * context
    + * Original signature : cl_int clGetGLContextInfoAPPLE(cl_context context, void *platform_gl_ctx, cl_gl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) + */ + int clGetGLContextInfoAPPLE(cl_context context, NativeSize platform_gl_ctx, int param_name, NativeSize param_value_size, Pointer param_value, NativeSizeByReference param_value_size_ret); + /** * memobj
    - * Original signature : cl_int clSetMemObjectDestructorAPPLE(cl_mem, clSetMemObjectDestructorAPPLE_arg1_callback*, void*) - */ - public int clSetMemObjectDestructorAPPLE(IOpenCLLibrary.cl_mem cl_mem1, Pointer arg1, Pointer voidPtr1) { - return clSetMemObjectDestructorAPPLE(Pointer.getPeer(cl_mem1), Pointer.getPeer(arg1), Pointer.getPeer(voidPtr1)); - } - @Optional - public native int clSetMemObjectDestructorAPPLE(@Ptr long cl_mem1, @Ptr long arg1, @Ptr long voidPtr1); - /** - * Context Logging Functions
    - * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
    - * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
    - * before using.
    - * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
    + * Original signature : cl_int clSetMemObjectDestructorAPPLE(cl_mem, clSetMemObjectDestructorAPPLE_arg1_callback, void*) + */ + int clSetMemObjectDestructorAPPLE(OpenCLLibrary.cl_mem cl_mem1, OpenCLLibrary.clSetMemObjectDestructorAPPLE_arg1_callback arg1, Pointer voidPtr1); + /** + * errstr
    + * Original signature : void clLogMessagesToSystemLogAPPLE(const char*, const void*, size_t, void*)
    + * @deprecated use the safer methods {@link #clLogMessagesToSystemLogAPPLE(java.lang.String, com.sun.jna.Pointer, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer)} and {@link #clLogMessagesToSystemLogAPPLE(com.sun.jna.Pointer, com.sun.jna.Pointer, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer)} instead + */ + @java.lang.Deprecated + void clLogMessagesToSystemLogAPPLE(Pointer charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); + /** * errstr
    * Original signature : void clLogMessagesToSystemLogAPPLE(const char*, const void*, size_t, void*) */ - public void clLogMessagesToSystemLogAPPLE(Pointer charPtr1, Pointer voidPtr1, @Ptr long size_t1, Pointer voidPtr2) { - clLogMessagesToSystemLogAPPLE(Pointer.getPeer(charPtr1), Pointer.getPeer(voidPtr1), size_t1, Pointer.getPeer(voidPtr2)); - } - @Optional - public native void clLogMessagesToSystemLogAPPLE(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2); + void clLogMessagesToSystemLogAPPLE(java.lang.String charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); + /** + * clLogMessagesToStdout sends all log messages to the file descriptor stdout
    + * errstr
    + * Original signature : void clLogMessagesToStdoutAPPLE(const char*, const void*, size_t, void*)
    + * @deprecated use the safer methods {@link #clLogMessagesToStdoutAPPLE(java.lang.String, com.sun.jna.Pointer, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer)} and {@link #clLogMessagesToStdoutAPPLE(com.sun.jna.Pointer, com.sun.jna.Pointer, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer)} instead + */ + @java.lang.Deprecated + void clLogMessagesToStdoutAPPLE(Pointer charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); /** * clLogMessagesToStdout sends all log messages to the file descriptor stdout
    * errstr
    * Original signature : void clLogMessagesToStdoutAPPLE(const char*, const void*, size_t, void*) */ - public void clLogMessagesToStdoutAPPLE(Pointer charPtr1, Pointer voidPtr1, @Ptr long size_t1, Pointer voidPtr2) { - clLogMessagesToStdoutAPPLE(Pointer.getPeer(charPtr1), Pointer.getPeer(voidPtr1), size_t1, Pointer.getPeer(voidPtr2)); - } - @Optional - public native void clLogMessagesToStdoutAPPLE(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2); + void clLogMessagesToStdoutAPPLE(java.lang.String charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); + /** + * clLogMessagesToStderr sends all log messages to the file descriptor stderr
    + * errstr
    + * Original signature : void clLogMessagesToStderrAPPLE(const char*, const void*, size_t, void*)
    + * @deprecated use the safer methods {@link #clLogMessagesToStderrAPPLE(java.lang.String, com.sun.jna.Pointer, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer)} and {@link #clLogMessagesToStderrAPPLE(com.sun.jna.Pointer, com.sun.jna.Pointer, com.ochafik.lang.jnaerator.runtime.NativeSize, com.sun.jna.Pointer)} instead + */ + @java.lang.Deprecated + void clLogMessagesToStderrAPPLE(Pointer charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); /** * clLogMessagesToStderr sends all log messages to the file descriptor stderr
    * errstr
    * Original signature : void clLogMessagesToStderrAPPLE(const char*, const void*, size_t, void*) */ - public void clLogMessagesToStderrAPPLE(Pointer charPtr1, Pointer voidPtr1, @Ptr long size_t1, Pointer voidPtr2) { - clLogMessagesToStderrAPPLE(Pointer.getPeer(charPtr1), Pointer.getPeer(voidPtr1), size_t1, Pointer.getPeer(voidPtr2)); - } - @Optional - public native void clLogMessagesToStderrAPPLE(@Ptr long charPtr1, @Ptr long voidPtr1, @Ptr long size_t1, @Ptr long voidPtr2); - /** - * Additional Error Codes
    - * Original signature : cl_int clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id*, cl_uint*) - */ - public int clIcdGetPlatformIDsKHR(int cl_uint1, Pointer cl_platform_idPtr1, Pointer cl_uintPtr1) { - return clIcdGetPlatformIDsKHR(cl_uint1, Pointer.getPeer(cl_platform_idPtr1), Pointer.getPeer(cl_uintPtr1)); - } - @Optional - public native int clIcdGetPlatformIDsKHR(int cl_uint1, @Ptr long cl_platform_idPtr1, @Ptr long cl_uintPtr1); - /** Original signature : cl_int clReleaseDeviceEXT(cl_device_id) */ - public int clReleaseDeviceEXT(IOpenCLLibrary.cl_device_id cl_device_id1) { - return clReleaseDeviceEXT(Pointer.getPeer(cl_device_id1)); - } - @Optional - public native int clReleaseDeviceEXT(@Ptr long cl_device_id1); - /** Original signature : cl_int clRetainDeviceEXT(cl_device_id) */ - public int clRetainDeviceEXT(IOpenCLLibrary.cl_device_id cl_device_id1) { - return clRetainDeviceEXT(Pointer.getPeer(cl_device_id1)); - } - @Optional - public native int clRetainDeviceEXT(@Ptr long cl_device_id1); - /** Original signature : cl_int clCreateSubDevicesEXT(cl_device_id, const cl_device_partition_property_ext*, cl_uint, cl_device_id*, cl_uint*) */ - public int clCreateSubDevicesEXT(IOpenCLLibrary.cl_device_id cl_device_id1, Pointer cl_device_partition_property_extPtr1, int cl_uint1, Pointer cl_device_idPtr1, Pointer cl_uintPtr1) { - return clCreateSubDevicesEXT(Pointer.getPeer(cl_device_id1), Pointer.getPeer(cl_device_partition_property_extPtr1), cl_uint1, Pointer.getPeer(cl_device_idPtr1), Pointer.getPeer(cl_uintPtr1)); - } - @Optional - public native int clCreateSubDevicesEXT(@Ptr long cl_device_id1, @Ptr long cl_device_partition_property_extPtr1, int cl_uint1, @Ptr long cl_device_idPtr1, @Ptr long cl_uintPtr1); - /** - * Apple extension for retrieving OpenGL context information for a CL context
    - * created via the above method.
    - * Provides a query mechanism to retrieve OpenGL context specific information
    - * from an OpenCL context to help identify device specific mappings and usage.
    - *
    - * For example, one possible usage would be to allow the client to map a CGL
    - * virtual screen index to an appropriate CL device id to insure that the
    - * rendering device and the compute device are the same, thus guaranteeing
    - * any shared OpenGL memory that is attached o a CL memory object remains
    - * resident on the active device.
    - * context
    - * Original signature : cl_int clGetGLContextInfoAPPLE(cl_context, void*, cl_gl_platform_info, size_t, void*, size_t*) + void clLogMessagesToStderrAPPLE(java.lang.String charPtr1, Pointer voidPtr1, NativeSize size_t1, Pointer voidPtr2); + /** + * Original signature : cl_int clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id*, cl_uint*)
    + * @deprecated use the safer methods {@link #clIcdGetPlatformIDsKHR(int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_platform_id[], java.nio.IntBuffer)} and {@link #clIcdGetPlatformIDsKHR(int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_platform_id[], com.sun.jna.ptr.IntByReference)} instead + */ + @java.lang.Deprecated + int clIcdGetPlatformIDsKHR(int cl_uint1, PointerByReference cl_platform_idPtr1, IntByReference cl_uintPtr1); + /// Original signature : cl_int clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id*, cl_uint*) + int clIcdGetPlatformIDsKHR(int cl_uint1, OpenCLLibrary.cl_platform_id cl_platform_idPtr1[], IntBuffer cl_uintPtr1); + /// Original signature : cl_int clIcdGetPlatformIDsKHR(cl_uint, cl_platform_id*, cl_uint*) + int clIcdGetPlatformIDsKHR(int cl_uint1, OpenCLLibrary.cl_platform_id cl_platform_idPtr1[], IntByReference cl_uintPtr1); + /// Original signature : cl_int clReleaseDeviceEXT(cl_device_id) + int clReleaseDeviceEXT(OpenCLLibrary.cl_device_id cl_device_id1); + /// Original signature : cl_int clRetainDeviceEXT(cl_device_id) + int clRetainDeviceEXT(OpenCLLibrary.cl_device_id cl_device_id1); + /** + * Original signature : cl_int clCreateSubDevicesEXT(cl_device_id, const cl_device_partition_property_ext*, cl_uint, cl_device_id*, cl_uint*)
    + * @deprecated use the safer methods {@link #clCreateSubDevicesEXT(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id, java.nio.LongBuffer, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], java.nio.IntBuffer)} and {@link #clCreateSubDevicesEXT(com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id, com.sun.jna.ptr.LongByReference, int, com.nativelibs4java.opencl.library.OpenCLLibrary.cl_device_id[], com.sun.jna.ptr.IntByReference)} instead */ - public int clGetGLContextInfoAPPLE(IOpenCLLibrary.cl_context cl_context1, Pointer voidPtr1, int cl_gl_platform_info1, @Ptr long size_t1, Pointer voidPtr2, Pointer size_tPtr1) { - return clGetGLContextInfoAPPLE(Pointer.getPeer(cl_context1), Pointer.getPeer(voidPtr1), cl_gl_platform_info1, size_t1, Pointer.getPeer(voidPtr2), Pointer.getPeer(size_tPtr1)); - } - @Optional - public native int clGetGLContextInfoAPPLE(@Ptr long cl_context1, @Ptr long voidPtr1, int cl_gl_platform_info1, @Ptr long size_t1, @Ptr long voidPtr2, @Ptr long size_tPtr1); + @java.lang.Deprecated + int clCreateSubDevicesEXT(OpenCLLibrary.cl_device_id cl_device_id1, LongByReference cl_device_partition_property_extPtr1, int cl_uint1, PointerByReference cl_device_idPtr1, IntByReference cl_uintPtr1); + /// Original signature : cl_int clCreateSubDevicesEXT(cl_device_id, const cl_device_partition_property_ext*, cl_uint, cl_device_id*, cl_uint*) + int clCreateSubDevicesEXT(OpenCLLibrary.cl_device_id cl_device_id1, LongBuffer cl_device_partition_property_extPtr1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], IntBuffer cl_uintPtr1); + /// Original signature : cl_int clCreateSubDevicesEXT(cl_device_id, const cl_device_partition_property_ext*, cl_uint, cl_device_id*, cl_uint*) + int clCreateSubDevicesEXT(OpenCLLibrary.cl_device_id cl_device_id1, LongByReference cl_device_partition_property_extPtr1, int cl_uint1, OpenCLLibrary.cl_device_id cl_device_idPtr1[], IntByReference cl_uintPtr1); + //public static final GlobalCallback clCreateSubDevicesEXT_fn = new GlobalCallback(com.nativelibs4java.opencl.library.OpenCLLibrary.JNA_NATIVE_LIB, clCreateSubDevicesEXT_fn_callback.class, "clCreateSubDevicesEXT_fn"); + /// Pointer to unknown (opaque) type + public static class __GLsync extends PointerType { + public __GLsync(Pointer address) { + super(address); + } + public __GLsync() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_device_id extends PointerType { + public cl_device_id(Pointer address) { + super(address); + } + public cl_device_id() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_mem extends PointerType { + public cl_mem(Pointer address) { + super(address); + } + public cl_mem() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_platform_id extends PointerType { + public cl_platform_id(Pointer address) { + super(address); + } + public cl_platform_id() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_event extends PointerType { + public cl_event(Pointer address) { + super(address); + } + public cl_event() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_command_queue extends PointerType { + public cl_command_queue(Pointer address) { + super(address); + } + public cl_command_queue() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_context extends PointerType { + public cl_context(Pointer address) { + super(address); + } + public cl_context() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_sampler extends PointerType { + public cl_sampler(Pointer address) { + super(address); + } + public cl_sampler() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_program extends PointerType { + public cl_program(Pointer address) { + super(address); + } + public cl_program() { + super(); + } + }; + /// Pointer to unknown (opaque) type + public static class cl_kernel extends PointerType { + public cl_kernel(Pointer address) { + super(address); + } + public cl_kernel() { + super(); + } + }; } diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenGLContextUtils.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenGLContextUtils.java index bae97a61..f270f676 100644 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenGLContextUtils.java +++ b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/OpenGLContextUtils.java @@ -1,58 +1,43 @@ package com.nativelibs4java.opencl.library; - -import org.bridj.*; -import org.bridj.ann.*; -import static org.bridj.Pointer.*; - /** * JNA Wrapper for library OpenGL
    * This file was autogenerated by JNAerator,
    * a tool written by Olivier Chafik that uses a few opensource projects..
    * For help, please visit NativeLibs4Java, Rococoa, or JNA. */ -@Library("OpenGL") -@org.bridj.ann.Runtime(CRuntime.class) -public class OpenGLContextUtils { - static { - if (Platform.isWindows()) - BridJ.addNativeLibraryAlias("OpenGL", "OpenGL32"); // even in 64 bit mode ! - else if (Platform.isUnix() && !Platform.isMacOSX()) - BridJ.addNativeLibraryAlias("OpenGL", "GL"); - - BridJ.register(); - } +public interface OpenGLContextUtils extends com.sun.jna.Library { + public static final java.lang.String JNA_LIBRARY_NAME = + com.sun.jna.Platform.isWindows() ? "OpenGL32" : + com.sun.jna.Platform.isLinux() ? "GL" : + "OpenGL"; + //public static final java.lang.String JNA_LIBRARY_NAME = com.ochafik.lang.jnaerator.runtime.LibraryExtractor.getLibraryPath("OpenGL", true, OpenGLApple.class); + //public static final com.sun.jna.NativeLibrary JNA_NATIVE_LIB = com.sun.jna.NativeLibrary.getInstance(OpenGLApple.JNA_LIBRARY_NAME, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS); + public static final OpenGLContextUtils INSTANCE = (OpenGLContextUtils)com.sun.jna.Native.loadLibrary(JNA_LIBRARY_NAME, OpenGLContextUtils.class);//OpenGLApple.JNA_LIBRARY_NAME, OpenGLApple.class, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS); + /// Original signature : CGLShareGroupObj CGLGetShareGroup(CGLContextObj) - public static native Pointer CGLGetShareGroup(Pointer ctx); + com.ochafik.lang.jnaerator.runtime.NativeSize CGLGetShareGroup(com.ochafik.lang.jnaerator.runtime.NativeSize ctx); /** * * Current context functions
    * Original signature : CGLError CGLSetCurrentContext(CGLContextObj) */ - @Optional - public static native int CGLSetCurrentContext(Pointer ctx); + int CGLSetCurrentContext(com.sun.jna.Pointer ctx); /// Original signature : CGLContextObj CGLGetCurrentContext() - @Optional - public static native Pointer CGLGetCurrentContext(); + com.ochafik.lang.jnaerator.runtime.NativeSize CGLGetCurrentContext(); /** * * Version numbers
    * Original signature : void CGLGetVersion(GLint*, GLint*) */ - @Optional - public static native void CGLGetVersion(Pointer majorvers, Pointer minorvers); + void CGLGetVersion(java.nio.IntBuffer majorvers, java.nio.IntBuffer minorvers); /** * * Convert an error code to a string
    * Original signature : char* CGLErrorString(CGLError)
    * @param error @see CGLError */ - @Optional - public static native Pointer CGLErrorString(int error); + java.lang.String CGLErrorString(int error); - @Optional - public static native Pointer wglGetCurrentDC(); - @Optional - public static native Pointer wglGetCurrentContext(); - @Optional - public static native Pointer glXGetCurrentDisplay(); - @Optional - public static native Pointer glXGetCurrentContext(); + com.ochafik.lang.jnaerator.runtime.NativeSize wglGetCurrentDC(); + com.ochafik.lang.jnaerator.runtime.NativeSize wglGetCurrentContext(); + com.ochafik.lang.jnaerator.runtime.NativeSize glXGetCurrentDisplay(); + com.ochafik.lang.jnaerator.runtime.NativeSize glXGetCurrentContext(); } diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_buffer_region.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_buffer_region.java index 4b64b3da..f7e00d41 100644 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_buffer_region.java +++ b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_buffer_region.java @@ -1,42 +1,36 @@ package com.nativelibs4java.opencl.library; -import org.bridj.Pointer; -import org.bridj.StructObject; -import org.bridj.ann.Field; -import org.bridj.ann.Library; -import org.bridj.ann.Ptr; +import com.ochafik.lang.jnaerator.runtime.NativeSize; +import com.ochafik.lang.jnaerator.runtime.Structure; /** * This file was autogenerated by JNAerator,
    * a tool written by Olivier Chafik that uses a few opensource projects..
    - * For help, please visit NativeLibs4Java or BridJ . + * For help, please visit NativeLibs4Java , Rococoa, or JNA. */ -@Library("OpenCL") -public class cl_buffer_region extends StructObject { - @Ptr - @Field(0) - public long origin() { - return this.io.getSizeTField(this, 0); - } - @Ptr - @Field(0) - public cl_buffer_region origin(long origin) { - this.io.setSizeTField(this, 0, origin); - return this; - } - @Ptr - @Field(1) - public long size() { - return this.io.getSizeTField(this, 1); - } - @Ptr - @Field(1) - public cl_buffer_region size(long size) { - this.io.setSizeTField(this, 1, size); - return this; - } +public class cl_buffer_region extends Structure { + public NativeSize origin; + public NativeSize size; public cl_buffer_region() { super(); } - public cl_buffer_region(Pointer pointer) { - super(pointer); + public cl_buffer_region(NativeSize origin, NativeSize size) { + super(); + this.origin = origin; + this.size = size; + } + + public java.util.List getFieldOrder() { + return java.util.Arrays.asList("origin", "size"); + } + protected ByReference newByReference() { return new ByReference(); } + protected ByValue newByValue() { return new ByValue(); } + protected cl_buffer_region newInstance() { return new cl_buffer_region(); } + public static cl_buffer_region[] newArray(int arrayLength) { + return Structure.newArray(cl_buffer_region.class, arrayLength); } + public static class ByReference extends cl_buffer_region implements Structure.ByReference { + + }; + public static class ByValue extends cl_buffer_region implements Structure.ByValue { + + }; } diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_image_desc.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_image_desc.java deleted file mode 100644 index 9a94116a..00000000 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_image_desc.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.nativelibs4java.opencl.library; -import com.nativelibs4java.opencl.library.IOpenCLLibrary.cl_mem; -import org.bridj.Pointer; -import org.bridj.StructObject; -import org.bridj.ann.Field; -import org.bridj.ann.Library; -import org.bridj.ann.Ptr; -/** - * This file was autogenerated by JNAerator,
    - * a tool written by Olivier Chafik that uses a few opensource projects..
    - * For help, please visit NativeLibs4Java or BridJ . - */ -@Library("OpenCL") -public class cl_image_desc extends StructObject { - /** C type : cl_mem_object_type */ - @Field(0) - public int image_type() { - return this.io.getIntField(this, 0); - } - /** C type : cl_mem_object_type */ - @Field(0) - public cl_image_desc image_type(int image_type) { - this.io.setIntField(this, 0, image_type); - return this; - } - @Ptr - @Field(1) - public long image_width() { - return this.io.getSizeTField(this, 1); - } - @Ptr - @Field(1) - public cl_image_desc image_width(long image_width) { - this.io.setSizeTField(this, 1, image_width); - return this; - } - @Ptr - @Field(2) - public long image_height() { - return this.io.getSizeTField(this, 2); - } - @Ptr - @Field(2) - public cl_image_desc image_height(long image_height) { - this.io.setSizeTField(this, 2, image_height); - return this; - } - @Ptr - @Field(3) - public long image_depth() { - return this.io.getSizeTField(this, 3); - } - @Ptr - @Field(3) - public cl_image_desc image_depth(long image_depth) { - this.io.setSizeTField(this, 3, image_depth); - return this; - } - @Ptr - @Field(4) - public long image_array_size() { - return this.io.getSizeTField(this, 4); - } - @Ptr - @Field(4) - public cl_image_desc image_array_size(long image_array_size) { - this.io.setSizeTField(this, 4, image_array_size); - return this; - } - @Ptr - @Field(5) - public long image_row_pitch() { - return this.io.getSizeTField(this, 5); - } - @Ptr - @Field(5) - public cl_image_desc image_row_pitch(long image_row_pitch) { - this.io.setSizeTField(this, 5, image_row_pitch); - return this; - } - @Ptr - @Field(6) - public long image_slice_pitch() { - return this.io.getSizeTField(this, 6); - } - @Ptr - @Field(6) - public cl_image_desc image_slice_pitch(long image_slice_pitch) { - this.io.setSizeTField(this, 6, image_slice_pitch); - return this; - } - /** C type : cl_uint */ - @Field(7) - public int num_mip_levels() { - return this.io.getIntField(this, 7); - } - /** C type : cl_uint */ - @Field(7) - public cl_image_desc num_mip_levels(int num_mip_levels) { - this.io.setIntField(this, 7, num_mip_levels); - return this; - } - /** C type : cl_uint */ - @Field(8) - public int num_samples() { - return this.io.getIntField(this, 8); - } - /** C type : cl_uint */ - @Field(8) - public cl_image_desc num_samples(int num_samples) { - this.io.setIntField(this, 8, num_samples); - return this; - } - /** C type : cl_mem */ - @Field(9) - public cl_mem buffer() { - return this.io.getTypedPointerField(this, 9); - } - /** C type : cl_mem */ - @Field(9) - public cl_image_desc buffer(cl_mem buffer) { - this.io.setPointerField(this, 9, buffer); - return this; - } - public cl_image_desc() { - super(); - } - public cl_image_desc(Pointer pointer) { - super(pointer); - } -} diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_image_format.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_image_format.java index 8d297cef..5e9d2a1e 100644 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_image_format.java +++ b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/library/cl_image_format.java @@ -1,41 +1,41 @@ package com.nativelibs4java.opencl.library; -import org.bridj.Pointer; -import org.bridj.StructObject; -import org.bridj.ann.Field; -import org.bridj.ann.Library; +import com.ochafik.lang.jnaerator.runtime.Structure; /** * This file was autogenerated by JNAerator,
    * a tool written by Olivier Chafik that uses a few opensource projects..
    - * For help, please visit NativeLibs4Java or BridJ . + * For help, please visit NativeLibs4Java , Rococoa, or JNA. */ -@Library("OpenCL") -public class cl_image_format extends StructObject { - /** C type : cl_channel_order */ - @Field(0) - public int image_channel_order() { - return this.io.getIntField(this, 0); - } - /** C type : cl_channel_order */ - @Field(0) - public cl_image_format image_channel_order(int image_channel_order) { - this.io.setIntField(this, 0, image_channel_order); - return this; - } - /** C type : cl_channel_type */ - @Field(1) - public int image_channel_data_type() { - return this.io.getIntField(this, 1); - } - /** C type : cl_channel_type */ - @Field(1) - public cl_image_format image_channel_data_type(int image_channel_data_type) { - this.io.setIntField(this, 1, image_channel_data_type); - return this; - } +public class cl_image_format extends Structure { + /// C type : cl_channel_order + public int image_channel_order; + /// C type : cl_channel_type + public int image_channel_data_type; public cl_image_format() { super(); } - public cl_image_format(Pointer pointer) { - super(pointer); + /** + * @param image_channel_order C type : cl_channel_order
    + * @param image_channel_data_type C type : cl_channel_type + */ + public cl_image_format(int image_channel_order, int image_channel_data_type) { + super(); + this.image_channel_order = image_channel_order; + this.image_channel_data_type = image_channel_data_type; + } + + public java.util.List getFieldOrder() { + return java.util.Arrays.asList("image_channel_order", "image_channel_data_type"); + } + protected ByReference newByReference() { return new ByReference(); } + protected ByValue newByValue() { return new ByValue(); } + protected cl_image_format newInstance() { return new cl_image_format(); } + public static cl_image_format[] newArray(int arrayLength) { + return Structure.newArray(cl_image_format.class, arrayLength); } + public static class ByReference extends cl_image_format implements Structure.ByReference { + + }; + public static class ByValue extends cl_image_format implements Structure.ByValue { + + }; } diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/AbstractOpenCLImplementation.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/AbstractOpenCLImplementation.java deleted file mode 100644 index 2aa72f06..00000000 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/AbstractOpenCLImplementation.java +++ /dev/null @@ -1,450 +0,0 @@ -package com.nativelibs4java.opencl.proxy; - -import com.nativelibs4java.opencl.library.IOpenCLLibrary; -import com.nativelibs4java.opencl.library.OpenCLLibrary; -import org.bridj.Pointer; -import org.bridj.SizeT; - -public abstract class AbstractOpenCLImplementation implements IOpenCLLibrary { - - public int clBuildProgram(long cl_program1, int cl_uint1, long cl_device_idPtr1, long charPtr1, long arg1, long voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clCompileProgram(cl_program cl_program1, int cl_uint1, Pointer cl_device_idPtr1, Pointer charPtr1, int cl_uint2, Pointer cl_programPtr1, Pointer> charPtrPtr1, Pointer arg1, Pointer voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateBuffer(long cl_context1, long cl_mem_flags1, long size_t1, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateCommandQueue(long cl_context1, long cl_device_id1, long cl_command_queue_properties1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateContext(long cl_context_propertiesPtr1, int cl_uint1, long cl_device_idPtr1, long arg1, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public cl_context clCreateContextFromType(Pointer> cl_context_propertiesPtr1, long cl_device_type1, Pointer arg1, Pointer voidPtr1, Pointer cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public cl_event clCreateEventFromGLsyncKHR(cl_context cl_context1, cl_GLsync cl_GLsync1, Pointer cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateFromGLBuffer(long cl_context1, long cl_mem_flags1, int cl_GLuint1, long intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateFromGLRenderbuffer(long cl_context1, long cl_mem_flags1, int cl_GLuint1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateFromGLTexture(long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateFromGLTexture2D(long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateFromGLTexture3D(long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateImage(long cl_context1, long cl_mem_flags1, long cl_image_formatPtr1, long cl_image_descPtr1, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateImage2D(long cl_context1, long cl_mem_flags1, long cl_image_formatPtr1, long size_t1, long size_t2, long size_t3, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateImage3D(long cl_context1, long cl_mem_flags1, long cl_image_formatPtr1, long size_t1, long size_t2, long size_t3, long size_t4, long size_t5, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateKernel(long cl_program1, long charPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clCreateKernelsInProgram(long cl_program1, int cl_uint1, long cl_kernelPtr1, long cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateProgramWithBinary(long cl_context1, int cl_uint1, long cl_device_idPtr1, long size_tPtr1, long charPtrPtr1, long cl_intPtr1, long cl_intPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public cl_program clCreateProgramWithBuiltInKernels(cl_context cl_context1, int cl_uint1, Pointer cl_device_idPtr1, Pointer charPtr1, Pointer cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateProgramWithSource(long cl_context1, int cl_uint1, long charPtrPtr1, long size_tPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateSampler(long cl_context1, int cl_bool1, int cl_addressing_mode1, int cl_filter_mode1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateSubBuffer(long cl_mem1, long cl_mem_flags1, int cl_buffer_create_type1, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clCreateSubDevices(cl_device_id cl_device_id1, Pointer> cl_device_partition_propertyPtr1, int cl_uint1, Pointer cl_device_idPtr1, Pointer cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clCreateSubDevicesEXT(cl_device_id cl_device_id1, Pointer cl_device_partition_property_extPtr1, int cl_uint1, Pointer cl_device_idPtr1, Pointer cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateUserEvent(long cl_context1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueAcquireGLObjects(long cl_command_queue1, int cl_uint1, long cl_memPtr1, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueBarrier(long cl_command_queue1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueBarrierWithWaitList(cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyBuffer(long cl_command_queue1, long cl_mem1, long cl_mem2, long size_t1, long size_t2, long size_t3, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyBufferRect(cl_command_queue cl_command_queue1, cl_mem cl_mem1, cl_mem cl_mem2, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, long size_t1, long size_t2, long size_t3, long size_t4, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyBufferToImage(cl_command_queue cl_command_queue1, cl_mem cl_mem1, cl_mem cl_mem2, long size_t1, Pointer size_tPtr1, Pointer size_tPtr2, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyImage(cl_command_queue cl_command_queue1, cl_mem cl_mem1, cl_mem cl_mem2, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyImageToBuffer(cl_command_queue cl_command_queue1, cl_mem cl_mem1, cl_mem cl_mem2, Pointer size_tPtr1, Pointer size_tPtr2, long size_t1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueFillBuffer(cl_command_queue cl_command_queue1, cl_mem cl_mem1, Pointer voidPtr1, long size_t1, long size_t2, long size_t3, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueFillImage(cl_command_queue cl_command_queue1, cl_mem cl_mem1, Pointer voidPtr1, Pointer size_tPtr1, Pointer size_tPtr2, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clEnqueueMapBuffer(long cl_command_queue1, long cl_mem1, int cl_bool1, long cl_map_flags1, long size_t1, long size_t2, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clEnqueueMapImage(long cl_command_queue1, long cl_mem1, int cl_bool1, long cl_map_flags1, long size_tPtr1, long size_tPtr2, long size_tPtr3, long size_tPtr4, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueMarker(long cl_command_queue1, long cl_eventPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueMarkerWithWaitList(cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueMigrateMemObjects(cl_command_queue cl_command_queue1, int cl_uint1, Pointer cl_memPtr1, long cl_mem_migration_flags1, int cl_uint2, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueNDRangeKernel(long cl_command_queue1, long cl_kernel1, int cl_uint1, long size_tPtr1, long size_tPtr2, long size_tPtr3, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueNativeKernel(cl_command_queue cl_command_queue1, Pointer arg1, Pointer voidPtr1, long size_t1, int cl_uint1, Pointer cl_memPtr1, Pointer> voidPtrPtr1, int cl_uint2, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueReadBuffer(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueReadBufferRect(cl_command_queue cl_command_queue1, cl_mem cl_mem1, int cl_bool1, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, long size_t1, long size_t2, long size_t3, long size_t4, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueReadImage(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_tPtr1, long size_tPtr2, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueReleaseGLObjects(long cl_command_queue1, int cl_uint1, long cl_memPtr1, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueTask(long cl_command_queue1, long cl_kernel1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueUnmapMemObject(long cl_command_queue1, long cl_mem1, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueWaitForEvents(long cl_command_queue1, int cl_uint1, long cl_eventPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueWriteBuffer(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueWriteBufferRect(cl_command_queue cl_command_queue1, cl_mem cl_mem1, int cl_bool1, Pointer size_tPtr1, Pointer size_tPtr2, Pointer size_tPtr3, long size_t1, long size_t2, long size_t3, long size_t4, Pointer voidPtr1, int cl_uint1, Pointer cl_eventPtr1, Pointer cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueWriteImage(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_tPtr1, long size_tPtr2, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clFinish(long cl_command_queue1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clFlush(long cl_command_queue1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetCommandQueueInfo(long cl_command_queue1, int cl_command_queue_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetContextInfo(long cl_context1, int cl_context_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetDeviceIDs(long cl_platform_id1, long cl_device_type1, int cl_uint1, long cl_device_idPtr1, long cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetDeviceInfo(long cl_device_id1, int cl_device_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetEventInfo(long cl_event1, int cl_event_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetEventProfilingInfo(long cl_event1, int cl_profiling_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public Pointer clGetExtensionFunctionAddress(Pointer charPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public Pointer clGetExtensionFunctionAddressForPlatform(cl_platform_id cl_platform_id1, Pointer charPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetGLContextInfoAPPLE(long cl_context1, long voidPtr1, int cl_gl_platform_info1, long size_t1, long voidPtr2, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetGLContextInfoKHR(long cl_context_propertiesPtr1, int cl_gl_context_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetGLObjectInfo(long cl_mem1, long cl_gl_object_typePtr1, long cl_GLuintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetGLTextureInfo(long cl_mem1, int cl_gl_texture_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetImageInfo(long cl_mem1, int cl_image_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetKernelArgInfo(long cl_kernel1, int cl_uint1, int cl_kernel_arg_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetKernelInfo(long cl_kernel1, int cl_kernel_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetKernelWorkGroupInfo(long cl_kernel1, long cl_device_id1, int cl_kernel_work_group_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetMemObjectInfo(long cl_mem1, int cl_mem_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetPlatformIDs(int cl_uint1, long cl_platform_idPtr1, long cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetPlatformInfo(long cl_platform_id1, int cl_platform_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetProgramBuildInfo(long cl_program1, long cl_device_id1, int cl_program_build_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetProgramInfo(long cl_program1, int cl_program_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetSamplerInfo(long cl_sampler1, int cl_sampler_info1, long size_t1, long voidPtr1, long size_tPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clGetSupportedImageFormats(long cl_context1, long cl_mem_flags1, int cl_mem_object_type1, int cl_uint1, long cl_image_formatPtr1, long cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clIcdGetPlatformIDsKHR(int cl_uint1, long cl_platform_idPtr1, long cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public cl_program clLinkProgram(cl_context cl_context1, int cl_uint1, Pointer cl_device_idPtr1, Pointer charPtr1, int cl_uint2, Pointer cl_programPtr1, Pointer arg1, Pointer voidPtr1, Pointer cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void clLogMessagesToStderrAPPLE(Pointer charPtr1, Pointer voidPtr1, long size_t1, Pointer voidPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void clLogMessagesToStdoutAPPLE(Pointer charPtr1, Pointer voidPtr1, long size_t1, Pointer voidPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void clLogMessagesToSystemLogAPPLE(Pointer charPtr1, Pointer voidPtr1, long size_t1, Pointer voidPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseCommandQueue(long cl_command_queue1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseContext(long cl_context1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseDevice(long cl_device_id1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseDeviceEXT(long cl_device_id1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseEvent(long cl_event1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseKernel(long cl_kernel1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseMemObject(long cl_mem1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseProgram(long cl_program1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clReleaseSampler(long cl_sampler1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainCommandQueue(long cl_command_queue1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainContext(long cl_context1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainDevice(long cl_device_id1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainDeviceEXT(long cl_device_id1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainEvent(long cl_event1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainKernel(long cl_kernel1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainMemObject(long cl_mem1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainProgram(long cl_program1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clRetainSampler(long cl_sampler1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetCommandQueueProperty(long cl_command_queue1, long cl_command_queue_properties1, int cl_bool1, long cl_command_queue_propertiesPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetEventCallback(long cl_event1, int cl_int1, long arg1, long voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetKernelArg(long cl_kernel1, int cl_uint1, long size_t1, long voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetMemObjectDestructorAPPLE(cl_mem cl_mem1, Pointer arg1, Pointer voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetMemObjectDestructorCallback(long cl_mem1, long arg1, long voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetPrintfCallback(cl_context cl_context1, Pointer arg1, Pointer voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetUserEventStatus(long cl_event1, int cl_int1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clUnloadCompiler() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clUnloadPlatformCompiler(long cl_platform_id1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clWaitForEvents(int cl_uint1, long cl_eventPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - -} diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/PointerUtils.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/PointerUtils.java deleted file mode 100644 index 9c2b89b7..00000000 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/PointerUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.proxy; - -import org.bridj.NativeObject; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; - -public class PointerUtils { - - protected static void setSizeT(long peer, long value) { - pointerToAddress(peer).setSizeT(value); - } - - protected static void setSizeTAtIndex(long peer, int index, long value) { - pointerToAddress(peer).setSizeTAtIndex(index, value); - } - - protected static void setPointerAtIndex(long peer, int index, Pointer value) { - pointerToAddress(peer).setPointerAtIndex(index, value); - } - - protected static void setPointerAtIndex(long peer, int index, NativeObject value) { - pointerToAddress(peer).setSizeTAtIndex(index, Pointer.getPeer(Pointer.getPointer(value))); - // pointerToAddress(peer).setSizeTAtIndex(index, Pointer.getPeer(Pointer.pointerTo(value))); - } - - protected static long getSizeT(long peer) { - return pointerToAddress(peer).getSizeT(); - } - - protected static Pointer getPointer(long peer, Class targetClass) { - return pointerToAddress(peer).getPointer(targetClass); - } - - // public static Pointer getPointer(N instance) { - // return pointerTo(instance); - // } - - protected static void setInt(long peer, int value) { - pointerToAddress(peer).setInt(value); - } - - protected static int getInt(long peer) { - return pointerToAddress(peer).getInt(); - } -} diff --git a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/ProxiedOpenCLImplementation.java b/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/ProxiedOpenCLImplementation.java deleted file mode 100644 index fd1e9a0a..00000000 --- a/OpenCL4Java/src/main/java/com/nativelibs4java/opencl/proxy/ProxiedOpenCLImplementation.java +++ /dev/null @@ -1,650 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.nativelibs4java.opencl.proxy; - -import com.nativelibs4java.opencl.library.IOpenCLLibrary; -import static com.nativelibs4java.opencl.library.IOpenCLLibrary.*; -import com.nativelibs4java.opencl.library.OpenCLLibrary; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ServiceLoader; -import org.bridj.BridJ; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; -import static com.nativelibs4java.opencl.proxy.PointerUtils.*; -import org.bridj.SizeT; -import org.bridj.StructObject; -import org.bridj.ann.Field; -import org.bridj.ann.Ptr; - -/** - * - * @author ochafik - */ -public class ProxiedOpenCLImplementation implements IOpenCLLibrary { - - private static Pointer icdDispatchTable; - public static void setIcdDispatchTable(long icdDispatchTablePeer) { - ProxiedOpenCLImplementation.icdDispatchTable = pointerToAddress(icdDispatchTablePeer); - } - - private static ProxiedOpenCLImplementation instance; - public static synchronized IOpenCLLibrary getInstance() { - if (instance == null) { - List platforms = new ArrayList(); - for (Iterator it = ServiceLoader.load(IOpenCLLibrary.class).iterator(); it.hasNext();) { - IOpenCLLibrary platform = it.next(); - platforms.add(platform); - } - instance = new ProxiedOpenCLImplementation(platforms); - } - return instance; - } - - public int clCreateSubDevices(long cl_device_id1, long cl_device_partition_propertyPtr1, int cl_uint1, long cl_device_idPtr1, long cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateContextFromType(long cl_context_propertiesPtr1, long cl_device_type1, long arg1, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateProgramWithBuiltInKernels(long cl_context1, int cl_uint1, long cl_device_idPtr1, long charPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clCompileProgram(long cl_program1, int cl_uint1, long cl_device_idPtr1, long charPtr1, int cl_uint2, long cl_programPtr1, long charPtrPtr1, long arg1, long voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clLinkProgram(long cl_context1, int cl_uint1, long cl_device_idPtr1, long charPtr1, int cl_uint2, long cl_programPtr1, long arg1, long voidPtr1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueReadBufferRect(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_tPtr1, long size_tPtr2, long size_tPtr3, long size_t1, long size_t2, long size_t3, long size_t4, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueWriteBufferRect(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_tPtr1, long size_tPtr2, long size_tPtr3, long size_t1, long size_t2, long size_t3, long size_t4, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueFillBuffer(long cl_command_queue1, long cl_mem1, long voidPtr1, long size_t1, long size_t2, long size_t3, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyBufferRect(long cl_command_queue1, long cl_mem1, long cl_mem2, long size_tPtr1, long size_tPtr2, long size_tPtr3, long size_t1, long size_t2, long size_t3, long size_t4, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueFillImage(long cl_command_queue1, long cl_mem1, long voidPtr1, long size_tPtr1, long size_tPtr2, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyImage(long cl_command_queue1, long cl_mem1, long cl_mem2, long size_tPtr1, long size_tPtr2, long size_tPtr3, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyImageToBuffer(long cl_command_queue1, long cl_mem1, long cl_mem2, long size_tPtr1, long size_tPtr2, long size_t1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueCopyBufferToImage(long cl_command_queue1, long cl_mem1, long cl_mem2, long size_t1, long size_tPtr1, long size_tPtr2, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueMigrateMemObjects(long cl_command_queue1, int cl_uint1, long cl_memPtr1, long cl_mem_migration_flags1, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueNativeKernel(long cl_command_queue1, long arg1, long voidPtr1, long size_t1, int cl_uint1, long cl_memPtr1, long voidPtrPtr1, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueMarkerWithWaitList(long cl_command_queue1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clEnqueueBarrierWithWaitList(long cl_command_queue1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetPrintfCallback(long cl_context1, long arg1, long voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clGetExtensionFunctionAddressForPlatform(long cl_platform_id1, long charPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clGetExtensionFunctionAddress(long charPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public long clCreateEventFromGLsyncKHR(long cl_context1, long cl_GLsync1, long cl_intPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clSetMemObjectDestructorAPPLE(long cl_mem1, long arg1, long voidPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void clLogMessagesToSystemLogAPPLE(long charPtr1, long voidPtr1, long size_t1, long voidPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void clLogMessagesToStdoutAPPLE(long charPtr1, long voidPtr1, long size_t1, long voidPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void clLogMessagesToStderrAPPLE(long charPtr1, long voidPtr1, long size_t1, long voidPtr2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public int clCreateSubDevicesEXT(long cl_device_id1, long cl_device_partition_property_extPtr1, int cl_uint1, long cl_device_idPtr1, long cl_uintPtr1) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - protected static class IcdEntity extends StructObject { - @Field(0) - public Pointer icdDispatchTable = ProxiedOpenCLImplementation.icdDispatchTable; - @Field(1) - public int implementationIndex; - @Field(2) - public int entityIndex; - - - public IcdEntity() { - super(); - } - public IcdEntity(Pointer peer, Object... targs) { - super(peer); - } - } - - public static IcdEntity createEntity(int implementationIndex, int entityIndex) { - IcdEntity entity = new IcdEntity(); - entity.implementationIndex = implementationIndex; - entity.entityIndex = entityIndex; - BridJ.writeToNative(entity); - return entity; - } - - private final List implementations; - private final List platformIds; - - public ProxiedOpenCLImplementation(List implementations) { - this.implementations = new ArrayList(implementations); - - List platformIds = new ArrayList(); - for (IOpenCLLibrary implementation : this.implementations) { - int implementationIndex = implementations.size(); - implementations.add(implementation); - platformIds.add(createEntity(implementationIndex, implementationIndex)); - } - this.platformIds = platformIds; - } - - - protected IOpenCLLibrary getImplementation(long icdEntityPeer) { - Pointer icdEntityPtr = getPointer(icdEntityPeer, IcdEntity.class); - IcdEntity icdEntity = icdEntityPtr.get(); - if (!icdDispatchTable.equals(icdEntity.icdDispatchTable)) - throw new IllegalArgumentException("Not an ICD entity, or different ICD dispatch table: " + icdEntityPeer); - IOpenCLLibrary implementation = implementations.get(icdEntity.implementationIndex); - return implementation; - } - - @Override - public int clGetPlatformIDs(int num_entries, @Ptr long platforms, @Ptr long num_platforms) { - System.out.println("Called clGetPlatformIDs"); - if ((platforms == 0 || num_entries == 0) && num_platforms == 0) { - setSizeT(num_platforms, platformIds.size()); - } else if (platforms != 0 && num_entries != 0) { - int numWrote = 0; - for (int i = 0; i < num_entries; i++) { - setPointerAtIndex(platforms, i, platformIds.get(i)); - numWrote++; - } - if (num_platforms != 0) { - setSizeT(num_platforms, numWrote); - } - } else - return CL_INVALID_VALUE; - return CL_SUCCESS; - } - - @Override - public int clIcdGetPlatformIDsKHR(int num_entries, @Ptr long platforms, @Ptr long num_platforms) { - // TODO - return clGetPlatformIDs(num_entries, platforms, num_platforms); - } - - - - - @Override - public int clGetDeviceIDs(long cl_platform_id1, long cl_device_type1, int cl_uint1, long cl_device_idPtr1, long cl_uintPtr1) { - return getImplementation(cl_platform_id1).clGetDeviceIDs(cl_platform_id1, cl_device_type1, cl_uint1, cl_device_idPtr1, cl_uintPtr1); - } - - @Override - public int clGetDeviceInfo(long cl_device_id1, int cl_device_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_device_id1).clGetDeviceInfo(cl_device_id1, cl_device_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetPlatformInfo(long cl_platform_id1, int cl_platform_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_platform_id1).clGetPlatformInfo(cl_platform_id1, cl_platform_info1, size_t1, voidPtr1, size_tPtr1); - } - - @Override - public int clBuildProgram(long cl_program1, int cl_uint1, long cl_device_idPtr1, long charPtr1, long arg1, long voidPtr1) { - return getImplementation(cl_program1).clBuildProgram(cl_program1, cl_uint1, cl_device_idPtr1, charPtr1, arg1, voidPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateBuffer(long cl_context1, long cl_mem_flags1, long size_t1, long voidPtr1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateBuffer(cl_context1, cl_mem_flags1, size_t1, voidPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateCommandQueue(long cl_context1, long cl_device_id1, long cl_command_queue_properties1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateCommandQueue(cl_context1, cl_device_id1, cl_command_queue_properties1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateContext(long cl_context_propertiesPtr1, int cl_uint1, long cl_device_idPtr1, long arg1, long voidPtr1, long cl_intPtr1) { - // TODO! - throw new UnsupportedOperationException(); -// return getImplementation(cl_context_propertiesPtr1).clCreateContext(cl_context_propertiesPtr1, cl_uint1, cl_device_idPtr1, arg1, voidPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateFromGLBuffer(long cl_context1, long cl_mem_flags1, int cl_GLuint1, long intPtr1) { - return getImplementation(cl_context1).clCreateFromGLBuffer(cl_context1, cl_mem_flags1, cl_GLuint1, intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateFromGLRenderbuffer(long cl_context1, long cl_mem_flags1, int cl_GLuint1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateFromGLRenderbuffer(cl_context1, cl_mem_flags1, cl_GLuint1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateFromGLTexture(long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateFromGLTexture(cl_context1, cl_mem_flags1, cl_GLenum1, cl_GLint1, cl_GLuint1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateFromGLTexture2D(long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateFromGLTexture2D(cl_context1, cl_mem_flags1, cl_GLenum1, cl_GLint1, cl_GLuint1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateFromGLTexture3D(long cl_context1, long cl_mem_flags1, int cl_GLenum1, int cl_GLint1, int cl_GLuint1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateFromGLTexture3D(cl_context1, cl_mem_flags1, cl_GLenum1, cl_GLint1, cl_GLuint1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateImage(long cl_context1, long cl_mem_flags1, long cl_image_formatPtr1, long cl_image_descPtr1, long voidPtr1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateImage(cl_context1, cl_mem_flags1, cl_image_formatPtr1, cl_image_descPtr1, voidPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateImage2D(long cl_context1, long cl_mem_flags1, long cl_image_formatPtr1, long size_t1, long size_t2, long size_t3, long voidPtr1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateImage2D(cl_context1, cl_mem_flags1, cl_image_formatPtr1, size_t1, size_t2, size_t3, voidPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateImage3D(long cl_context1, long cl_mem_flags1, long cl_image_formatPtr1, long size_t1, long size_t2, long size_t3, long size_t4, long size_t5, long voidPtr1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateImage3D(cl_context1, cl_mem_flags1, cl_image_formatPtr1, size_t1, size_t2, size_t3, size_t4, size_t5, voidPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateKernel(long cl_program1, long charPtr1, long cl_intPtr1) { - return getImplementation(cl_program1).clCreateKernel(cl_program1, charPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clCreateKernelsInProgram(long cl_program1, int cl_uint1, long cl_kernelPtr1, long cl_uintPtr1) { - return getImplementation(cl_program1).clCreateKernelsInProgram(cl_program1, cl_uint1, cl_kernelPtr1, cl_uintPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateProgramWithBinary(long cl_context1, int cl_uint1, long cl_device_idPtr1, long size_tPtr1, long charPtrPtr1, long cl_intPtr1, long cl_intPtr2) { - return getImplementation(cl_context1).clCreateProgramWithBinary(cl_context1, cl_uint1, cl_device_idPtr1, size_tPtr1, charPtrPtr1, cl_intPtr1, cl_intPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateProgramWithSource(long cl_context1, int cl_uint1, long charPtrPtr1, long size_tPtr1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateProgramWithSource(cl_context1, cl_uint1, charPtrPtr1, size_tPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateSampler(long cl_context1, int cl_bool1, int cl_addressing_mode1, int cl_filter_mode1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateSampler(cl_context1, cl_bool1, cl_addressing_mode1, cl_filter_mode1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateSubBuffer(long cl_mem1, long cl_mem_flags1, int cl_buffer_create_type1, long voidPtr1, long cl_intPtr1) { - return getImplementation(cl_mem1).clCreateSubBuffer(cl_mem1, cl_mem_flags1, cl_buffer_create_type1, voidPtr1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clCreateUserEvent(long cl_context1, long cl_intPtr1) { - return getImplementation(cl_context1).clCreateUserEvent(cl_context1, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueAcquireGLObjects(long cl_command_queue1, int cl_uint1, long cl_memPtr1, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueAcquireGLObjects(cl_command_queue1, cl_uint1, cl_memPtr1, cl_uint2, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueBarrier(long cl_command_queue1) { - return getImplementation(cl_command_queue1).clEnqueueBarrier(cl_command_queue1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueCopyBuffer(long cl_command_queue1, long cl_mem1, long cl_mem2, long size_t1, long size_t2, long size_t3, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueCopyBuffer(cl_command_queue1, cl_mem1, cl_mem2, size_t1, size_t2, size_t3, cl_uint1, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clEnqueueMapBuffer(long cl_command_queue1, long cl_mem1, int cl_bool1, long cl_map_flags1, long size_t1, long size_t2, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2, long cl_intPtr1) { - return getImplementation(cl_command_queue1).clEnqueueMapBuffer(cl_command_queue1, cl_mem1, cl_bool1, cl_map_flags1, size_t1, size_t2, cl_uint1, cl_eventPtr1, cl_eventPtr2, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public long clEnqueueMapImage(long cl_command_queue1, long cl_mem1, int cl_bool1, long cl_map_flags1, long size_tPtr1, long size_tPtr2, long size_tPtr3, long size_tPtr4, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2, long cl_intPtr1) { - return getImplementation(cl_command_queue1).clEnqueueMapImage(cl_command_queue1, cl_mem1, cl_bool1, cl_map_flags1, size_tPtr1, size_tPtr2, size_tPtr3, size_tPtr4, cl_uint1, cl_eventPtr1, cl_eventPtr2, cl_intPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueMarker(long cl_command_queue1, long cl_eventPtr1) { - return getImplementation(cl_command_queue1).clEnqueueMarker(cl_command_queue1, cl_eventPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueNDRangeKernel(long cl_command_queue1, long cl_kernel1, int cl_uint1, long size_tPtr1, long size_tPtr2, long size_tPtr3, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - - throw new UnsupportedOperationException(); -// return getImplementation(cl_program1).clEnqueueNDRangeKernel(cl_command_queue1, cl_kernel1, cl_uint1, size_tPtr1, size_tPtr2, size_tPtr3, cl_uint2, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueReadBuffer(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueReadBuffer(cl_command_queue1, cl_mem1, cl_bool1, size_t1, size_t2, voidPtr1, cl_uint1, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueReadImage(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_tPtr1, long size_tPtr2, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueReadImage(cl_command_queue1, cl_mem1, cl_bool1, size_tPtr1, size_tPtr2, size_t1, size_t2, voidPtr1, cl_uint1, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueReleaseGLObjects(long cl_command_queue1, int cl_uint1, long cl_memPtr1, int cl_uint2, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueReleaseGLObjects(cl_command_queue1, cl_uint1, cl_memPtr1, cl_uint2, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueTask(long cl_command_queue1, long cl_kernel1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueTask(cl_command_queue1, cl_kernel1, cl_uint1, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueUnmapMemObject(long cl_command_queue1, long cl_mem1, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueUnmapMemObject(cl_command_queue1, cl_mem1, voidPtr1, cl_uint1, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueWaitForEvents(long cl_command_queue1, int cl_uint1, long cl_eventPtr1) { - return getImplementation(cl_command_queue1).clEnqueueWaitForEvents(cl_command_queue1, cl_uint1, cl_eventPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueWriteBuffer(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueWriteBuffer(cl_command_queue1, cl_mem1, cl_bool1, size_t1, size_t2, voidPtr1, cl_uint1, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clEnqueueWriteImage(long cl_command_queue1, long cl_mem1, int cl_bool1, long size_tPtr1, long size_tPtr2, long size_t1, long size_t2, long voidPtr1, int cl_uint1, long cl_eventPtr1, long cl_eventPtr2) { - return getImplementation(cl_command_queue1).clEnqueueWriteImage(cl_command_queue1, cl_mem1, cl_bool1, size_tPtr1, size_tPtr2, size_t1, size_t2, voidPtr1, cl_uint1, cl_eventPtr1, cl_eventPtr2); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clFinish(long cl_command_queue1) { - return getImplementation(cl_command_queue1).clFinish(cl_command_queue1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clFlush(long cl_command_queue1) { - return getImplementation(cl_command_queue1).clFlush(cl_command_queue1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetCommandQueueInfo(long cl_command_queue1, int cl_command_queue_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_command_queue1).clGetCommandQueueInfo(cl_command_queue1, cl_command_queue_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetContextInfo(long cl_context1, int cl_context_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_context1).clGetContextInfo(cl_context1, cl_context_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetEventInfo(long cl_event1, int cl_event_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_event1).clGetEventInfo(cl_event1, cl_event_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetEventProfilingInfo(long cl_event1, int cl_profiling_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_event1).clGetEventProfilingInfo(cl_event1, cl_profiling_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetGLContextInfoAPPLE(long cl_context1, long voidPtr1, int cl_gl_platform_info1, long size_t1, long voidPtr2, long size_tPtr1) { - return getImplementation(cl_context1).clGetGLContextInfoAPPLE(cl_context1, voidPtr1, cl_gl_platform_info1, size_t1, voidPtr2, size_tPtr1); - } - - @Override - public int clGetGLContextInfoKHR(long cl_context_propertiesPtr1, int cl_gl_context_info1, long size_t1, long voidPtr1, long size_tPtr1) { - // TODO - throw new UnsupportedOperationException(); -// return getImplementation(cl_program1).clGetGLContextInfoKHR(cl_context_propertiesPtr1, cl_gl_context_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetGLObjectInfo(long cl_mem1, long cl_gl_object_typePtr1, long cl_GLuintPtr1) { - return getImplementation(cl_mem1).clGetGLObjectInfo(cl_mem1, cl_gl_object_typePtr1, cl_GLuintPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetGLTextureInfo(long cl_mem1, int cl_gl_texture_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_mem1).clGetGLTextureInfo(cl_mem1, cl_gl_texture_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetImageInfo(long cl_mem1, int cl_image_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_mem1).clGetImageInfo(cl_mem1, cl_image_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetKernelArgInfo(long cl_kernel1, int cl_uint1, int cl_kernel_arg_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_kernel1).clGetKernelArgInfo(cl_kernel1, cl_uint1, cl_kernel_arg_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetKernelInfo(long cl_kernel1, int cl_kernel_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_kernel1).clGetKernelInfo(cl_kernel1, cl_kernel_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetKernelWorkGroupInfo(long cl_kernel1, long cl_device_id1, int cl_kernel_work_group_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_kernel1).clGetKernelWorkGroupInfo(cl_kernel1, cl_device_id1, cl_kernel_work_group_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetMemObjectInfo(long cl_mem1, int cl_mem_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_mem1).clGetMemObjectInfo(cl_mem1, cl_mem_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetProgramBuildInfo(long cl_program1, long cl_device_id1, int cl_program_build_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_program1).clGetProgramBuildInfo(cl_program1, cl_device_id1, cl_program_build_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetProgramInfo(long cl_program1, int cl_program_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_program1).clGetProgramInfo(cl_program1, cl_program_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetSamplerInfo(long cl_sampler1, int cl_sampler_info1, long size_t1, long voidPtr1, long size_tPtr1) { - return getImplementation(cl_sampler1).clGetSamplerInfo(cl_sampler1, cl_sampler_info1, size_t1, voidPtr1, size_tPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clGetSupportedImageFormats(long cl_context1, long cl_mem_flags1, int cl_mem_object_type1, int cl_uint1, long cl_image_formatPtr1, long cl_uintPtr1) { - return getImplementation(cl_context1).clGetSupportedImageFormats(cl_context1, cl_mem_flags1, cl_mem_object_type1, cl_uint1, cl_image_formatPtr1, cl_uintPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseCommandQueue(long cl_command_queue1) { - return getImplementation(cl_command_queue1).clReleaseCommandQueue(cl_command_queue1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseContext(long cl_context1) { - return getImplementation(cl_context1).clReleaseContext(cl_context1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseDevice(long cl_device_id1) { - return getImplementation(cl_device_id1).clReleaseDevice(cl_device_id1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseDeviceEXT(long cl_device_id1) { - return getImplementation(cl_device_id1).clReleaseDeviceEXT(cl_device_id1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseEvent(long cl_event1) { - return getImplementation(cl_event1).clReleaseEvent(cl_event1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseKernel(long cl_kernel1) { - return getImplementation(cl_kernel1).clReleaseKernel(cl_kernel1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseMemObject(long cl_mem1) { - return getImplementation(cl_mem1).clReleaseMemObject(cl_mem1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseProgram(long cl_program1) { - return getImplementation(cl_program1).clReleaseProgram(cl_program1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clReleaseSampler(long cl_sampler1) { - return getImplementation(cl_sampler1).clReleaseSampler(cl_sampler1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainCommandQueue(long cl_command_queue1) { - return getImplementation(cl_command_queue1).clRetainCommandQueue(cl_command_queue1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainContext(long cl_context1) { - return getImplementation(cl_context1).clRetainContext(cl_context1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainDevice(long cl_device_id1) { - return getImplementation(cl_device_id1).clRetainDevice(cl_device_id1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainDeviceEXT(long cl_device_id1) { - return getImplementation(cl_device_id1).clRetainDeviceEXT(cl_device_id1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainEvent(long cl_event1) { - return getImplementation(cl_event1).clRetainEvent(cl_event1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainKernel(long cl_kernel1) { - return getImplementation(cl_kernel1).clRetainKernel(cl_kernel1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainMemObject(long cl_mem1) { - return getImplementation(cl_mem1).clRetainMemObject(cl_mem1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainProgram(long cl_program1) { - return getImplementation(cl_program1).clRetainProgram(cl_program1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clRetainSampler(long cl_sampler1) { - return getImplementation(cl_sampler1).clRetainSampler(cl_sampler1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clSetCommandQueueProperty(long cl_command_queue1, long cl_command_queue_properties1, int cl_bool1, long cl_command_queue_propertiesPtr1) { - return getImplementation(cl_command_queue1).clSetCommandQueueProperty(cl_command_queue1, cl_command_queue_properties1, cl_bool1, cl_command_queue_propertiesPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clSetEventCallback(long cl_event1, int cl_int1, long arg1, long voidPtr1) { - return getImplementation(cl_event1).clSetEventCallback(cl_event1, cl_int1, arg1, voidPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clSetKernelArg(long cl_kernel1, int cl_uint1, long size_t1, long voidPtr1) { - return getImplementation(cl_kernel1).clSetKernelArg(cl_kernel1, cl_uint1, size_t1, voidPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clSetMemObjectDestructorCallback(long cl_mem1, long arg1, long voidPtr1) { - return getImplementation(cl_mem1).clSetMemObjectDestructorCallback(cl_mem1, arg1, voidPtr1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clSetUserEventStatus(long cl_event1, int cl_int1) { - return getImplementation(cl_event1).clSetUserEventStatus(cl_event1, cl_int1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clUnloadCompiler() { - for (IOpenCLLibrary implementation : implementations) { - int res = implementation.clUnloadCompiler(); - if (res != CL_SUCCESS) - return res; - } - return CL_SUCCESS; - } - - @Override - public int clUnloadPlatformCompiler(long cl_platform_id1) { - return getImplementation(cl_platform_id1).clUnloadPlatformCompiler(cl_platform_id1); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public int clWaitForEvents(int cl_uint1, long cl_eventPtr1) { - throw new UnsupportedOperationException(); - } - -} diff --git a/OpenCL4Java/src/main/jnaerator/OpenCL.MacOSX.jnaerator b/OpenCL4Java/src/main/jnaerator/OpenCL.MacOSX.jnaerator index 2add7884..0d692eb9 100644 --- a/OpenCL4Java/src/main/jnaerator/OpenCL.MacOSX.jnaerator +++ b/OpenCL4Java/src/main/jnaerator/OpenCL.MacOSX.jnaerator @@ -3,7 +3,7 @@ -DAVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER= -D__APPLE__= -//-framework OpenCL +-framework OpenCL //-framework OpenGL //-package com.nativelibs4java.opengl.library -framework OpenGL diff --git a/OpenCL4Java/src/main/jnaerator/config-1.1.jnaerator b/OpenCL4Java/src/main/jnaerator/config-1.1.jnaerator deleted file mode 100644 index efcc27c4..00000000 --- a/OpenCL4Java/src/main/jnaerator/config-1.1.jnaerator +++ /dev/null @@ -1,36 +0,0 @@ --nocpp --noMangling --noJar -noComp --runtime BridJ - --gccLong --limitComments - -"-Dextern=" -"-D__stdcall=" -"-D__declspec(x)=x" -"-D__extension__=" - --U_MSC_VER -//-U__APPLE__ -//-U__cplusplus -//-U_WIN32 --DCL_USE_DEPRECATED_OPENCL_1_0_APIS=1 - -//-o "$(DIR)/../../../target/generated-sources/java" - -//-choicesOut "$(DIR)/OpenCL.choices" --v - --package com.nativelibs4java.opencl.library --libraryNamingPrefixes cl --library OpenCL - "-I$(DIR)/../headers/1.1" - "$(DIR)/../headers/1.1/CL/cl_platform.h" - "$(DIR)/../headers/1.1/CL/opencl.h" - "$(DIR)/../headers/1.1/CL/cl.h" - "$(DIR)/../headers/1.1/CL/cl_ext.h" - "$(DIR)/../headers/1.1/CL/cl_gl.h" - "$(DIR)/../headers/1.1/CL/cl_gl_ext.h" - --onlineDoc "Khronos Documentation for {0}" "http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/{0}.html" diff --git a/OpenCL4Java/src/main/jnaerator/config-1.2.jnaerator b/OpenCL4Java/src/main/jnaerator/config-1.2.jnaerator deleted file mode 100644 index 7710e4f8..00000000 --- a/OpenCL4Java/src/main/jnaerator/config-1.2.jnaerator +++ /dev/null @@ -1,50 +0,0 @@ --dontCastConstants - --nocpp --noMangling -//-noJar -noComp --runtime BridJ - --parseInOnePiece --gccLong --limitComments - -"-Dextern=" -"-D__stdcall=" -"-D__declspec(x)=x" -"-D__extension__=" - --U_MSC_VER -//-U__APPLE__ -//-U__cplusplus -//-U_WIN32 --DCL_USE_DEPRECATED_OPENCL_1_0_APIS=1 --DCL_USE_DEPRECATED_OPENCL_1_1_APIS=1 --DCL_USE_DEPRECATED_OPENCL_1_2_APIS=1 - --v - --package com.nativelibs4java.opencl.library --libraryNamingPrefixes cl --library OpenCL - --skipStructs "cl_u?(double|float|int|char|short|long)\d*" --optionalFunctions "cl.+(KHR|EXT|APPLE)|clSetPrintfCallback" --noStaticInit --extractDeclarations IOpenCLLibrary - "-I$(DIR)/../headers/1.2" - //"$(DIR)/../headers/1.2/CL/cl_platform.h" - "$(DIR)/../headers/1.2/CL/opencl.h" - "$(DIR)/../headers/1.2/CL/cl_apple.h" - - //"$(DIR)/../headers/1.2/CL/cl.h" - //"$(DIR)/../headers/1.2/CL/cl_ext.h" - //"$(DIR)/../headers/1.2/CL/cl_gl.h" - //"$(DIR)/../headers/1.2/CL/cl_gl_ext.h" - //"$(DIR)/../headers/1.2/CL/t.h" - - --onlineDoc "Khronos Documentation for {0}" "http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/{0}.html" - --optionalFunctions - clCompileProgram|clCreateEventFromGLsyncKHR|clCreateFromGLTexture|clCreateImage|clCreateProgramWithBuiltInKernels|clCreateSubBuffer|clCreateSubDevices|clCreateSubDevicesEXT|clCreateUserEvent|clEnqueueBarrierWithWaitList|clEnqueueCopyBufferRect|clEnqueueFillBuffer|clEnqueueFillImage|clEnqueueMarkerWithWaitList|clEnqueueMigrateMemObjects|clEnqueueReadBufferRect|clEnqueueWriteBufferRect|clGetExtensionFunctionAddressForPlatform|clGetGLContextInfoAPPLE|clGetGLContextInfoAPPLE|clGetGLContextInfoKHR|clGetKernelArgInfo|clIcdGetPlatformIDsKHR|clLinkProgram|clLogMessagesToStderr|clLogMessagesToStderrAPPLE|clLogMessagesToStdout|clLogMessagesToStdoutAPPLE|clLogMessagesToSystemLog|clLogMessagesToSystemLogAPPLE|clReleaseDevice|clReleaseDeviceEXT|clRetainDevice|clRetainDeviceEXT|clSetEventCallback|clSetMemObjectCallbackFn|clSetMemObjectDestructorAPPLE|clSetMemObjectDestructorCallback|clSetPrintfCallback|clSetUserEventStatus|clUnloadPlatformCompiler diff --git a/OpenCL4Java/src/main/jnaerator/config.jnaerator b/OpenCL4Java/src/main/jnaerator/config.jnaerator index f73609d8..d75fcaa4 100644 --- a/OpenCL4Java/src/main/jnaerator/config.jnaerator +++ b/OpenCL4Java/src/main/jnaerator/config.jnaerator @@ -1 +1,36 @@ -"$(DIR)/config-1.2.jnaerator" +-nocpp +-noMangling +-noJar -noComp +-runtime JNAerator + +-gccLong +-limitComments + +"-Dextern=" +"-D__stdcall=" +"-D__declspec(x)=x" +"-D__extension__=" + +-U_MSC_VER +//-U__APPLE__ +//-U__cplusplus +//-U_WIN32 +-DCL_USE_DEPRECATED_OPENCL_1_0_APIS=1 + +//-o "$(DIR)/../../../target/generated-sources/java" + +//-choicesOut "$(DIR)/OpenCL.choices" +-v + +-package com.nativelibs4java.opencl.library +-libraryNamingPrefixes cl +-library OpenCL + "-I$(DIR)/../headers/1.1" + "$(DIR)/../headers/1.1/CL/cl_platform.h" + "$(DIR)/../headers/1.1/CL/opencl.h" + "$(DIR)/../headers/1.1/CL/cl.h" + "$(DIR)/../headers/1.1/CL/cl_ext.h" + "$(DIR)/../headers/1.1/CL/cl_gl.h" + "$(DIR)/../headers/1.1/CL/cl_gl_ext.h" + +-onlineDoc "Khronos Documentation for {0}" "http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/{0}.html" diff --git a/OpenGLDemos/javacl-opengl-demos-bridj.iml b/OpenGLDemos/javacl-opengl-demos-bridj.iml deleted file mode 100644 index 93ec40b5..00000000 --- a/OpenGLDemos/javacl-opengl-demos-bridj.iml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenGLDemos/javacl-opengl-demos.iml b/OpenGLDemos/javacl-opengl-demos.iml deleted file mode 100644 index 94d2a9ab..00000000 --- a/OpenGLDemos/javacl-opengl-demos.iml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenGLDemos/pom.xml b/OpenGLDemos/pom.xml index c54c6d0d..5b201cc4 100644 --- a/OpenGLDemos/pom.xml +++ b/OpenGLDemos/pom.xml @@ -3,20 +3,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.nativelibs4java - javacl-opengl-demos - JavaCL OpenGL Demos / BridJ + javacl-opengl-demos-jna + JavaCL OpenGL Demos / JNA http://code.google.com/p/javacl/ + 1.0.0-RC4 jar - - true - com.nativelibs4java.opencl.demos.particles.ParticlesDemo - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT + javacl-parent-jna + 1.0.0-RC4 .. @@ -24,8 +20,14 @@ com.nativelibs4java - javacl-demos + javacl-demos-jna + + + org.swinglabs + swing-layout + 1.0.3 + org.jogamp.gluegen @@ -37,12 +39,6 @@ jogl-all-main 2.0.2-rc12 - - - org.swinglabs - swing-layout - 1.0.3 - @@ -50,23 +46,16 @@ com.nativelibs4java - maven-javacl-plugin - - - org.apache.maven.plugins - maven-shade-plugin - - - full-package - package - - shade - - - ${shadedArtifactAttached} - - - + javacl-generator-jna + + + + compile + + + + + diff --git a/OpenGLDemos/src/main/java/com/nativelibs4java/opencl/demos/particles/ParticlesDemo.java b/OpenGLDemos/src/main/java/com/nativelibs4java/opencl/demos/particles/ParticlesDemo.java index 532f9039..6769b3b5 100644 --- a/OpenGLDemos/src/main/java/com/nativelibs4java/opencl/demos/particles/ParticlesDemo.java +++ b/OpenGLDemos/src/main/java/com/nativelibs4java/opencl/demos/particles/ParticlesDemo.java @@ -37,11 +37,13 @@ import com.nativelibs4java.opencl.demos.JavaCLSettingsPanel; import com.nativelibs4java.opencl.demos.SetupUtils; import com.nativelibs4java.util.*; +import com.ochafik.util.SystemUtils; +import com.sun.jna.Platform; +import java.io.IOException; import java.util.logging.*; import javax.swing.*; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; +import java.nio.FloatBuffer; import javax.media.opengl.*; import static javax.media.opengl.GL.*; @@ -59,6 +61,7 @@ import java.io.StringWriter; import java.net.URL; import java.nio.ByteBuffer; +import java.nio.IntBuffer; import java.util.Map; import java.util.Random; import javax.imageio.ImageIO; @@ -347,21 +350,22 @@ public void setImage(BufferedImage image) { queue.finish(); - Pointer positionsView = interleavedColorAndPositionsTemp.as(Float.class); - Pointer colorView = interleavedColorAndPositionsTemp.as(Integer.class); + FloatBuffer positionsView = interleavedColorAndPositionsTemp.asFloatBuffer(); + IntBuffer colorView = interleavedColorAndPositionsTemp.asIntBuffer(); for (int iPoint = 0; iPoint < particlesCount; iPoint++) { int iPixel = (int)(random.nextFloat() * (nNonEmptyPixels - 1)); - velocities.set(iPixel, 0f); - velocities.set(iPixel + 1, 0f); + velocities.put(iPixel, 0); + velocities.put(iPixel + 1, 0); int colorOffset = iPoint * (elementSize / 4); int posOffset = iPoint * (elementSize / 4) + 1; - colorView.set(colorOffset, nonEmptyPixels[iPixel]); - positionsView.set(posOffset, nonEmptyPixelsX[iPixel]); - positionsView.set(posOffset + 1, nonEmptyPixelsY[iPixel]); + colorView.put(colorOffset, nonEmptyPixels[iPixel]); + positionsView.put(posOffset, nonEmptyPixelsX[iPixel]); + positionsView.put(posOffset + 1, nonEmptyPixelsY[iPixel]); } + velocities.rewind(); velocitiesMem.write(queue, velocities, false); if (useOpenGLContext) @@ -387,16 +391,16 @@ public void setImage(BufferedImage image) { boolean limitToScreen = false; long lastMouseMove; - Pointer velocities; + FloatBuffer velocities; //CLKernel updateParticleKernel; ParticlesDemoProgram particlesProgram; - CLBuffer massesMem, velocitiesMem; - CLBuffer interleavedColorAndPositionsMem; - Pointer interleavedColorAndPositionsTemp; + CLFloatBuffer massesMem, velocitiesMem; + CLByteBuffer interleavedColorAndPositionsMem; + ByteBuffer interleavedColorAndPositionsTemp; int elementSize = 4 * 4;//4 + 2 * 4 + 4; // 4 color bytes and 2 position floats, 1 dummy alignment float - CLBuffer colorsMem; + CLByteBuffer colorsMem; Random random = new Random(System.nanoTime()); JavaCLSettingsPanel settings = new JavaCLSettingsPanel(); @@ -506,46 +510,50 @@ public void init(GLAutoDrawable glad) { } queue = context.createDefaultQueue(); - Pointer masses = allocateFloats(particlesCount).order(context.getByteOrder()); - velocities = allocateFloats(2 * particlesCount).order(context.getByteOrder()); - interleavedColorAndPositionsTemp = allocateBytes(elementSize * particlesCount).order(context.getByteOrder()); + FloatBuffer masses = NIOUtils.directFloats(particlesCount, context.getByteOrder()); + velocities = NIOUtils.directFloats(2 * particlesCount, context.getByteOrder()); + interleavedColorAndPositionsTemp = NIOUtils.directBytes(elementSize * particlesCount, context.getByteOrder()); - Pointer positionsView = interleavedColorAndPositionsTemp.as(Float.class); + FloatBuffer positionsView = interleavedColorAndPositionsTemp.asFloatBuffer(); for (int i = 0; i < particlesCount; i++) { - masses.set(i, 0.5f + 0.5f * random.nextFloat()); + masses.put(0.5f + 0.5f * random.nextFloat()); - velocities.set(i * 2, (random.nextFloat() - 0.5f) * 0.2f); - velocities.set(i * 2 + 1, (random.nextFloat() - 0.5f) * 0.2f); + velocities.put((random.nextFloat() - 0.5f) * 0.2f); + velocities.put((random.nextFloat() - 0.5f) * 0.2f); int colorOffset = i * elementSize; int posOffset = i * (elementSize / 4) + 1; byte r = (byte)128, g = r, b = r, a = r; - interleavedColorAndPositionsTemp.set(colorOffset++, r); - interleavedColorAndPositionsTemp.set(colorOffset++, g); - interleavedColorAndPositionsTemp.set(colorOffset++, b); - interleavedColorAndPositionsTemp.set(colorOffset, a); + interleavedColorAndPositionsTemp.put(colorOffset++, r); + interleavedColorAndPositionsTemp.put(colorOffset++, g); + interleavedColorAndPositionsTemp.put(colorOffset++, b); + interleavedColorAndPositionsTemp.put(colorOffset, a); float x = (random.nextFloat() - 0.5f) * 200, y = (random.nextFloat() - 0.5f) * 200; - positionsView.set(posOffset, (float)x); - positionsView.set(posOffset + 1, y); + positionsView.put(posOffset, x); + positionsView.put(posOffset + 1, y); } - velocitiesMem = context.createBuffer(Usage.InputOutput, velocities, false); - massesMem = context.createBuffer(Usage.Input, masses, true); + velocities.rewind(); + masses.rewind(); + interleavedColorAndPositionsTemp.rewind(); + + velocitiesMem = context.createFloatBuffer(Usage.InputOutput, velocities, false); + massesMem = context.createFloatBuffer(Usage.Input, masses, true); gl.glGenBuffers(1, vbo, 0); gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); - gl.glBufferData(GL_ARRAY_BUFFER, (int) interleavedColorAndPositionsTemp.getValidBytes(), interleavedColorAndPositionsTemp.getByteBuffer(), GL2.GL_DYNAMIC_COPY); + gl.glBufferData(GL_ARRAY_BUFFER, (int) NIOUtils.getSizeInBytes(interleavedColorAndPositionsTemp), interleavedColorAndPositionsTemp, GL2.GL_DYNAMIC_COPY); gl.glBindBuffer(GL_ARRAY_BUFFER, 0); if (useOpenGLContext) { interleavedColorAndPositionsMem = context.createBufferFromGLBuffer(Usage.InputOutput, vbo[0]); } else - interleavedColorAndPositionsMem = context.createBuffer(Usage.InputOutput, interleavedColorAndPositionsTemp, false); + interleavedColorAndPositionsMem = context.createByteBuffer(Usage.InputOutput, interleavedColorAndPositionsTemp, false); String hsv2rgbSrc = IOUtils.readText(ParticlesDemo.class.getResourceAsStream("HSVtoRGB.c")); //String src = IOUtils.readText(ParticlesDemo.class.getResourceAsStream("ParticlesDemo.c")); @@ -589,7 +597,7 @@ public void display(GLAutoDrawable glad) { } else { //interleavedColorAndPositionsMem.map(queue, CLMem.MapFlags.Read); interleavedColorAndPositionsMem.read(queue, interleavedColorAndPositionsTemp, true); - gl.glBufferSubData(GL_ARRAY_BUFFER, 0, (int)interleavedColorAndPositionsTemp.getValidBytes(), interleavedColorAndPositionsTemp.getByteBuffer()); + gl.glBufferSubData(GL_ARRAY_BUFFER, 0, (int)NIOUtils.getSizeInBytes(interleavedColorAndPositionsTemp), interleavedColorAndPositionsTemp); //interleavedColorAndPositionsMem.unmap(queue, interleavedColorAndPositionsTemp); } @@ -625,7 +633,7 @@ private synchronized void updateKernelArgs() { queue, massesMem, velocitiesMem, - interleavedColorAndPositionsMem.as(Float.class), + interleavedColorAndPositionsMem.asCLFloatBuffer(), new float[] {mouseX - width / 2f, height / 2f - mouseY}, new float[] {width, height}, massFactor, diff --git a/Proxy/pom.xml b/Proxy/pom.xml deleted file mode 100644 index b9dac6ee..00000000 --- a/Proxy/pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - 4.0.0 - com.nativelibs4java - opencl-impl-proxy - JavalCL OpenCL Implementation Proxy - http://code.google.com/p/javacl/ - jar - - -Native implementation of the OpenCL API (of its Icd) that relies on a Java proxy. -That proxy channels implementations of com.nativelibs4java.opencl.library.IOpenCLLibrary discovered through the standard Java SPI discovery mechanism. -This project also contains helpers to create such implementations. - - - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - .. - - - - - com.nativelibs4java - opencl4java - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.apache.maven.plugins - maven-shade-plugin - - - full-package - package - - shade - - - ${shadedArtifactAttached} - - - - - - - - - - diff --git a/Proxy/src/main/cpp/proxy/API.c b/Proxy/src/main/cpp/proxy/API.c deleted file mode 100644 index 5c2e18d2..00000000 --- a/Proxy/src/main/cpp/proxy/API.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "API.h" - -jclass gOpenCLProxyInterface = NULL; -jmethodID gclGetPlatformIDsMethod = NULL; -jobject gOpenCLProxyImplementation = NULL; - -#define PROXIED_CLASS_SIG "com/nativelibs4java/opencl/library/ProxiedOpenCLImplementation" - -void bindJavaAPI(void *instanceData) { - jclass proxyClass = NULL; - jmethodID getProxyInstanceMethod = NULL; - jmethodID setIcdDispatchTableMethod = NULL; - JNIEnv *env = GetEnv(); - gOpenCLProxyInterface = GLOBAL_REF((*env)->FindClass(env, PROXY_INTERFACE_SIG)); - gclGetPlatformIDsMethod = (*env)->GetMethodID(env, proxyClass, "clGetPlatformIDs", "(ILL)I"); - - proxyClass = (*env)->FindClass(env, PROXIED_CLASS_SIG); - getProxyInstanceMethod = (*env)->GetStaticMethodID(env, proxyClass, "getInstance", "()L" PROXY_INTERFACE_SIG ";"); - setIcdDispatchTableMethod = (*env)->GetStaticMethodID(env, proxyClass, "setIcdDispatchTable", "(L)V" PROXIED_CLASS_SIG ";"); - - (*env)->CallStaticVoidMethod(env, proxyClass, setIcdDispatchTableMethod, (jlong)(size_t)instanceData); - gOpenCLProxyImplementation = GLOBAL_REF((*env)->CallStaticObjectMethod(env, proxyClass, getProxyInstanceMethod)); -} - -void unbindJavaAPI() { - JNIEnv *env = GetEnv(); - DEL_GLOBAL_REF(gOpenCLProxyImplementation); - DEL_GLOBAL_REF(gOpenCLProxyInterface); -} - diff --git a/Proxy/src/main/cpp/proxy/API.h b/Proxy/src/main/cpp/proxy/API.h deleted file mode 100644 index e3138ca4..00000000 --- a/Proxy/src/main/cpp/proxy/API.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __JAVACL_PROXY_API_H -#define __JAVACL_PROXY_API_H - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#include "Common.h" - -extern jclass gOpenCLProxyInterface; -extern jmethodID gclGetPlatformIDsMethod; -extern jobject gOpenCLProxyImplementation; - -void bindJavaAPI(void *instanceData); -void unbindJavaAPI(); - -#endif // __JAVACL_PROXY_API_H diff --git a/Proxy/src/main/cpp/proxy/Common.h b/Proxy/src/main/cpp/proxy/Common.h deleted file mode 100644 index 2b7e54ee..00000000 --- a/Proxy/src/main/cpp/proxy/Common.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __JAVACL_PROXY_COMMON_H -#define __JAVACL_PROXY_COMMON_H - -// /System/Library/Frameworks/OpenCL.framework/Headers/cl.h -// http://manpages.ubuntu.com/manpages/raring/man7/libOpenCL.7.html -// http://www.khronos.org/registry/cl/extensions/khr/cl_khr_icd.txt -// git clone https://forge.imag.fr/anonscm/git/ocl-icd/ocl-icd.git - -#include - -#ifdef __GNUC__ - #define JAVACL_PROXY_API - #define __cdecl - #define __stdcall -#else - #ifdef JAVACL_PROXY_EXPORTS - #define JAVACL_PROXY_API __declspec(dllexport) - #else - #define JAVACL_PROXY_API __declspec(dllimport) - #endif -#endif - -JNIEnv* GetEnv(); - -#define GLOBAL_REF(v) (*env)->NewGlobalRef(env, v) -#define DEL_GLOBAL_REF(v) (*env)->DeleteGlobalRef(env, v) - -#define PROXY_INTERFACE_SIG "com/nativelibs4java/opencl/library/IOpenCLLibrary" - -struct _cl_icd_dispatch; - -#endif // __JAVACL_PROXY_COMMON_H diff --git a/Proxy/src/main/cpp/proxy/GNUmakefile b/Proxy/src/main/cpp/proxy/GNUmakefile deleted file mode 100644 index 0996325b..00000000 --- a/Proxy/src/main/cpp/proxy/GNUmakefile +++ /dev/null @@ -1,87 +0,0 @@ -#////////////////////////////////////////////////////////////////////////////// -# -# Copyright (c) 2007,2009 Daniel Adler , -# Tassilo Philipp -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# -#////////////////////////////////////////////////////////////////////////////// - -#BUILD_CONFIG=debug - -DLL_PREFIX=lib -LD=gcc -CXX=gcc - -COMPILE_PIC = 1 - -TOP = $(DYNCALL_HOME)/dyncall -include $(DYNCALL_HOME)/dyncall/buildsys/gmake/prolog.gmake - -TARGET_DLL = javacl -INSTALL_LIB = 1 - -# uses some dyncall headers - no other dependencies. - -UNITS += API -UNITS += Proxy -UNITS += Library - -CPPFLAGS += -Werror -CPPFLAGS += -std=c99 -#CFLAGS += -g - -# Lower requirement for GLIBC version number (2.2.5) : -# objdump -p src/main/resources/org/bridj/lib/linux_x64/bridj.so | fgrep 'Version References:' -A 100 -CPPFLAGS += -U_FORTIFY_SOURCE - -ifdef BUILD_OS_darwin -#CPPFLAGS += -I/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/include -#CPPFLAGS += -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/ -CPPFLAGS += -I/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/include -CPPFLAGS += -I/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/include/darwin -LDFLAGS += -L/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/jre/lib/jli -ljli -LDFLAGS += -ldl -framework Foundation -all_load -endif - -ifdef BUILD_OS_linux -CPPFLAGS += -I/usr/lib/jvm/java-6-sun/include/ -CPPFLAGS += -I/usr/lib/jvm/java-6-sun/include/linux -CPPFLAGS += -I/usr/lib/jvm/java-6-openjdk/include/ -CPPFLAGS += -I/usr/lib/jvm/java-6-openjdk/include/linux -CPPFLAGS += -I/usr/lib/jvm/java-6-openjdk-armhf/include -CPPFLAGS += -I/usr/lib/jvm/java-6-openjdk-armhf/include/linux -CPPFLAGS += -I/usr/lib/jvm/java-6-openjdk-armel/include -CPPFLAGS += -I/usr/lib/jvm/java-6-openjdk-armel/include/linux -endif - -ifdef BUILD_OS_sunos -# http://gcc.gnu.org/onlinedocs/gcc/Solaris-2-Options.html -CPPFLAGS += -I/usr/jdk/instances/jdk1.5.0/include -CPPFLAGS += -I/usr/jdk/instances/jdk1.5.0/include/solaris -LDFLAGS += -mimpure-text -LDFLAGS += -L/opt/csw/gcc4/lib -endif - -ifdef BUILD_OS_darwin -CPPFLAGS += -mmacosx-version-min=10.4 -LDFLAGS += -mmacosx-version-min=10.4 -endif - -ifdef BUILD_CONFIG_debug -CPPFLAGS += -O0 -g -else -CPPFLAGS += -O3 -endif - -include $(DYNCALL_HOME)/dyncall/buildsys/gmake/epilog.gmake diff --git a/Proxy/src/main/cpp/proxy/Library.c b/Proxy/src/main/cpp/proxy/Library.c deleted file mode 100644 index 5694a004..00000000 --- a/Proxy/src/main/cpp/proxy/Library.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "Common.h" -#include "API.h" -#include "Proxy.h" - -JavaVM* gJVM = NULL; -#define JNI_VERSION JNI_VERSION_1_4 - -JNIEnv* GetEnv() { - JNIEnv* env = NULL; - if ((*gJVM)->GetEnv(gJVM, (void*)&env, JNI_VERSION) != JNI_OK) { - if ((*gJVM)->AttachCurrentThreadAsDaemon(gJVM, (void*)&env, NULL) != JNI_OK) { - printf("JavaCL Proxy: Cannot attach current JVM thread !\n"); - return NULL; - } - } - return env; -} - -struct _cl_icd_dispatch dispatch; - -void createJVM() { - JNIEnv *env; - JavaVMInitArgs vm_args; - JavaVMOption options; - options.optionString = "-Djava.class.path=javacl-proxy.jar"; // TODO: change this - vm_args.version = JNI_VERSION_1_6; - vm_args.nOptions = 1; - vm_args.options = &options; - vm_args.ignoreUnrecognized = 0; - JNI_CreateJavaVM(&gJVM, (void**)&env, &vm_args); - // TODO: handle errors. -} -void initializeLibrary() { - // Create JVM, based on env. OPENCL_PROXY_JAR - createJVM(); - - // Bind classes and methods. - bindJavaAPI(&gJavaCLProxyDispatch); -} - -void cleanupLibrary() { - // Unbind classes and methods - unbindJavaAPI(); - - // Stop JVM - (*gJVM)->DestroyJavaVM(gJVM); -} - diff --git a/Proxy/src/main/cpp/proxy/Make.sh b/Proxy/src/main/cpp/proxy/Make.sh deleted file mode 100644 index bd469c45..00000000 --- a/Proxy/src/main/cpp/proxy/Make.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash - -# Avoid locale in diff : -LANG=C - -SRC_HOME=${SRC_HOME:-~/src} -BIN_HOME=${BIN_HOME:-~/bin} - -cd $(dirname $0) -BRIDJ_CPP_DIR=$PWD -SCRIPTS_DIR=$PWD/../../../../../scripts - -#BUILD_CONFIG=debug sh MakeAll.sh clean -export MAKE_CMD=make -if [[ "`which gmake`" != "" ]] ; then - export MAKE_CMD=gmake ; -fi - -if [[ "$DEBUG" == "1" ]] ; then - export OUT_PATTERN=debug ; -else - export OUT_PATTERN=release ; -fi - -CURR="`pwd`" -LD=gcc -COMPILE_PIC=1 -BUILD_DIR= - -function fail() { - echo "#" - echo "# ERROR: $@" - echo "#" - exit 1 -} - -#echo BUILD_DIR = $BUILD_DIR -#echo BUILD_CONFIG = $BUILD_CONFIG -#echo LINK_DIRS = $LINK_DIRS - -#echo $DYNCALL_HOME/dyncall/$BUILD_DIR - - -#svn diff $SRC_HOME/dyncall/dyncall > dyncall.diff - -cd $DYNCALL_HOME -[[ -f $SCRIPTS_DIR/svnDiffSorted ]] || fail "no svn diff script" -$SCRIPTS_DIR/svnDiffSorted dyncall | sed "s/${DYNCALL_HOME//\//\\/}\///" > $BRIDJ_CPP_DIR/dyncall.diff -#svn diff $DYNCALL_HOME/dyncall | sed "s/${DYNCALL_HOME//\//\\/}\///" > dyncall.diff -#svn diff $SRC_HOME/dyncall/dyncall | sed "s/${HOME//\//\\/}\/src\/dyncall\///" | sed -E 's/^(---|\+\+\+)(.*)\(([^)]+)\)/\1\2/' > dyncall.diff - -echo "# Configuring dyncall" -cd "$DYNCALL_HOME/dyncall" || fail "Cannot go to DYNCALL_HOME = $DYNCALL_HOME" - -export PATH=/Developer-old/usr/bin:$PATH -if [[ -d /System/Library/Frameworks/ && ! -d /Applications/MobilePhone.app ]] ; then - # Avoid LC_DYLD_INFO (https://discussions.apple.com/thread/3197542?start=0&tstart=0) - export MACOSX_DEPLOYMENT_TARGET=10.4 - sh ./configure --target-universal || fail "Failed to configure MacOS X Universal build" -else - sh ./configure || fail "Failed to configure default build" -fi - -if [[ -z "$SHAREDLIB_SUFFIX" ]] ; then - if [[ -d /System/Library/Frameworks/ ]] ; then - SHAREDLIB_SUFFIX=dylib ; - else - SHAREDLIB_SUFFIX=so ; - fi ; -fi - -echo "# Making dyncall with '$MAKE_CMD $@'" -$MAKE_CMD $@ || fail "Failed to make dyncall" - -echo "# Making BridJ" -cd "$CURR" -$MAKE_CMD $@ || fail "Failed to make BridJ" - -echo "# Making test library" -cd "../../../test/cpp/test" -$MAKE_CMD $@ || fail "Failed to make BridJ's test library" ; - -echo "# Making dependsOnTest library" -cd "../../../test/cpp/dependsOnTest" -$MAKE_CMD $@ || fail "Failed to make BridJ's dependsOnTest library" ; - -cd "$CURR" - -if [[ -d build_out ]] ; then - cd build_out - - for D in `ls . | grep _$OUT_PATTERN` ; do - ARCH_NAME="`echo $D| sed "s/_gcc_$OUT_PATTERN//"| sed "s/_androidndk_$OUT_PATTERN//"`" - if [[ "$ARCH_NAME" == "android_arm32_arm" ]] ; then - RES_SUB="libs/armeabi" ; - elif [[ "$ARCH_NAME" == "linux_arm32_arm" && -d /lib/arm-linux-gnueabihf ]] ; then - RES_SUB="org/bridj/lib/linux_armhf" ; - elif [[ "$ARCH_NAME" == "linux_arm32_arm" && -d /lib/arm-linux-gnueabi ]] ; then - RES_SUB="org/bridj/lib/linux_armel" ; - else - RES_SUB="org/bridj/lib/$ARCH_NAME" ; - fi - MAIN_OUT="../../../resources/$RES_SUB" - - echo ARCH_NAME: $ARCH_NAME - echo RES_SUB: $RES_SUB - TEST_OUT="../../../../test/resources/$RES_SUB" - - mkdir -p $MAIN_OUT - cp $D/*.$SHAREDLIB_SUFFIX $MAIN_OUT - - mkdir -p $TEST_OUT - cp ../../../../test/cpp/test/build_out/$D/*.$SHAREDLIB_SUFFIX $TEST_OUT - cp ../../../../test/cpp/dependsOnTest/build_out/$D/*.$SHAREDLIB_SUFFIX $TEST_OUT - - nm $TEST_OUT/*.so > $TEST_OUT/test.so.nm - nm $TEST_OUT/*.dylib > $TEST_OUT/test.dylib.nm ; - - echo "Done for $D" ; - # svn add $MAIN_OUT - # svn add $TEST_OUT ; - done ; -fi diff --git a/Proxy/src/main/cpp/proxy/Proxy.c b/Proxy/src/main/cpp/proxy/Proxy.c deleted file mode 100644 index 00857690..00000000 --- a/Proxy/src/main/cpp/proxy/Proxy.c +++ /dev/null @@ -1,129 +0,0 @@ -#include "Common.h" -#include "Proxy.h" -#include "API.h" - -// AUTOGENERATED {{{ - -cl_int JAVACL_PROXY_API -JAVAclGetPlatformIDs(cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms) { - JNIEnv *env = GetEnv(); - return (cl_int)(*env)->CallIntMethod(env, gOpenCLProxyImplementation, gclGetPlatformIDsMethod, (jint)num_entries, (jlong)(size_t)platforms, (jlong)(size_t)num_platforms); -} - -// }}} AUTOGENERATED - -// See https://github.com/NatTuck/pocl/blob/master/lib/CL/pocl_icd.h -struct _cl_icd_dispatch gJavaCLProxyDispatch = { - &JAVAclGetPlatformIDs, - NULL, // &JAVAclGetPlatformInfo, - NULL, // &JAVAclGetDeviceIDs, - NULL, // &JAVAclGetDeviceInfo, - NULL, // &JAVAclCreateContext, - NULL, // &JAVAclCreateContextFromType, - NULL, // &JAVAclRetainContext, - NULL, // &JAVAclReleaseContext, - NULL, // &JAVAclGetContextInfo, - NULL, // &JAVAclCreateCommandQueue, - NULL, // &JAVAclRetainCommandQueue, - NULL, // &JAVAclReleaseCommandQueue, - NULL, // &JAVAclGetCommandQueueInfo, - NULL, // &JAVAclSetCommandQueueProperty, - NULL, // &JAVAclCreateBuffer, - NULL, // &JAVAclCreateImage2D, - NULL, // &JAVAclCreateImage3D, - NULL, // &JAVAclRetainMemObject, - NULL, // &JAVAclReleaseMemObject, - NULL, // &JAVAclGetSupportedImageFormats, - NULL, // &JAVAclGetMemObjectInfo, - NULL, // &JAVAclGetImageInfo, - NULL, // &JAVAclCreateSampler, - NULL, // &JAVAclRetainSampler, - NULL, // &JAVAclReleaseSampler, - NULL, // &JAVAclGetSamplerInfo, - NULL, // &JAVAclCreateProgramWithSource, - NULL, // &JAVAclCreateProgramWithBinary, - NULL, // &JAVAclRetainProgram, - NULL, // &JAVAclReleaseProgram, - NULL, // &JAVAclBuildProgram, - NULL, // &JAVAclUnloadCompiler, - NULL, // &JAVAclGetProgramInfo, - NULL, // &JAVAclGetProgramBuildInfo, - NULL, // &JAVAclCreateKernel, - NULL, // &JAVAclCreateKernelsInProgram, - NULL, // &JAVAclRetainKernel, - NULL, // &JAVAclReleaseKernel, - NULL, // &JAVAclSetKernelArg, - NULL, // &JAVAclGetKernelInfo, - NULL, // &JAVAclGetKernelWorkGroupInfo, - NULL, // &JAVAclWaitForEvents, - NULL, // &JAVAclGetEventInfo, - NULL, // &JAVAclRetainEvent, - NULL, // &JAVAclReleaseEvent, - NULL, // &JAVAclGetEventProfilingInfo, - NULL, // &JAVAclFlush, - NULL, // &JAVAclFinish, - NULL, // &JAVAclEnqueueReadBuffer, - NULL, // &JAVAclEnqueueWriteBuffer, - NULL, // &JAVAclEnqueueCopyBuffer, - NULL, // &JAVAclEnqueueReadImage, - NULL, // &JAVAclEnqueueWriteImage, - NULL, // &JAVAclEnqueueCopyImage, - NULL, // &JAVAclEnqueueCopyImageToBuffer, - NULL, // &JAVAclEnqueueCopyBufferToImage, - NULL, // &JAVAclEnqueueMapBuffer, - NULL, // &JAVAclEnqueueMapImage, - NULL, // &JAVAclEnqueueUnmapMemObject, - NULL, // &JAVAclEnqueueNDRangeKernel, - NULL, // &JAVAclEnqueueTask, - NULL, // &JAVAclEnqueueNativeKernel, - NULL, // &JAVAclEnqueueMarker, - NULL, // &JAVAclEnqueueWaitForEvents, - NULL, // &JAVAclEnqueueBarrier, - NULL, // &JAVAclGetExtensionFunctionAddress, - NULL, // &JAVAclCreateFromGLBuffer, - NULL, // &JAVAclCreateFromGLTexture2D, - NULL, // &JAVAclCreateFromGLTexture3D, - NULL, // &JAVAclCreateFromGLRenderbuffer, - NULL, // &JAVAclGetGLObjectInfo, - NULL, // &JAVAclGetGLTextureInfo, - NULL, // &JAVAclEnqueueAcquireGLObjects, - NULL, // &JAVAclEnqueueReleaseGLObjects, - NULL, // &JAVAclGetGLContextInfoKHR, - NULL, // &clUnknown75, - NULL, // &clUnknown76, - NULL, // &clUnknown77, - NULL, // &clUnknown78, - NULL, // &clUnknown79, - NULL, // &clUnknown80, - NULL, // &JAVAclSetEventCallback, - NULL, // &JAVAclCreateSubBuffer, - NULL, // &JAVAclSetMemObjectDestructorCallback, - NULL, // &JAVAclCreateUserEvent, - NULL, // &JAVAclSetUserEventStatus, - NULL, // &JAVAclEnqueueReadBufferRect, - NULL, // &JAVAclEnqueueWriteBufferRect, - NULL, // &JAVAclEnqueueCopyBufferRect, - NULL, // &JAVAclCreateSubDevicesEXT, - NULL, // &JAVAclRetainDeviceEXT, - NULL, // &JAVAclReleaseDeviceEXT, - NULL, // &clUnknown92, - NULL, // &JAVAclCreateSubDevices, - NULL, // &JAVAclRetainDevice, - NULL, // &JAVAclReleaseDevice, - NULL, // &JAVAclCreateImage, - NULL, // &JAVAclCreateProgramWithBuiltInKernels, - NULL, // &JAVAclCompileProgram, - NULL, // &JAVAclLinkProgram, - NULL, // &JAVAclUnloadPlatformCompiler, - NULL, // &JAVAclGetKernelArgInfo, - NULL, // &JAVAclEnqueueFillBuffer, - NULL, // &JAVAclEnqueueFillImage, - NULL, // &JAVAclEnqueueMigrateMemObjects, - NULL, // &JAVAclEnqueueMarkerWithWaitList, - NULL, // &JAVAclEnqueueBarrierWithWaitList, - NULL, // &JAVAclGetExtensionFunctionAddressForPlatform, - NULL, // &JAVAclCreateFromGLTexture, -}; - diff --git a/Proxy/src/main/cpp/proxy/Proxy.h b/Proxy/src/main/cpp/proxy/Proxy.h deleted file mode 100644 index 65998825..00000000 --- a/Proxy/src/main/cpp/proxy/Proxy.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __JAVACL_PROXY_PROXY_H -#define __JAVACL_PROXY_PROXY_H - -struct _cl_icd_dispatch { - void *funcptr[109]; -}; - -extern struct _cl_icd_dispatch gJavaCLProxyDispatch; - -#endif // __JAVACL_PROXY_PROXY_H diff --git a/Proxy/src/main/cpp/proxy/build.sh b/Proxy/src/main/cpp/proxy/build.sh deleted file mode 100755 index c716b2c9..00000000 --- a/Proxy/src/main/cpp/proxy/build.sh +++ /dev/null @@ -1,25 +0,0 @@ -export DYNCALL_HOME=../../../../../../BridJ/dyncall - -set -e - -cd $(dirname $0) -CURR="`pwd`" - -export MAKE_CMD=make -if [[ "`which gmake`" != "" ]] ; then - export MAKE_CMD=gmake ; -fi - -cd "$DYNCALL_HOME/dyncall" - -sh ./configure -#if [[ -d /System/Library/Frameworks/ && ! -d /Applications/MobilePhone.app ]] ; then -# # Avoid LC_DYLD_INFO (https://discussions.apple.com/thread/3197542?start=0&tstart=0) -# export MACOSX_DEPLOYMENT_TARGET=10.4 -# sh ./configure --target-universal -#else -# sh ./configure -#fi - -cd "$CURR" -$MAKE_CMD $@ diff --git a/README.md b/README.md deleted file mode 100644 index ff2fa27c..00000000 --- a/README.md +++ /dev/null @@ -1,32 +0,0 @@ -__BEWARE__: _This project hasn't been maintained in many years. An effort to refresh the BridJ / JNAerator / JavaCL stack is in progress (Nov 2022), with no guarantees_. - -[![Maven Central](https://img.shields.io/maven-central/v/com.nativelibs4java/javacl.svg)]() [![Build Status](https://travis-ci.org/nativelibs4java/JavaCL.svg?branch=feature_travis-build)](https://travis-ci.org/nativelibs4java/JavaCL) [![Join the chat at https://gitter.im/nativelibs4java/JavaCL](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nativelibs4java/JavaCL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -[JavaCL](http://javacl.googlecode.com) provides OpenCL bindings for Java. It wraps low-level bindings in a clean object-oriented API, which adds a few goodies. - -A comprehensive documentation is available on its [WebSite](http://javacl.googlecode.com) and [Wiki](https://code.google.com/p/javacl/wiki/FAQ?tm=6). - -It was previously hosted on [ochafik/nativelibs4java](http://github.com/ochafik/nativelibs4java). - -# Quick links - -* [CHANGELOG](./CHANGELOG.md) -* [FAQ](http://code.google.com/p/javacl/wiki/FAQ) -* [JavaDoc](http://nativelibs4java.sourceforge.net/javacl/api/stable/) -* [Credits and License](http://code.google.com/p/bridj/wiki/CreditsAndLicense) - -# Building - - ``` - git clone http://github.com/nativelibs4java/JavaCL.git - mvn clean install - ``` - -# Support - -Please use the [mailing-list](https://groups.google.com/forum/#!forum/nativelibs4java) and [file bugs](https://github.com/ochafik/nativelibs4java/issues/new). - -# TODO - -* Finalize OpenCL 1.2 support -* Push a final 1.0 version diff --git a/Tutorials/.gitignore b/Tutorials/.gitignore deleted file mode 100644 index 8e0d5325..00000000 --- a/Tutorials/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -project/boot -project/target -*~ diff --git a/Tutorials/DFT/.gitignore b/Tutorials/DFT/.gitignore deleted file mode 100644 index 8e0d5325..00000000 --- a/Tutorials/DFT/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -project/boot -project/target -*~ diff --git a/Tutorials/DFT/javacl-dft-tutorial.iml b/Tutorials/DFT/javacl-dft-tutorial.iml deleted file mode 100644 index 3fbd5899..00000000 --- a/Tutorials/DFT/javacl-dft-tutorial.iml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tutorials/Simple/.gitignore b/Tutorials/Simple/.gitignore deleted file mode 100644 index 8e0d5325..00000000 --- a/Tutorials/Simple/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -project/boot -project/target -*~ diff --git a/Tutorials/Simple/javacl-simple-tutorial.iml b/Tutorials/Simple/javacl-simple-tutorial.iml deleted file mode 100644 index c51ad6a8..00000000 --- a/Tutorials/Simple/javacl-simple-tutorial.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Tutorials/Simple/pom.xml b/Tutorials/Simple/pom.xml deleted file mode 100644 index ccbacbce..00000000 --- a/Tutorials/Simple/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - 4.0.0 - com.nativelibs4java - javacl-simple-tutorial - jar - JavaCL Simple Tutorial Archetype - - - - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - ../.. - - - diff --git a/Tutorials/Simple/src/main/resources/META-INF/maven/archetype-metadata.xml b/Tutorials/Simple/src/main/resources/META-INF/maven/archetype-metadata.xml deleted file mode 100644 index 17ff875b..00000000 --- a/Tutorials/Simple/src/main/resources/META-INF/maven/archetype-metadata.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - JavaCLTutorial - - - - com.mycompany - - - - com.mycompany - - - - - - - - src/main/java - - **/*.java - - - - - src/main/opencl - - **/*.cl - - - - - diff --git a/Tutorials/Simple/src/main/resources/archetype-resources/.gitignore b/Tutorials/Simple/src/main/resources/archetype-resources/.gitignore deleted file mode 100644 index 8e0d5325..00000000 --- a/Tutorials/Simple/src/main/resources/archetype-resources/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -project/boot -project/target -*~ diff --git a/Tutorials/Simple/src/main/resources/archetype-resources/pom.xml b/Tutorials/Simple/src/main/resources/archetype-resources/pom.xml deleted file mode 100644 index ca7ddbd9..00000000 --- a/Tutorials/Simple/src/main/resources/archetype-resources/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - 4.0.0 - JavaCL Tutorial - ${groupId} - ${artifactId} - ${version} - jar - - - - sonatype - Sonatype OSS Snapshots Repository - http://oss.sonatype.org/content/groups/public - - - - - - sonatype - Sonatype OSS Snapshots Repository - http://oss.sonatype.org/content/groups/public - - - - - - com.nativelibs4java - javacl - 1.0-SNAPSHOT - - - - - - - - com.nativelibs4java - maven-javacl-plugin - 1.0-SNAPSHOT - - - - compile - - - - - - - diff --git a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial1.java b/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial1.java deleted file mode 100644 index ae588769..00000000 --- a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial1.java +++ /dev/null @@ -1,54 +0,0 @@ -package ${package}; - -import com.nativelibs4java.opencl.*; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.util.*; -import com.nativelibs4java.util.*; -import org.bridj.Pointer; -import java.nio.ByteOrder; -import static org.bridj.Pointer.*; -import static java.lang.Math.*; -import java.io.IOException; - -public class JavaCLTutorial1 { - public static void main(String[] args) throws IOException { - CLContext context = JavaCL.createBestContext(); - CLQueue queue = context.createDefaultQueue(); - ByteOrder byteOrder = context.getByteOrder(); - - int n = 1024; - Pointer - aPtr = allocateFloats(n).order(byteOrder), - bPtr = allocateFloats(n).order(byteOrder); - - for (int i = 0; i < n; i++) { - aPtr.set(i, (float)cos(i)); - bPtr.set(i, (float)sin(i)); - } - - // Create OpenCL input buffers (using the native memory pointers aPtr and bPtr) : - CLBuffer - a = context.createFloatBuffer(Usage.Input, aPtr), - b = context.createFloatBuffer(Usage.Input, bPtr); - - // Create an OpenCL output buffer : - CLBuffer out = context.createFloatBuffer(Usage.Output, n); - - // Read the program sources and compile them : - String src = IOUtils.readText(JavaCLTutorial1.class.getResource("TutorialKernels.cl")); - CLProgram program = context.createProgram(src); - - // Get and call the kernel : - CLKernel addFloatsKernel = program.createKernel("add_floats"); - addFloatsKernel.setArgs(a, b, out, n); - int[] globalSizes = new int[] { n }; - CLEvent addEvt = addFloatsKernel.enqueueNDRange(queue, globalSizes); - - Pointer outPtr = out.read(queue, addEvt); // blocks until add_floats finished - - // Print the first 10 output values : - for (int i = 0; i < 10 && i < n; i++) - System.out.println("out[" + i + "] = " + outPtr.get(i)); - - } -} \ No newline at end of file diff --git a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial2.java b/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial2.java deleted file mode 100644 index 18467f2a..00000000 --- a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial2.java +++ /dev/null @@ -1,48 +0,0 @@ -package ${package}; - -import com.nativelibs4java.opencl.*; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.util.*; -import com.nativelibs4java.util.*; -import org.bridj.Pointer; -import java.nio.ByteOrder; -import static org.bridj.Pointer.*; -import static java.lang.Math.*; -import java.io.IOException; - -public class JavaCLTutorial2 { - public static void main(String[] args) throws IOException { - CLContext context = JavaCL.createBestContext(); - CLQueue queue = context.createDefaultQueue(); - ByteOrder byteOrder = context.getByteOrder(); - - int n = 1024; - Pointer - aPtr = allocateFloats(n).order(byteOrder), - bPtr = allocateFloats(n).order(byteOrder); - - for (int i = 0; i < n; i++) { - aPtr.set(i, (float)cos(i)); - bPtr.set(i, (float)sin(i)); - } - - // Create OpenCL input buffers (using the native memory pointers aPtr and bPtr) : - CLBuffer - a = context.createFloatBuffer(Usage.Input, aPtr), - b = context.createFloatBuffer(Usage.Input, bPtr); - - // Create an OpenCL output buffer : - CLBuffer out = context.createFloatBuffer(Usage.Output, n); - - TutorialKernels kernels = new TutorialKernels(context); - int[] globalSizes = new int[] { n }; - CLEvent addEvt = kernels.add_floats(queue, a, b, out, n, globalSizes, null); - - Pointer outPtr = out.read(queue, addEvt); // blocks until add_floats finished - - // Print the first 10 output values : - for (int i = 0; i < 10 && i < n; i++) - System.out.println("out[" + i + "] = " + outPtr.get(i)); - - } -} diff --git a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial3.java b/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial3.java deleted file mode 100644 index c5d27776..00000000 --- a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/java/JavaCLTutorial3.java +++ /dev/null @@ -1,37 +0,0 @@ -package ${package}; - -import com.nativelibs4java.opencl.*; -import com.nativelibs4java.opencl.CLMem.Usage; -import com.nativelibs4java.opencl.util.*; -import com.nativelibs4java.util.*; -import org.bridj.Pointer; -import static org.bridj.Pointer.*; -import static java.lang.Math.*; -import java.io.IOException; - -public class JavaCLTutorial3 { - public static void main(String[] args) throws IOException { - CLContext context = JavaCL.createBestContext(); - CLQueue queue = context.createDefaultQueue(); - - int n = 1024; - - // Create OpenCL input and output buffers - CLBuffer - a = context.createFloatBuffer(Usage.InputOutput, n), // a and b and read AND written to - b = context.createFloatBuffer(Usage.InputOutput, n), - out = context.createFloatBuffer(Usage.Output, n); - - TutorialKernels kernels = new TutorialKernels(context); - int[] globalSizes = new int[] { n }; - CLEvent fillEvt = kernels.fill_in_values(queue, a, b, n, globalSizes, null); - CLEvent addEvt = kernels.add_floats(queue, a, b, out, n, globalSizes, null, fillEvt); - - Pointer outPtr = out.read(queue, addEvt); // blocks until add_floats finished - - // Print the first 10 output values : - for (int i = 0; i < 10 && i < n; i++) - System.out.println("out[" + i + "] = " + outPtr.get(i)); - - } -} diff --git a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/opencl/TutorialKernels.cl b/Tutorials/Simple/src/main/resources/archetype-resources/src/main/opencl/TutorialKernels.cl deleted file mode 100644 index d3ac14a1..00000000 --- a/Tutorials/Simple/src/main/resources/archetype-resources/src/main/opencl/TutorialKernels.cl +++ /dev/null @@ -1,18 +0,0 @@ -__kernel void add_floats(__global const float* a, __global const float* b, __global float* out, int n) -{ - int i = get_global_id(0); - if (i >= n) - return; - - out[i] = a[i] + b[i]; -} - -__kernel void fill_in_values(__global float* a, __global float* b, int n) -{ - int i = get_global_id(0); - if (i >= n) - return; - - a[i] = cos((float)i); - b[i] = sin((float)i); -} \ No newline at end of file diff --git a/Tutorials/javacl-tutorials-root.iml b/Tutorials/javacl-tutorials-root.iml deleted file mode 100644 index d4bc3aaf..00000000 --- a/Tutorials/javacl-tutorials-root.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Tutorials/pom.xml b/Tutorials/pom.xml deleted file mode 100644 index 26693e89..00000000 --- a/Tutorials/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - 4.0.0 - com.nativelibs4java - javacl-tutorials-root - pom - JavaCL Tutorials Root / BridJ - - - com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT - .. - - - - DFT - Simple - - diff --git a/buildWebStartArtifacts.sh b/buildWebStartArtifacts.sh deleted file mode 100755 index 25102b83..00000000 --- a/buildWebStartArtifacts.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -mvn -Pwebstart -Dstorepass=$KEYSTORE_PASS -DskipTests clean install || exit 1 - -rm -fR target-webstart -mkdir target-webstart -cd target-webstart - -for SUB in InteractiveImageDemo Demos OpenGLDemos ; do - cp ../$SUB/target/*-shaded.jar . || exit 1 -done - -open . -open /Applications/Cyberduck.app/ || exit 1 - diff --git a/opencl4java-root-bridj.iml b/opencl4java-root-bridj.iml deleted file mode 100644 index 467882a0..00000000 --- a/opencl4java-root-bridj.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/opencl4java-root.iml b/opencl4java-root.iml deleted file mode 100644 index d4bc3aaf..00000000 --- a/opencl4java-root.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/patchFromBridJ b/patchFromBridJ new file mode 100644 index 00000000..f418b5ec --- /dev/null +++ b/patchFromBridJ @@ -0,0 +1,8 @@ +#!/bin/bash +DIFF_FILE=OpenCL-`date '+%Y%m%d'`.diff + +cd ../OpenCL +svn diff > $DIFF_FILE + +cd ../OpenCL-JNA +patch -p0 < ../OpenCL-JNA/$DIFF_FILE diff --git a/pom.xml b/pom.xml index 3954c537..3df5d8e9 100644 --- a/pom.xml +++ b/pom.xml @@ -2,149 +2,95 @@ 4.0.0 com.nativelibs4java - javacl-parent - 1.0-SNAPSHOT + javacl-parent-jna + 1.0.0-RC4 pom - JavaCL Parent Project + Legacy JavaCL-JNA Parent Project 2009 http://code.google.com/p/nativelibs4java/wiki/OpenCL + + + 1.0.0-RC4 + com.nativelibs4java nativelibs4java-parent - 1.10-SNAPSHOT + 1.9 + .. - - - - sonatype - Sonatype OSS Snapshots Repository - http://oss.sonatype.org/content/groups/public - - - - - - sonatype - Sonatype OSS Snapshots Repository - http://oss.sonatype.org/content/groups/public - - - - - - junit - junit - 4.12 - test - - - - - 0.7.1-SNAPSHOT - 0.13-SNAPSHOT - - - - scm:git:git@github.com:nativelibs4java/JavaCL.git - scm:git:git@github.com:nativelibs4java/JavaCL.git - http://github.com/nativelibs4java/JavaCL - + + + OpenCL4Java, JavaCL and ScalaCL are OpenCL binding libraries for the Java platform. + - LibCL InteractiveImageDemo Generator - MavenPlugin OpenCL4Java Demos JavaCL Core - Blas OpenGLDemos - Tutorials + JavaCLTutorial - - - regenerate - - false - - - com.nativelibs4java - opencl4java - ${project.version} - - - com.nativelibs4java - javacl-blas - ${project.version} - - - com.nativelibs4java - javacl-core - ${project.version} - - - com.nativelibs4java - javacl-demos + libcl ${project.version} com.nativelibs4java - javacl-numerical-benchmark + opencl4java-jna ${project.version} com.nativelibs4java - javacl-generator + javacl-blas-jna ${project.version} com.nativelibs4java - javacl-opengl-demos + javacl-core-jna ${project.version} com.nativelibs4java - javacl + javacl-demos-jna ${project.version} com.nativelibs4java - javacl-tutorials-root + javacl-numerical-benchmark-jna ${project.version} com.nativelibs4java - javacl-dft-tutorial + javacl-generator-jna ${project.version} com.nativelibs4java - javacl-simple-tutorial + javacl-opengl-demos-jna ${project.version} com.nativelibs4java - maven-javacl-plugin + javacl-jna ${project.version} com.nativelibs4java - libcl + javacl-tutorial-jna ${project.version} - com.nativelibs4java jnaerator - ${jnaerator.version} + ${jnaerator.version} @@ -168,5 +114,5 @@ + -