本文整理汇总了Java中com.nativelibs4java.opencl.CLMem.Usage类的典型用法代码示例。如果您正苦于以下问题:Java Usage类的具体用法?Java Usage怎么用?Java Usage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Usage类属于com.nativelibs4java.opencl.CLMem包,在下文中一共展示了Usage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:17,代码来源:LoopWithMultipleConditionsInBody.java
示例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);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:18,代码来源:BlackScholes.java
示例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);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:22,代码来源:Mandelbrot.java
示例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);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:24,代码来源:Convolution.java
示例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();
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:21,代码来源:MatrixMultiplicationOneD.java
示例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();
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:24,代码来源:NBody.java
示例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);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:17,代码来源:FillArray.java
示例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]);
}
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:27,代码来源:ArrayMultiplication2D.java
示例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);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:17,代码来源:ArrayIncrement.java
示例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);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:17,代码来源:ArrayIncrement.java
示例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)) };
}
开发者ID:apemanzilla,项目名称:turbokrist,代码行数:27,代码来源:GPUMiner.java
示例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);
}
}
开发者ID:apemanzilla,项目名称:turbokrist,代码行数:21,代码来源:TestCLMining.java
示例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);
}
}
开发者ID:apemanzilla,项目名称:turbokrist,代码行数:29,代码来源:TestCLMacros.java
示例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);
}
}
开发者ID:apemanzilla,项目名称:JCLMiner,代码行数:21,代码来源:TestCLMining.java
示例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);
}
开发者ID:nativelibs4java,项目名称:JavaCL,代码行数:18,代码来源:KernelTest.java
示例16: testArrayArg
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public <T> Object testArrayArg(String type, Object array, Class<T> targetType) {
long size = BridJ.sizeOf(targetType);
long length = Array.getLength(array);
CLBuffer<Byte> 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();
}
开发者ID:nativelibs4java,项目名称:JavaCL,代码行数:17,代码来源:KernelTest.java
示例17: main
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
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<Float>
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<Float> 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));
}
开发者ID:nativelibs4java,项目名称:JavaCL,代码行数:25,代码来源:JavaCLTutorial3.java
示例18: CLConvolve2D
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
/**
* Construct the convolution operator with the given kernel and OpenCL
* context
*
* @param context
* the OpenCL context
* @param kernel
* the convolution kernel
* @throws IOException
* if an error occurs
*/
public CLConvolve2D(CLContext context, float[][] kernel) throws IOException {
super(context, CLConvolve2D.class.getResource("Convolve.cl"));
final ByteBuffer bb = ByteBuffer.allocateDirect(kernel.length * kernel.length * 4);
bb.order(context.getByteOrder());
final FloatBuffer fb = bb.asFloatBuffer();
for (int y = 0; y < kernel.length; y++)
for (int x = 0; x < kernel.length; x++)
fb.put(kernel[y][x]);
// Note: the buffer needs to be an ivar as it seems to
// get garbage collected (the setArg line below internally
// just grabs the native pointer to the buffer; java has no
// way of knowing that we still need the data...)
floatData = context.createFloatBuffer(Usage.Input, fb, true);
this.kernel.setArg(2, floatData);
this.kernel.setArg(3, kernel.length);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:32,代码来源:CLConvolve2D.java
示例19: kernel_378899703
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_378899703(int paramInt1, int paramInt2, float paramFloat1, float paramFloat2, float[] paramArrayOfFloat1, float paramFloat3, float paramFloat4, float[] paramArrayOfFloat2, float paramFloat5, float paramFloat6, float paramFloat7, float[] paramArrayOfFloat3, float paramFloat8, float paramFloat9, float paramFloat10)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_378899703 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
int i = paramInt2;
float f1 = paramFloat1;
float f2 = paramFloat2;
CLBuffer localCLBuffer1 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToFloats(paramArrayOfFloat1), true);
float f3 = paramFloat3;
float f4 = paramFloat4;
CLBuffer localCLBuffer2 = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToFloats(paramArrayOfFloat2), true);
float f5 = paramFloat5;
float f6 = paramFloat6;
float f7 = paramFloat7;
CLBuffer localCLBuffer3 = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToFloats(paramArrayOfFloat3), true);
float f8 = paramFloat8;
float f9 = paramFloat9;
float f10 = paramFloat10;
localCLKernel.setArgs(new Object[] { paramInt1, i, f1, f2, localCLBuffer1, f3, f4, localCLBuffer2, f5, f6, f7, localCLBuffer3, f8, f9, f10 });
int j = paramInt1 - paramInt2 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { j }, arrayOfCLEvent);
localCLQueue.finish();
localCLBuffer2.read(localCLQueue, new CLEvent[] { localCLEvent }).getFloats(paramArrayOfFloat2);
localCLBuffer3.read(localCLQueue, new CLEvent[] { localCLEvent }).getFloats(paramArrayOfFloat3);
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:30,代码来源:BlackScholes.java
示例20: kernel_1711690764
import com.nativelibs4java.opencl.CLMem.Usage; //导入依赖的package包/类
public static void kernel_1711690764(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int[][] paramArrayOfInt1, int[][] paramArrayOfInt2, int[][] paramArrayOfInt3)
{
CLDevice.QueueProperties[] arrayOfQueueProperties = { CLDevice.QueueProperties.ProfilingEnable };
CLQueue localCLQueue = context.createDefaultQueue(arrayOfQueueProperties);
String[] arrayOfString = { kernel_1711690764 };
CLKernel[] arrayOfCLKernel = context.createProgram(arrayOfString).createKernels();
CLKernel localCLKernel = arrayOfCLKernel[0];
int i = paramInt3;
int j = paramInt4;
int k = paramInt5;
CLBuffer localCLBuffer1 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToInts(paramArrayOfInt1), true);
CLBuffer localCLBuffer2 = context.createBuffer(CLMem.Usage.InputOutput, Pointer.pointerToInts(paramArrayOfInt2), true);
CLBuffer localCLBuffer3 = context.createBuffer(CLMem.Usage.Input, Pointer.pointerToInts(paramArrayOfInt3), true);
localCLKernel.setArgs(new Object[] { paramInt1, paramInt2, i, j, k, localCLBuffer1, localCLBuffer2, localCLBuffer3 });
int m = paramInt1 - paramInt5 / 1;
int n = paramInt2 - paramInt3 / 1;
CLEvent[] arrayOfCLEvent = { null };
CLEvent localCLEvent = localCLKernel.enqueueNDRange(localCLQueue, new int[] { m, n }, arrayOfCLEvent);
localCLQueue.finish();
Pointer localPointer1 = localCLBuffer2.read(localCLQueue, new CLEvent[] { localCLEvent });
long l = localPointer1.getValidElements();
for (int i1 = 0; i1 < l; i1++)
{
Pointer localPointer2 = (Pointer)localPointer1.get(i1);
localPointer2.getInts(paramArrayOfInt2[i1]);
}
}
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:28,代码来源:MatrixMultiplication.java
注:本文中的com.nativelibs4java.opencl.CLMem.Usage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论