/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueMapBuffer.html">clEnqueueMapBuffer</a>.<br> * @param queue Execution queue for this operation. * @param flags Map flags. * @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. * @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}. */ public Pair<Pointer<T>, CLEvent> mapLater(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { return map(queue, flags, 0, getElementCount(), false, eventsToWaitFor); } /**
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueMapBuffer.html">clEnqueueMapBuffer</a>.<br> * @param queue Execution queue for this operation. * @param flags Map flags. * @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. * @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}. */ public Pair<Pointer<T>, CLEvent> mapLater(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { return map(queue, flags, 0, getElementCount(), false, eventsToWaitFor); } /**
/** * enqueues a command to copy a buffer object identified by src_buffer to another buffer object identified by destination. * @param destination destination buffer object * @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. * @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}. */ public CLEvent copyTo(CLQueue queue, CLMem destination, CLEvent... eventsToWaitFor) { return copyTo(queue, 0, getElementCount(), destination, 0, eventsToWaitFor); }
@Override public Pointer<B> reduce(CLQueue queue, CLBuffer<B> input, CLEvent... eventsToWaitFor) { return reduce(queue, input, input.getElementCount(), DEFAULT_MAX_REDUCTION_SIZE, eventsToWaitFor); } @Override
@Override public CLEvent transform(CLQueue queue, CLBuffer<T> inBuf, CLBuffer<T> outBuf, boolean inverse, CLEvent... eventsToWaitFor) throws CLException { int length = (int)inBuf.getElementCount() / 2; return dft(queue, inBuf, outBuf, length, inverse ? -1 : 1, new int[]{length}, eventsToWaitFor); } }
/** * enqueues a command to copy a buffer object identified by src_buffer to another buffer object identified by destination. * @param destination destination buffer object * @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. * @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}. */ public CLEvent copyTo(CLQueue queue, CLMem destination, CLEvent... eventsToWaitFor) { return copyTo(queue, 0, getElementCount(), destination, 0, eventsToWaitFor); }
@Override public CLEvent transform(CLQueue queue, CLBuffer<T> inBuf, CLBuffer<T> outBuf, boolean inverse, CLEvent... eventsToWaitFor) throws CLException { int length = (int)inBuf.getElementCount() / 2; return dft(queue, inBuf, outBuf, length, inverse ? -1 : 1, new int[]{length}, eventsToWaitFor); } }
@Override public Pointer<B> reduce(CLQueue queue, CLBuffer<B> input, CLEvent... eventsToWaitFor) { return reduce(queue, input, input.getElementCount(), DEFAULT_MAX_REDUCTION_SIZE, eventsToWaitFor); } @Override
public <T> CLEvent op2(Primitive prim, Fun2 fun, CLBuffer<T> a, CLBuffer<T> b, long rows, long columns, long stride, CLBuffer<T> 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<T>)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 <T> CLEvent op2(Primitive prim, Fun2 fun, CLBuffer<T> a, T b, long rows, long columns, long stride, CLBuffer<T> 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<T>)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; } }
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueFillBuffer.html">clEnqueueFillBuffer</a>.<br> * @param queue Execution queue for this operation. * @param pattern Data pattern to fill the buffer with. * @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. * @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}. */ public CLEvent fillBuffer(CLQueue queue, Pointer<T> pattern, CLEvent... eventsToWaitFor) { return fillBuffer(queue, pattern, pattern.getValidElements(), 0, getElementCount(), eventsToWaitFor); }
@Override public CLEvent transform(CLQueue queue, CLBuffer<T> inBuf, CLBuffer<T> outBuf, boolean inverse, CLEvent... eventsToWaitFor) throws CLException { int length = (int)inBuf.getElementCount() / 2; if (Integer.bitCount(length) != 1) throw new UnsupportedOperationException("Only supports FFTs of power-of-two-sized arrays (was given array of length " + length + ")"); CLBuffer<Integer> 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; } private CLEvent fft(CLQueue queue, CLBuffer<T> X, int N, int s, int inverse, int blocks, CLBuffer<T> Y, CLEvent... eventsToWaitFor) throws CLException {
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueMapBuffer.html">clEnqueueMapBuffer</a>.<br> * @param queue Execution queue for this operation. * @param flags Map flags. * @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. * @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}. */ public Pointer<T> map(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { return map(queue, flags, 0, getElementCount(), true, eventsToWaitFor).getFirst(); } /**
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueMapBuffer.html">clEnqueueMapBuffer</a>.<br> * @param queue Execution queue for this operation. * @param flags Map flags. * @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. * @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}. */ public Pointer<T> map(CLQueue queue, MapFlags flags, CLEvent... eventsToWaitFor) throws CLException.MapFailure { return map(queue, flags, 0, getElementCount(), true, eventsToWaitFor).getFirst(); } /**
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueFillBuffer.html">clEnqueueFillBuffer</a>.<br> * @param queue Execution queue for this operation. * @param pattern Data pattern to fill the buffer with. * @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. * @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}. */ public CLEvent fillBuffer(CLQueue queue, Pointer<T> pattern, CLEvent... eventsToWaitFor) { return fillBuffer(queue, pattern, pattern.getValidElements(), 0, getElementCount(), eventsToWaitFor); }
@Override public CLEvent transform(CLQueue queue, CLBuffer<T> inBuf, CLBuffer<T> outBuf, boolean inverse, CLEvent... eventsToWaitFor) throws CLException { int length = (int)inBuf.getElementCount() / 2; if (Integer.bitCount(length) != 1) throw new UnsupportedOperationException("Only supports FFTs of power-of-two-sized arrays (was given array of length " + length + ")"); CLBuffer<Integer> 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; } private CLEvent fft(CLQueue queue, CLBuffer<T> X, int N, int s, int inverse, int blocks, CLBuffer<T> Y, CLEvent... eventsToWaitFor) throws CLException {
/** * Returns a pointer to native memory large enough for this buffer's data, and with a compatible byte ordering. */ public Pointer<T> allocateCompatibleMemory(CLDevice device) { return allocateArray(io, getElementCount()).order(device.getKernelsDefaultByteOrder()); }
/** * Returns a pointer to native memory large enough for this buffer's data, and with a compatible byte ordering. */ public Pointer<T> allocateCompatibleMemory(CLDevice device) { return allocateArray(io, getElementCount()).order(device.getKernelsDefaultByteOrder()); }
public CLEvent perform(CLEvent[] events) { ret[0] = getMatrix().getKernels().containsValue(getMatrix().getPrimitive(), getMatrix().getBuffer(), getMatrix().getBuffer().getElementCount(), value, events); return null; } });
public CLEvent perform(CLEvent[] events) { return getMatrix().getKernels().clear(getMatrix().getPrimitive(), getMatrix().getBuffer(), getMatrix().getBuffer().getElementCount(), events); } });