本文整理匯總了Java中com.nativelibs4java.opencl.JavaCL類的典型用法代碼示例。如果您正苦於以下問題:Java JavaCL類的具體用法?Java JavaCL怎麽用?Java JavaCL使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

JavaCL類屬於com.nativelibs4java.opencl包,在下文中一共展示了JavaCL類的20個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: setUp

​點讚 3

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

@Before

public void setUp() throws ProgramBuildException {

// Set up context and queue

context = JavaCL.createBestContext();

queue = context.createDefaultQueue();

// Build program

ProgramBuilder pb = new ProgramBuilder("sha256.cl", "krist_miner.cl", "test_kernels.cl");

pb.addBuildOption("-Werror");

pb.defineMacro("UNIT_TESTING", 1);

program = pb.build(context);

// Test that CL code can be compiled and the testCompile kernel can be

// run without errors

CLKernel kernel = program.createKernel("testCompile");

CLEvent compilationTest = kernel.enqueueNDRange(queue, new int[] { 1 });

compilationTest.waitFor();

}

開發者ID:apemanzilla,項目名稱:turbokrist,代碼行數:17,

示例2: setUp

​點讚 3

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

@Before

public void setUp() {

context = JavaCL.createBestContext();

queue = context.createDefaultQueue();

String mainCode = CLCodeLoader.loadCode("/sha256.cl");

String minerCode = CLCodeLoader.loadCode("/krist_miner.cl");

String testCode = CLCodeLoader.loadCode("/test_kernels.cl");

assertNotNull("Failed to load main code", mainCode);

assertNotNull("Failed to load miner code", minerCode);

assertNotNull("Failed to load test code", testCode);

program = context.createProgram("#define UNIT_TESTING\n",mainCode, minerCode, testCode);

// Treat all warning as errors so

// tests will fail if warnings occur

program.addBuildOption("-Werror");

// Add other build options

for (String opt : JCLMiner.cl_build_options) {

program.addBuildOption(opt);

}

// Test that CL code can be compiled and the testCompile kernel can be run

CLKernel kernel = program.createKernel("testCompile");

CLEvent compilationTest = kernel.enqueueNDRange(queue, new int[] {1});

compilationTest.waitFor();

}

開發者ID:apemanzilla,項目名稱:JCLMiner,代碼行數:27,

示例3: testGPUPerfFloat

​點讚 3

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

@Test

