当前位置: 首页>>代码示例>>Java>>正文


Java CLEvent.release方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:apemanzilla,项目名称:turbokrist,代码行数:24,代码来源:GPUMiner.java

示例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();
}
 
开发者ID:apemanzilla,项目名称:JCLMiner,代码行数:61,代码来源:GPUMiner.java


注:本文中的com.nativelibs4java.opencl.CLEvent.release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。