本文整理汇总了Java中com.nativelibs4java.opencl.CLMem.Usage类的典型用法代码示例。如果您正苦于以下问题:Java Usage类的具体用法?Java Usage怎么用?Java Usage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Usage类属于com.nativelibs4java.opencl.CLMem包,在下文中一共展示了Usage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: kernel_381446705
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_381446705(int paramInt1, int[] paramArrayOfInt, int paramInt2)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_381446705 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
CLBuffer localCLBuffer = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToInts(paramArrayOfInt), true);
int i = paramInt2;
localCLKernel.setArgs(new Object[] { paramInt1, localCLBuffer, i });
int j = paramInt1 - paramInt2 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { j }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer.read(localCLQueue, new CLEvent[] { localCLEvent }).getInts(paramArrayOfInt);
}
示例2: kernel_1780824482
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_1780824482(int paramInt1, int paramInt2, float[] paramArrayOfFloat, int paramInt3)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_1780824482 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
int i = paramInt2;
CLBuffer localCLBuffer = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToFloats(paramArrayOfFloat), true);
int j = paramInt3;
localCLKernel.setArgs(new Object[] { paramInt1, i, localCLBuffer, j });
int k = paramInt1 - paramInt2 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { k }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer.read(localCLQueue, new CLEvent[] { localCLEvent }).getFloats(paramArrayOfFloat);
}
示例3: kernel_112397371
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_112397371(int paramInt1, int paramInt2, int paramInt3, float paramFloat, int paramInt4, int paramInt5, int paramInt6, short[] paramArrayOfShort)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_112397371 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
int i = paramInt3;
float f = paramFloat;
int j = paramInt4;
int k = paramInt5;
int m = paramInt6;
CLBuffer localCLBuffer = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToShorts(paramArrayOfShort), true);
localCLKernel.setArgs(new Object[] { paramInt1, paramInt2, i, f, j, k, m, localCLBuffer });
int n = paramInt1 - paramInt4 / 1;
int i1 = paramInt2 - paramInt5 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { n, i1 }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer.read(localCLQueue, new CLEvent[] { localCLEvent }).getShorts(paramArrayOfShort);
}
示例4: kernel_1817842420
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_1817842420(int paramInt1, int paramInt2, float[] paramArrayOfFloat, int paramInt3, int paramInt4, byte[] paramArrayOfByte1, int paramInt5, int paramInt6, byte[] paramArrayOfByte2, int paramInt7)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_1817842420 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
int i = paramInt2;
CLBuffer localCLBuffer1 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToFloats(paramArrayOfFloat), true);
int j = paramInt3;
int k = paramInt4;
CLBuffer localCLBuffer2 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToBytes(paramArrayOfByte1), true);
int m = paramInt5;
int n = paramInt6;
CLBuffer localCLBuffer3 = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToBytes(paramArrayOfByte2), true);
int i1 = paramInt7;
localCLKernel.setArgs(new Object[] { paramInt1, i, localCLBuffer1, j, k, localCLBuffer2, m, n, localCLBuffer3, i1 });
int i2 = paramInt1 - paramInt6 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { i2 }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer3.read(localCLQueue, new CLEvent[] { localCLEvent }).getBytes(paramArrayOfByte2);
}
示例5: kernel_539791456
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_539791456(int paramInt1, int paramInt2, int paramInt3, int paramInt4, float[] paramArrayOfFloat1, float paramFloat, float[] paramArrayOfFloat2, int paramInt5)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_539791456 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
int i = paramInt2;
int j = paramInt3;
int k = paramInt4;
CLBuffer localCLBuffer1 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToFloats(paramArrayOfFloat1), true);
float f = paramFloat;
CLBuffer localCLBuffer2 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToFloats(paramArrayOfFloat2), true);
int m = paramInt5;
localCLKernel.setArgs(new Object[] { paramInt1, i, j, k, localCLBuffer1, f, localCLBuffer2, m });
int n = paramInt1 - paramInt2 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { n }, arrayOfCLEvent);
localCLQueue.finish();
}
示例6: kernel_1983995535
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_1983995535(int paramInt1, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, float paramFloat5, float paramFloat6, float paramFloat7, int paramInt2, float paramFloat8, float[] paramArrayOfFloat)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_1983995535 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
float f1 = paramFloat1;
float f2 = paramFloat2;
float f3 = paramFloat3;
float f4 = paramFloat4;
float f5 = paramFloat5;
float f6 = paramFloat6;
float f7 = paramFloat7;
int i = paramInt2;
float f8 = paramFloat8;
CLBuffer localCLBuffer = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToFloats(paramArrayOfFloat), true);
localCLKernel.setArgs(new Object[] { paramInt1, f1, f2, f3, f4, f5, f6, f7, i, f8, localCLBuffer });
int j = paramInt1 - paramInt2 / 3;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { j }, arrayOfCLEvent);
localCLQueue.finish();
}
示例7: kernel_741680667
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_741680667(int paramInt1, int paramInt2, float[] paramArrayOfFloat)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_741680667 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
int i = paramInt2;
CLBuffer localCLBuffer = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToFloats(paramArrayOfFloat), true);
localCLKernel.setArgs(new Object[] { paramInt1, i, localCLBuffer });
int j = paramInt1 - paramInt2 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { j }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer.read(localCLQueue, new CLEvent[] { localCLEvent }).getFloats(paramArrayOfFloat);
}
示例8: kernel_M382277171
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_M382277171(int paramInt1, int paramInt2, int[][] paramArrayOfInt1, int paramInt3, int paramInt4, int[][] paramArrayOfInt2, int[][] paramArrayOfInt3)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_M382277171 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
CLBuffer localCLBuffer1 = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToInts(paramArrayOfInt1), true);
int i = paramInt3;
int j = paramInt4;
CLBuffer localCLBuffer2 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToInts(paramArrayOfInt2), true);
CLBuffer localCLBuffer3 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToInts(paramArrayOfInt3), true);
localCLKernel.setArgs(new Object[] { paramInt1, paramInt2, localCLBuffer1, i, j, localCLBuffer2, localCLBuffer3 });
int k = paramInt1 - paramInt3 / 1;
int m = paramInt2 - paramInt4 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { k, m }, arrayOfCLEvent);
localCLQueue.finish();
Pointer localPointer1 = localCLBuffer1.read(localCLQueue, new CLEvent[] { localCLEvent });
long l = localPointer1.getValidElements();
for (int n = 0; n < l; n++)
{
Pointer localPointer2 = (Pointer)localPointer1.get(n);
localPointer2.getInts(paramArrayOfInt1[n]);
}
}
示例9: kernel_2128203651
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_2128203651(int paramInt1, int[] paramArrayOfInt, int paramInt2)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_2128203651 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
CLBuffer localCLBuffer = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToInts(paramArrayOfInt), true);
int i = paramInt2;
localCLKernel.setArgs(new Object[] { paramInt1, localCLBuffer, i });
int j = paramInt1 - paramInt2 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { j }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer.read(localCLQueue, new CLEvent[] { localCLEvent }).getInts(paramArrayOfInt);
}
示例10: kernel_1507237915
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_1507237915(int paramInt1, int[] paramArrayOfInt, int paramInt2)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_1507237915 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
CLBuffer localCLBuffer = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToInts(paramArrayOfInt), true);
int i = paramInt2;
localCLKernel.setArgs(new Object[] { paramInt1, localCLBuffer, i });
int j = paramInt1 - paramInt2 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { j }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer.read(localCLQueue, new CLEvent[] { localCLEvent }).getInts(paramArrayOfInt);
}
示例11: GPUMiner
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
/**
* Creates a GPUMiner object. This constructor should not be used - you
* should instead use {@link
* me.apemanzilla.krist.turbokrist.miners.MinerFactory}.
*
* @param dev @param options @throws MinerInitException
*/
GPUMiner(CLDevice dev, MinerOptions options) throws MinerInitException {
this.deviceName = dev.getName().trim();
this.context = dev.getPlatform().createContext(null, new CLDevice[] { dev });
this.queue = context.createDefaultQueue();
ProgramBuilder pb = new ProgramBuilder("sha256.cl", "krist_miner.cl");
CLProgram program;
try {
program = pb.build(context);
} catch (ProgramBuildException e) {
e.printStackTrace();
throw new MinerInitException("Failed to build OpenCL program");
}
this.kernel = program.createKernel("krist_miner_basic");
Pointer<Byte> addressPtr = Pointer.allocateBytes(10).order(context.getByteOrder());
byte[] addressBytes = MinerUtils.getBytes(options.getKristAddress().getName());
addressPtr.setArray(addressBytes);
this.addressBuffer = context.createByteBuffer(Usage.Input, addressPtr);
this.workSize = new int[] { options.getWorkSize(MinerFactory.generateSignature(dev)) };
}
示例12: testMining_hashToLong
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
@Test
public void testMining_hashToLong() {
String[] inputs = { "", "hello", "hi", "ADLGeag3" };
CLKernel kernel = program.createKernel("testHashToLong");
for (String input : inputs) {
byte[] hashed = MinerUtils.digest(MinerUtils.getBytes(input));
Pointer<Byte> inputPtr = Pointer.allocateBytes(hashed.length).order(context.getByteOrder());
for (int i = 0; i < hashed.length; i++) {
inputPtr.set(i, hashed[i]);
}
CLBuffer<Byte> inputBuf = context.createByteBuffer(Usage.Input, inputPtr);
CLBuffer<Long> outputBuf = context.createLongBuffer(Usage.Output, 1);
kernel.setArgs(inputBuf, outputBuf);
CLEvent evt = kernel.enqueueNDRange(queue, new int[] { 1 });
Pointer<Long> outputPtr = outputBuf.read(queue, evt);
long expect = MinerUtils.hashToLong(hashed);
long got = outputPtr.get(0);
assertEquals(expect, got);
}
}
示例13: testMacro_RR
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
/**
* Tests whether the RR macro (rotate right) is producing expected results -
* compares output from OpenCL to Java's results
*/
@Test
public void testMacro_RR() {
int[] input = { 1, 5, -20, -190, 40, Integer.MAX_VALUE, Integer.MIN_VALUE, 0 };
int[] dist = new int[input.length];
for (int i = 0; i < dist.length; i++)
dist[i] = 1;
Pointer<Integer> inputPtr = Pointer.allocateInts(input.length).order(context.getByteOrder()),
distPtr = Pointer.allocateInts(input.length).order(context.getByteOrder());
for (int i = 0; i < input.length; i++) {
inputPtr.set(i, input[i]);
// default value should be 1
distPtr.set(i, dist[i]);
}
CLBuffer<Integer> inputBuf = context.createIntBuffer(Usage.Input, inputPtr),
distBuf = context.createIntBuffer(Usage.Input, distPtr),
outputBuf = context.createIntBuffer(Usage.Output, input.length);
CLKernel kernel = program.createKernel("testRR", inputBuf, distBuf, outputBuf, input.length);
CLEvent evt = kernel.enqueueNDRange(queue, new int[] { input.length });
Pointer<Integer> outputPtr = outputBuf.read(queue, evt);
for (int i = 0; i < input.length; i++) {
int got = outputPtr.get(i).intValue(), expected = Integer.rotateRight(input[i], dist[i]);
assertEquals(String.format("Got %d, expected %d", got, expected), expected, got);
}
}
示例14: testMining_hashToLong
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
@Test
public void testMining_hashToLong() {
String[] inputs = {"","hello","hi","ADLGeag3"};
CLKernel kernel = program.createKernel("testHashToLong");
for (String input : inputs) {
byte[] hashed = MinerUtils.digest(MinerUtils.getBytes(input));
Pointer<Byte> inputPtr = Pointer.allocateBytes(hashed.length).order(context.getByteOrder());
for (int i = 0; i < hashed.length; i++) {
inputPtr.set(i, hashed[i]);
}
CLBuffer<Byte> inputBuf = context.createByteBuffer(Usage.Input, inputPtr);
CLBuffer<Long> outputBuf = context.createLongBuffer(Usage.Output, 1);
kernel.setArgs(inputBuf, outputBuf);
CLEvent evt = kernel.enqueueNDRange(queue, new int[] {1});
Pointer<Long> outputPtr = outputBuf.read(queue, evt);
long expect = MinerUtils.hashToLong(hashed);
long got = outputPtr.get(0);
assertEquals(expect, got);
}
}
示例15: testArg
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public <T> Pointer<T> testArg(String type, Object value, Class<T> targetType) {
long size = BridJ.sizeOf(targetType);
CLBuffer<Byte> 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);
}