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


Java Kernel类代码示例

本文整理汇总了Java中com.amd.aparapi.Kernel的典型用法代码示例。如果您正苦于以下问题:Java Kernel类的具体用法?Java Kernel怎么用?Java Kernel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AparAPI

import com.amd.aparapi.Kernel; //导入依赖的package包/类
@Override
	public void AparAPI() {
		 final float[] sum = this.arrAparAPi;
final float inA[] = this.inputValues;
final int size = this.size;
	   
Kernel kernel = new Kernel(){
	         @Override public void run() {
	            int gid = getGlobalId();
	            sum[gid] =  pow(inA[gid], 2);
	            }
	      };

	      kernel.execute(size);
	      kernel.dispose();
	}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:17,代码来源:SquaresMath.java

示例2: disposeOn2DTest

import com.amd.aparapi.Kernel; //导入依赖的package包/类
@Test
	public void disposeOn2DTest() {
		class Kernel1 extends Kernel {
			public int[][] a = new int[10][10];

			@Override
			public void run() {
				int i = getGlobalId();
				a[i][5] = i;
			}
		}

//		System.setProperty("com.amd.aparapi.enableShowGeneratedOpenCL", "true");
		Kernel1 k = new Kernel1();
		k.execute(10);
		System.out.println(Arrays.deepToString(k.a));
		k.dispose();
	}
 
开发者ID:myshzzx,项目名称:mlib,代码行数:19,代码来源:AparapiTest.java

示例3: scalarMatrixMultiplication

import com.amd.aparapi.Kernel; //导入依赖的package包/类
public void scalarMatrixMultiplication() {
    float inputMatrix[] = {3, 4, 5, 6, 7, 8, 9};
    int size = inputMatrix.length;
    
    ScalarMultiplicationKernel kernel
            = new ScalarMultiplicationKernel(inputMatrix);
    kernel.setExecutionMode(Kernel.EXECUTION_MODE.NONE);
    kernel.execute(size);
    kernel.displayResult();
    kernel.dispose();
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:12,代码来源:AparapiExamples.java

示例4: AparAPI

import com.amd.aparapi.Kernel; //导入依赖的package包/类
@Test
	public void AparAPI() {
		System.out.println("AparApi");
	final float[]in1 = inA;
	final float[]in2 = inB;
	final int size = this.size;
	final float [] outAparApi = this.outAparApi;
	Kernel kernel = new Kernel(){
		    @Override
		    public void run() {
		        int i = getGlobalId();
		        int j = getPassId();
		    
		        float value = 0;
		        for(int k = 0; k < size; k++)
		        {
		            value += in1[k + i * size] * in2[k * size + j];
		        }
		        outAparApi[i * size + j] = value;
		    }
		 
		};
//		 
		kernel.execute(size, size);
		    
		
	}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:28,代码来源:MatrixMultiplication.java

示例5: AparAPI

import com.amd.aparapi.Kernel; //导入依赖的package包/类
@Override
	public void AparAPI() {
		final float delT = this.delT;
		final float espSqr = this.espSqr;
		final float mass = this.mass;
		final float[] xyz = positionsAparApi;
		final float[] vxyz = velocitiesAparApi;
		Kernel kernel = new Kernel(){
		

		
		  
		      @Override public void run() {
		         final int body = getGlobalId();
		         final int count = getGlobalSize(0) * 3;
		         final int globalId = body * 3;

		         float accx = 0.f;
		         float accy = 0.f;
		         float accz = 0.f;

		         final float myPosx = xyz[globalId + 0];
		         final float myPosy = xyz[globalId + 1];
		         final float myPosz = xyz[globalId + 2];
		         for (int i = 0; i < count; i += 3) {
		            final float dx = xyz[i + 0] - myPosx;
		            final float dy = xyz[i + 1] - myPosy;
		            final float dz = xyz[i + 2] - myPosz;
		            final float invDist = rsqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr);
		            final float s = mass * invDist * invDist * invDist;
		            accx = accx + (s * dx);
		            accy = accy + (s * dy);
		            accz = accz + (s * dz);
		         }
		         accx = accx * delT;
		         accy = accy * delT;
		         accz = accz * delT;
		         xyz[globalId + 0] = myPosx + (vxyz[globalId + 0] * delT) + (accx * .5f * delT);
		         xyz[globalId + 1] = myPosy + (vxyz[globalId + 1] * delT) + (accy * .5f * delT);
		         xyz[globalId + 2] = myPosz + (vxyz[globalId + 2] * delT) + (accz * .5f * delT);

		         vxyz[globalId + 0] = vxyz[globalId + 0] + accx;
		         vxyz[globalId + 1] = vxyz[globalId + 1] + accy;
		         vxyz[globalId + 2] = vxyz[globalId + 2] + accz;
		      }

		    	
	
};
	kernel.execute(size);
	}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:52,代码来源:NBody.java

示例6: AparAPI

import com.amd.aparapi.Kernel; //导入依赖的package包/类
@Override
public void AparAPI() {
	
	final int height = this.size;
	final int width = this.size;
	 final  int pix[] = outAprApi;
	   
	  Kernel kernel = new Kernel(){
		  
		  public void run() {
		         int gid = getGlobalId();

			  int x = (gid % width);

		         int y = (gid / height);
			  int red = (y * 255) / (height - 1);
		        int blue = (x * 255) / (width - 1);
		        pix[gid] = (255 << 24) | (red << 16) | blue;
		   		
			}
		
	  };
	  kernel.execute(height*width);
	  kernel.dispose();
	     
	
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:28,代码来源:MemImage.java


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