public void testGPUPerfFloat() throws IOException {

//CLKernels.setInstance(new CLKernels(JavaCL.createBestContext(DeviceFeature.GPU).createDefaultQueue()));

//int size = 100;

for (int size : new int[] { 10, 50, 100/*, 200, 400*/ }) {

DefaultDenseFloatMatrix2D mJava = new DefaultDenseFloatMatrix2D(size, size);

Matrix pJava = testPerf("Java(size = " + size +")", mJava).getValue();

for (DeviceFeature feat : new DeviceFeature[] { DeviceFeature.CPU, DeviceFeature.GPU }) {

CLKernels.setInstance(new CLKernels(JavaCL.createBestContext(feat).createDefaultQueue()));

CLDevice device = CLKernels.getInstance().getQueue().getDevice();

CLDenseFloatMatrix2D mCL = new CLDenseFloatMatrix2D(size, size);

Matrix pCL = testPerf("OpenCL(size = " + size +", device = " + device + ")", mCL).getValue();

assertEquals(pJava, pCL);

}

}

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:23,

示例4: getPlatforms

​點讚 3

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public List getPlatforms() {

CLPlatform[] platforms = JavaCL.listPlatforms();

boolean hasSharing = false;

plat: for (CLPlatform platform : platforms)

if (platform.isGLSharingSupported())

for (CLDevice device : platform.listAllDevices(false))

if (device.isGLSharingSupported()) {

hasSharing = true;

break plat;

}

configFromGLCheck.setEnabled(hasSharing);

if (!hasSharing) {

configFromGLCheck.setText(configFromGLCheck.getText() + " (unavailable option)");

configFromGLCheck.setToolTipText("Did not find any OpenCL platform with OpenGL sharing support.");

}

return Arrays.asList(platforms);

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:20,

示例5: add

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public static Pointer add(Pointer a, Pointer 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 aBuf = context.createBuffer(CLMem.Usage.Input, a, true);

CLBuffer bBuf = context.createBuffer(CLMem.Usage.Input, b, true);

CLBuffer outBuf = context.createBuffer(CLMem.Usage.InputOutput, a, true);

//CLBuffer 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,

示例6: listCompatibleDevices

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

@Deprecated

public static List listCompatibleDevices() {

List out = new ArrayList();

CLPlatform platforms[] = JavaCL.listPlatforms();

for (CLPlatform plat : platforms) {

CLDevice[] devices = plat.listAllDevices(false);

for (CLDevice dev : devices) {

if (isDeviceCompatible(dev)) {

out.add(dev);

}

}

}

return out;

}

開發者ID:apemanzilla,項目名稱:JCLMiner,代碼行數:15,

示例7: initializeCLContextAndQueueOrNothing

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

private synchronized void initializeCLContextAndQueueOrNothing(int platformNumber, int deviceNumber) {

//should check for index out of bounds later. need to figure out how I should throw the errors

if(context==null || q == null) {

CLDevice device = JavaCL.listPlatforms()[platformNumber].listAllDevices(false)[deviceNumber];

System.out.println("Device = " + device);

context = (JavaCL.createContext(null, device));

q = (context.createDefaultQueue());

}

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:10,

示例8: CLKernels

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public CLKernels() throws IOException, CLBuildException {

this(

JavaCL.createBestContext(

DeviceFeature.DoubleSupport,

DeviceFeature.MaxComputeUnits

).createDefaultQueue()

);

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:9,

示例9: testPICircle

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

/**

* http://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#Exemples

*/

@Test

public void testPICircle() {

try {

ParallelRandom random = new ParallelRandom(

JavaCL.createBestContext().createDefaultQueue(),

nPoints * 2,

seed

);

int nInside = 0, nTotalPoints = 0;

for (int iLoop = 0; iLoop < nLoops; iLoop++) {

Pointer values = random.next();

for (int iPoint = 0; iPoint < nPoints; iPoint++) {

int offset = iPoint * 2;

int ix = values.get(offset), iy = values.get(offset + 1);

float x = (float)((ix & mask) / divid);

float y = (float)((iy & mask) / divid);

float dist = x * x + y * y;

if (dist <= 1)

nInside++;

}

nTotalPoints += nPoints;

//checkPICircleProba(nInside, nTotalPoints);

}

checkPICircleProba(nInside, nTotalPoints);

} catch (Exception ex) {

throw new RuntimeException(ex);

}

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:35,

示例10: doExecute

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

@Override

protected Object doExecute() throws Exception {

CLPlatform[] platforms = JavaCL.listGPUPoweredPlatforms();

System.out.println("#### OpenCL Powered Platforms ####");

for (int p = 0; p < platforms.length; p++) {

System.out.println("Platform Name: " + platforms[p].getName());

System.out.println("Platform Profile: " + platforms[p].getProfile());

System.out.println("Platform Version: " + platforms[p].getVersion());

System.out.println("Platform Vendor: " + platforms[p].getVendor());

CLDevice[] devices = platforms[p].listAllDevices(true);

for (int d = 0; d < devices.length; d++) {

System.out.println("");

System.out.println("Device Name: " + devices[d].getName());

System.out.println("Device Version: " + devices[d].getOpenCLVersion());

System.out.println("Device Driver: " + devices[d].getDriverVersion());

System.out.println("Device MemCache Line: " + devices[d].getGlobalMemCachelineSize());

System.out.println("Device MemCache Size: " + devices[d].getGlobalMemCacheSize());

System.out.println("Device LocalMem Size: " + devices[d].getLocalMemSize());

System.out.println("Device MaxConBuf Size: " + devices[d].getMaxConstantBufferSize());

System.out.println("Device Global Mem: " + devices[d].getGlobalMemSize());

System.out.println("Device Max Mem Alloc: " + devices[d].getMaxMemAllocSize());

System.out.println("Device Clock Speed: " + devices[d].getMaxClockFrequency());

System.out.println("Device Compute Units: " + devices[d].getMaxComputeUnits());

System.out.println("Device Max Work Items: " + devices[d].getMaxWorkItemDimensions());

System.out.println("Device Max Work Groups: " + devices[d].getMaxWorkGroupSize());

System.out.println("Device Branding: " + devices[d].toString());

}

}

return null;

}

開發者ID:savoirtech,項目名稱:HWAAAS,代碼行數:31,

示例11: CLImageProcessor

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

/**

* Construct with the given OpenCL program

* @param program the OpenCL program

*/

public CLImageProcessor(CLProgram program) {

try {

this.context = JavaCL.createBestContext(DeviceFeature.GPU);

this.kernel = program.createKernels()[0];

} catch (CLBuildException e) {

//fallback to OpenCL on the CPU

this.context = JavaCL.createBestContext(DeviceFeature.CPU);

this.kernel = program.createKernels()[0];

}

}

開發者ID:openimaj,項目名稱:openimaj,代碼行數:15,

示例12: CLImageAnalyser

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

/**

* Construct with the given OpenCL program

* @param program the OpenCL program

*/

public CLImageAnalyser(CLProgram program) {

try {

this.context = JavaCL.createBestContext(DeviceFeature.GPU);

this.kernel = program.createKernels()[0];

} catch (CLBuildException e) {

//fallback to OpenCL on the CPU

this.context = JavaCL.createBestContext(DeviceFeature.CPU);

this.kernel = program.createKernels()[0];

}

}

開發者ID:openimaj,項目名稱:openimaj,代碼行數:15,

示例13: add

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public static Pointer add(Pointer 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 outBuf = context.createBuffer(CLMem.Usage.InputOutput, a, true);

CLBuffer 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,

示例14: failWithDownloadProposalsIfOpenCLNotAvailable

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public static void failWithDownloadProposalsIfOpenCLNotAvailable() {

///*

try {

JavaCL.listPlatforms();

return;

} catch (Throwable ex) {

ex.printStackTrace();

} //*/

String title = "JavaCL Error: OpenCL library not found";

if (Platform.isMacOSX()) {

JOptionPane.showMessageDialog(null, "Please upgrade Mac OS X to Snow Leopard (10.6) to be able to use OpenCL.", title, JOptionPane.ERROR_MESSAGE);

return;

}

Object[] options = new Object[] {

"NVIDIA graphic card",

"ATI graphic card",

"CPU only",

"Cancel"

};

//for (;;) {

int option = JOptionPane.showOptionDialog(null,

"You don't appear to have an OpenCL implementation properly configured.\n" +

"Please choose one of the following options to proceed to the download of an appropriate OpenCL implementation :", title, JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[2]);

if (option >= 0 && option != 3) {

DownloadURL url;

if (option == 0) {

/*String nvidiaVersion = "260.99";

boolean appendPlatform = true;

String sys;

if (JNI.isWindows()) {

if (System.getProperty("os.name").toLowerCase().contains("xp")) {

sys = "winxp";

appendPlatform = false;

} else {

sys = "win7_vista";

}

urlString = "http://www.nvidia.fr/object/" + sys + "_" + nvidiaVersion + (appendPlatform ? "_" + (JNI.is64Bits() ? "64" : "32") + "bit" : "") + "_whql.html";

} else

urlString = "http://developer.nvidia.com/object/opencl-download.html";

*/

url = DownloadURL.NVidia;

} else

url = DownloadURL.ATI;

try {

Platform.open(url.url);

} catch (Exception ex1) {

exception(ex1);

}

}

System.exit(1);

}

開發者ID:adnanmitf09,項目名稱:Rubus,代碼行數:54,

示例15: main

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public static void main(String[] args) throws IOException {

CLContext context = JavaCL.createBestContext();

CLQueue clQueue = context.createDefaultQueue();

ByteOrder byteOrder = context.getByteOrder();

int n = 1024;

Pointer aPtr = allocateFloats(n).order(byteOrder);

for (int i = 0; i < n; i++) {

aPtr.set(i, (float)cos(i));

}

// Create OpenCL input/output buffers (using the native memory pointers aPtr and bPtr) :

CLBuffer a = context.createBuffer(Usage.InputOutput, aPtr);

// Read the program sources and compile them :

String src =

"__kernel void add_floats(global float* a, int n) {\n" +

" int i = get_global_id(0);\n" +

" if(i < n){\n" +

" a[i] = 2.f*a[i];\n" +

" }\n" +

"}";

//IOUtils.readText(new File("TutorialKernels.cl"));

CLProgram program = context.createProgram(src).build();

// Get and call the kernel :

CLKernel addFloatsKernel = program.createKernel("add_floats");

addFloatsKernel.setArgs(a, n);

CLEvent evt = addFloatsKernel.enqueueNDRange(clQueue, new int[] { n });

aPtr = a.read(clQueue, evt); // 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 + "] = " + aPtr.get(i));

}

}

開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:43,

示例16: LinearAlgebraUtils

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public LinearAlgebraUtils(boolean doubleCapable) throws IOException, CLBuildException {

this(JavaCL.createBestContext(doubleCapable ? DeviceFeature.DoubleSupport : null).createDefaultQueue());

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:4,

示例17: ParallelMath

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public ParallelMath() {

this(JavaCL.createBestContext().createDefaultQueue());

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:4,

示例18: ParallelRandom

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

public ParallelRandom() throws IOException {

this(JavaCL.createBestContext().createDefaultQueue(), 32 * 1024, System.currentTimeMillis());

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:4,

示例19: setup

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

@Before

public void setup() throws IOException {

context = JavaCL.createBestContext();

queue = context.createDefaultQueue();

structs = new Structs(context);

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:7,

示例20: selectBestDevice

​點讚 2

import com.nativelibs4java.opencl.JavaCL; //導入依賴的package包/類

private void selectBestDevice() {

setDevice(JavaCL.getBestDevice());

}

開發者ID:nativelibs4java,項目名稱:JavaCL,代碼行數:4,

注:本文中的com.nativelibs4java.opencl.JavaCL類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

java cl 規格_Java JavaCL類代碼示例相关推荐

  1. java中的case1怎么说_Java Cas20ServiceTicketValidator類代碼示例

    本文整理匯總了Java中org.jasig.cas.client.validation.Cas20ServiceTicketValidator類的典型用法代碼示例.如果您正苦於以下問題:Java Ca ...

  2. kies air java 证书_Java ToStringBuilder類代碼示例

    本文整理匯總了Java中org.apache.commons.lang3.builder.ToStringBuilder類的典型用法代碼示例.如果您正苦於以下問題:Java ToStringBuild ...

  3. java try finally connectoin close_Java SocketChannel類代碼示例

    本文整理匯總了Java中io.netty.channel.socket.SocketChannel類的典型用法代碼示例.如果您正苦於以下問題:Java SocketChannel類的具體用法?Java ...

  4. java中enhancer试什么_Java Enhancer類代碼示例

    import org.mockito.cglib.proxy.Enhancer; //導入依賴的package包/類 public Class createProxyClass(Class> m ...

  5. java datasource mysql_Java MysqlDataSource類代碼示例

    本文整理匯總了Java中com.mysql.cj.jdbc.MysqlDataSource類的典型用法代碼示例.如果您正苦於以下問題:Java MysqlDataSource類的具體用法?Java M ...

  6. java uiautomation_Java UiAutomation類代碼示例

    本文整理匯總了Java中android.app.UiAutomation類的典型用法代碼示例.如果您正苦於以下問題:Java UiAutomation類的具體用法?Java UiAutomation怎 ...

  7. java nifty_Java NiftyDialogBuilder類代碼示例

    本文整理匯總了Java中com.gitonway.lee.niftymodaldialogeffects.NiftyDialogBuilder類的典型用法代碼示例.如果您正苦於以下問題:Java Ni ...

  8. java intfunction_Java IntFunction類代碼示例

    本文整理匯總了Java中java.util.function.IntFunction類的典型用法代碼示例.如果您正苦於以下問題:Java IntFunction類的具體用法?Java IntFunct ...

  9. java sentence_Java Sentence類代碼示例

    本文整理匯總了Java中aima.core.logic.propositional.parsing.ast.Sentence類的典型用法代碼示例.如果您正苦於以下問題:Java Sentence類的具 ...

最新文章

  1. KVM中vhost-user简介(十三)
  2. Caffe官方教程翻译(9):Multilabel Classification with Python Data Layer
  3. 关于系统用户数,并发用户数,在线用户数,吞吐量
  4. 国内开源社区巨作AspectCore-Framework入门
  5. 电脑如何设置不休眠_电脑休眠了却没法唤醒?设置一下就好!
  6. Javascript学习数据结构--集合(Set实现)
  7. C语言课后习题(40)
  8. java生成平滑散点图_【转载】如何在excel制作散点图平滑线散点图
  9. WebStorm 是什么软件
  10. LeetCode 第 3 题(Longest Substring Without Repeating Characters)
  11. C#中常用字符串操作
  12. Java用jxl对表格的数值进行比对
  13. 微信分组群发45028,微信分组群发has no masssend quota hint
  14. Linux学习笔记(六)——文件打包与解压缩
  15. 宏碁(Acer)蜂鸟Fun 2020新款 14英寸轻薄商务笔记本使用真实评测
  16. 快来开建春晚红包信息群吧!
  17. iOS Quartz2D 渐变图形 CGGradient CGShading
  18. 从网页上直接扒取latex格式的公式
  19. java多线程并发卖票问题
  20. 【offer 收割计划】这几道常见的面试题,你会几道

热门文章

  1. 浅谈sql中的in与not in,exists与not exists的区别
  2. [jQuery原理] jQuery属性操作相关方法
  3. 如何成为一名优秀的web前端工程师(前端攻城师)
  4. JavaScript算法(实例十)回文数 / 立方根 / 进制转化
  5. LibLinear(SVM包)使用说明之(二)MATLAB接口
  6. ci框架中引入css,php ci框架中载入css和js文件失败的原因及解决方法
  7. matlab simplify函数,[求助]Matlab2016b里没有simple函数
  8. 数组c语言与指针,浅析C语言数组与指针
  9. [Apple开发者帐户帮助]二、管理你的团队(3)删除团队成员
  10. Linux下open函数、read函数、write函数记录