本文整理汇总了Java中com.nativelibs4java.opencl.CLEvent.release方法的典型用法代码示例。如果您正苦于以下问题:Java CLEvent.release方法的具体用法?Java CLEvent.release怎么用?Java CLEvent.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nativelibs4java.opencl.CLEvent
的用法示例。
在下文中一共展示了CLEvent.release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.nativelibs4java.opencl.CLEvent; //导入方法依赖的package包/类
@Override
public void run() {
long base = 0;
kernel.setArgs(addressBuffer, blockBuffer, prefixBuffer, base, work, outputBuffer);
while (run) {
CLEvent mine = kernel.enqueueNDRange(queue, workSize);
Pointer<Byte> outputPtr = outputBuffer.read(queue, mine);
mine.release();
hashes += workSize[0];
base += workSize[0];
if (outputPtr.getByteAtIndex(0) != 0 && run) {
char[] sol = MinerUtils.getChars(outputPtr.getBytes());
long score = MinerUtils.hashToLong(MinerUtils.digest(MinerUtils.getBytes(new String(sol))));
if (score <= work) {
Solution s = new Solution(new String(Arrays.copyOfRange(sol, 0, 10)),
new String(Arrays.copyOfRange(sol, 10, 22)), new String(Arrays.copyOfRange(sol, 22, 34)));
solved(s);
break;
}
}
kernel.setArg(3, base);
}
}
示例2: run
import com.nativelibs4java.opencl.CLEvent; //导入方法依赖的package包/类
@Override
public void run() {
// TODO make this a lot better
int range = this.range;
long base = 0;
Pointer<Byte> addressPtr = Pointer.allocateBytes(10).order(ctx.getByteOrder());
byte[] addressBytes = MinerUtils.getBytes(address);
for (int i = 0; i < 10; i ++) {
addressPtr.set(i, addressBytes[i]);
}
Pointer<Byte> blockPtr = Pointer.allocateBytes(12).order(ctx.getByteOrder());
byte[] blockBytes = MinerUtils.getBytes(lastBlock);
for (int i = 0; i < 12; i++) {
blockPtr.set(i, blockBytes[i]);
}
Pointer<Byte> prefixPtr = Pointer.allocateBytes(2).order(ctx.getByteOrder());
byte[] prefixBytes = MinerUtils.getBytes(prefix);
for (int i = 0; i < 2; i++) {
prefixPtr.set(i, prefixBytes[i]);
}
CLBuffer<Byte>
addressBuf = ctx.createByteBuffer(Usage.Input, addressPtr),
blockBuf = ctx.createByteBuffer(Usage.Input, blockPtr),
prefixBuf = ctx.createByteBuffer(Usage.Input, prefixPtr);
CLBuffer<Byte> outputBuf = ctx.createByteBuffer(Usage.Output, 34);
while (!Thread.interrupted()) {
kernel.setArgs(addressBuf, blockBuf, prefixBuf, base, work, outputBuf);
try {
CLEvent evt = kernel.enqueueNDRange(queue, new int[] {range});
Pointer<Byte> outputPtr = outputBuf.read(queue, evt);
evt.release();
if (outputPtr.get(0) != 0 && !Thread.interrupted()) {
// try solution
byte[] output = new byte[34];
for (int i = 0; i < 34; i++) {
output[i] = outputPtr.get(i);
}
long score = MinerUtils.hashToLong(MinerUtils.digest(output));
if (score <= work) {
byte[] c = new byte[12];
System.arraycopy(output, 22, c, 0, 12);
solution = new String(MinerUtils.getChars(c));
setChanged();
notifyObservers();
outputPtr.release();
break;
}
}
outputPtr.release();
base += range;
hashes += range;
} catch (CLException e) {
controller.interrupt();
}
}
addressBuf.release();
blockBuf.release();
prefixBuf.release();
outputBuf.release();
}