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


Java Pointer.getValidElements方法代码示例

本文整理汇总了Java中org.bridj.Pointer.getValidElements方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.getValidElements方法的具体用法?Java Pointer.getValidElements怎么用?Java Pointer.getValidElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bridj.Pointer的用法示例。


在下文中一共展示了Pointer.getValidElements方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.bridj.Pointer; //导入方法依赖的package包/类
public static void main(String[] args) {
		

		try {
//			int ar[] = new int[] { 1, 2, 3, 4, 3, 6, 7, 8, 3, 2, 4, 4 };
//			int br[] = new int[] { 1, 2, 3, 4, 3, 6, 7, 8, 3, 2, 4, 4 };
//			int cr[] = new int[ar.length];
			
			//Src2598218282026810383.samples_HelloWorld_kernel_12144151946(ar.length, ar, br, 0,cr);

			 
			float ar[] = new float[] { 1, 2, 3 };
			float br[] = new float[] { 4, 5, 6 };
			float cr[] = new float[ar.length];
		
			Pointer<Float> a = pointerToFloats(ar);
			Pointer<Float> b = pointerToFloats(br);

			Pointer<Float> sum = add(a, b);
			for (long i = 0, n = sum.getValidElements(); i < n; i++)
				System.out.println(sum.get(i));
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:26,代码来源:VectorAdd.java

示例2: kernel_M382277171

import org.bridj.Pointer; //导入方法依赖的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

示例3: add

import org.bridj.Pointer; //导入方法依赖的package包/类
public static Pointer<Float> add(Pointer<Float> a, Pointer<Float> b)
			throws CLBuildException {
		int n = (int) a.getValidElements();

		CLContext context = JavaCL.createBestContext();
		CLQueue queue = context.createDefaultQueue();

		String source = " void plusplus(int *i){i[0]= i[0]+1;}  " +
				" void add(__global float *a,__global float *b,__global float *c,__global int *i){int j = (int)i;c[j] = a[j] + b[j]; } \n" +
				"__kernel void kernel1 (__global  float* a, __global  float* b, __global float* output)     "
				+ "{                                                                                                     "
				+ "   int i = get_global_id(0);  " +
				   "  "+
				"    add(a,b,output,i); " +
				
				"     " +
				"                                                                 "
				+ "   " +
				"                                                                           "
				+ "}                                                                                                     "
				+" ";

		//CLKernel kernel = context.createProgram(kernel_1354633072).createKernel(		"kernel_1354633072");
		
		CLKernel kernel1 = context.createProgram(source).createKernel("kernel1");
		CLBuffer<Float> aBuf = context.createBuffer(CLMem.Usage.Input, a, true);
		CLBuffer<Float> bBuf = context.createBuffer(CLMem.Usage.Input, b, true);
		
		CLBuffer<Float> outBuf = context.createBuffer(CLMem.Usage.InputOutput, a, true);
//		CLBuffer<Float> outBuf = context.createBuffer(CLMem.Usage.InputOutput,
//				Float.class, n);
		kernel1.setArgs(aBuf, bBuf, outBuf);

		kernel1.enqueueNDRange(queue, new int[] { n });
		queue.finish();

		return outBuf.read(queue);
	}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:39,代码来源:VectorAdd.java

示例4: kernel_1711690764

import org.bridj.Pointer; //导入方法依赖的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

示例5: main

import org.bridj.Pointer; //导入方法依赖的package包/类
public static void main(String[] args) {
	

	try {

		 
		int ar[] = new int[] { 1, 2, 3,4,5 };
		
	
		Pointer<Integer> a = pointerToInts(ar);
	
		Pointer<Integer> sum = add(a);
		for (long i = 0, n = sum.getValidElements(); i < n; i++)
			System.out.println(sum.get(i));
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:19,代码来源:SimpleAdd.java

示例6: add

import org.bridj.Pointer; //导入方法依赖的package包/类
public static Pointer<Integer> add(Pointer<Integer> a)
		throws CLBuildException {
	int n = (int) a.getValidElements();

	CLContext context = JavaCL.createBestContext();
	CLQueue queue = context.createDefaultQueue();


	CLKernel kernel1 = context.createProgram(kernel_1725551088).createKernel("kernel_1725551088");
	

	
	CLBuffer<Integer> outBuf = context.createBuffer(CLMem.Usage.InputOutput, a, true);
	CLBuffer<Integer> aa = context.createBuffer(CLMem.Usage.InputOutput, pointerToInt(0), true);

	
	kernel1.setArgs(aa,aa,outBuf);

	kernel1.enqueueNDRange(queue, new int[] { n });
	queue.finish();

	return outBuf.read(queue);
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:24,代码来源:SimpleAdd.java


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