JOCL v2.6.0-rc-20250722
JOCL, OpenCL® API Binding for Java™ (public API).
LowLevelBindingTest.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opencl;
30
31import java.util.Random;
32
33import com.jogamp.common.nio.PointerBuffer;
34import com.jogamp.opencl.llb.impl.BuildProgramCallback;
35import com.jogamp.opencl.llb.impl.CLImpl12;
36import com.jogamp.opencl.llb.impl.CLImpl20;
37import com.jogamp.opencl.llb.CL;
38import com.jogamp.opencl.test.util.MiscUtils;
39import com.jogamp.opencl.test.util.UITestCase;
40
41import java.io.IOException;
42import java.nio.ByteBuffer;
43import java.nio.IntBuffer;
44import java.util.ArrayList;
45import java.util.List;
46import java.util.concurrent.Callable;
47import java.util.concurrent.CountDownLatch;
48import java.util.concurrent.ExecutionException;
49import java.util.concurrent.ExecutorService;
50import java.util.concurrent.Executors;
51import java.util.concurrent.Future;
52import java.util.concurrent.TimeUnit;
53
54import org.junit.BeforeClass;
55import org.junit.FixMethodOrder;
56import org.junit.Test;
57import org.junit.runners.MethodSorters;
58
59import static java.lang.System.*;
60import static org.junit.Assert.*;
61import static com.jogamp.common.nio.Buffers.*;
62import static com.jogamp.common.os.Platform.*;
63import static com.jogamp.opencl.test.util.MiscUtils.*;
64import static com.jogamp.opencl.util.CLUtil.*;
65
66/**
67 * Test testing the low level bindings.
68 * @author Michael Bien, et al.
69 */
70@FixMethodOrder(MethodSorters.NAME_ASCENDING)
71public class LowLevelBindingTest extends UITestCase {
72
73 private final static String programSource =
74 " // OpenCL Kernel Function for element by element vector addition \n"
75 + "kernel void VectorAdd(global const int* a, global const int* b, global int* c, int iNumElements) { \n"
76 + " // get index in global data array \n"
77 + " int iGID = get_global_id(0); \n"
78 + " // bound check (equivalent to the limit on a 'for' loop for standard/serial C code \n"
79 + " if (iGID >= iNumElements) { \n"
80 + " return; \n"
81 + " } \n"
82 + " // add the vector elements \n"
83 + " c[iGID] = a[iGID] + b[iGID]; \n"
84 + "} \n"
85 + "kernel void Test(global const int* a, global const int* b, global int* c, int iNumElements) { \n"
86 + " // get index in global data array \n"
87 + " int iGID = get_global_id(0); \n"
88 + " // bound check (equivalent to the limit on a 'for' loop for standard/serial C code \n"
89 + " if (iGID >= iNumElements) { \n"
90 + " return; \n"
91 + " } \n"
92 + " c[iGID] = iGID; \n"
93 + "} \n";
94
95 private int ELEMENT_COUNT = 11444777;
96
97
98 @BeforeClass
99 public static void setUpClass() throws Exception {
100 out.println("OS: " + System.getProperty("os.name"));
101 out.println("VM: " + System.getProperty("java.vm.name"));
102 }
103
104 @Test
105 public void contextlessTest() {
106
107 out.println(" - - - lowLevelTest; contextless binding - - - ");
108
110
111// System.out.println(((CLImpl)cl).clGetExtensionFunctionAddress("clCreateFromGLBuffer"));
112// System.out.println(((CLImpl)cl).clGetExtensionFunctionAddress("clEnqueueAcquireGLObjects"));
113
114 int ret = CL.CL_SUCCESS;
115
116 final IntBuffer intBuffer = newDirectIntBuffer(1);
117 // find all available OpenCL platforms
118 ret = cl.clGetPlatformIDs(0, null, intBuffer);
119 checkForError(ret);
120 out.println("#platforms: "+intBuffer.get(0));
121
122 final PointerBuffer platformId = PointerBuffer.allocateDirect(intBuffer.get(0));
123 ret = cl.clGetPlatformIDs(platformId.capacity(), platformId, null);
124 checkForError(ret);
125
126 // print platform info
127 final PointerBuffer longBuffer = PointerBuffer.allocateDirect(1);
128 final ByteBuffer bb = newDirectByteBuffer(128);
129
130 for (int i = 0; i < platformId.capacity(); i++) {
131
132 final long platform = platformId.get(i);
133 out.println("platform id: "+platform);
134
135 ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_PROFILE, bb.capacity(), bb, longBuffer);
136 checkForError(ret);
137 out.println(" profile: " + clString2JavaString(bb, (int)longBuffer.get(0)));
138
139 ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VERSION, bb.capacity(), bb, longBuffer);
140 checkForError(ret);
141 out.println(" version: " + clString2JavaString(bb, (int)longBuffer.get(0)));
142
143 ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_NAME, bb.capacity(), bb, longBuffer);
144 checkForError(ret);
145 out.println(" name: " + clString2JavaString(bb, (int)longBuffer.get(0)));
146
147 ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VENDOR, bb.capacity(), bb, longBuffer);
148 checkForError(ret);
149 out.println(" vendor: " + clString2JavaString(bb, (int)longBuffer.get(0)));
150
151 //find all devices
152 ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, 0, null, intBuffer);
153 checkForError(ret);
154 out.println("#devices: "+intBuffer.get(0));
155
156 final PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0));
157 ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null);
158
159 //print device info
160 for (int j = 0; j < devices.capacity(); j++) {
161 final long device = devices.get(j);
162 ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_NAME, bb.capacity(), bb, longBuffer);
163 checkForError(ret);
164 out.println(" device: " + clString2JavaString(bb, (int)longBuffer.get(0)));
165
166 // get the CL interface with version specific to this device
167 CL deviceInterface = CLPlatform.getLowLevelCLInterfaceForDevice(device);
168 if(deviceInterface instanceof CLImpl12)
169 out.println(" CL impl: 1.2");
170 else if(deviceInterface instanceof CLImpl20)
171 out.println(" CL impl: 2.0");
172 else
173 out.println(" CL impl: 1.1");
174
175 ret = deviceInterface.clGetDeviceInfo(device, CL.CL_DEVICE_TYPE, bb.capacity(), bb, longBuffer);
176 checkForError(ret);
177 out.println(" type: " + CLDevice.Type.valueOf(bb.get()));
178 bb.rewind();
179
180 }
181
182 }
183 }
184
185 @Test
186 public void createContextTest() {
187
188 out.println(" - - - createContextTest - - - ");
189
191
192 final IntBuffer intBuffer = newDirectIntBuffer(1);
193 // find all available OpenCL platforms
194 int ret = cl.clGetPlatformIDs(0, null, intBuffer);
195 checkForError(ret);
196 out.println("#platforms: "+intBuffer.get(0));
197
198 final PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0));
199 ret = cl.clGetPlatformIDs(pb.capacity(), pb, null);
200 checkForError(ret);
201
202 final long platform = pb.get(0);
203
204 //find all devices
205 ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, 0, null, intBuffer);
206 checkForError(ret);
207 out.println("#devices: "+intBuffer.get(0));
208
209 final PointerBuffer devices = PointerBuffer.allocateDirect(intBuffer.get(0));
210 ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, devices.capacity(), devices, null);
211
212 final long context = cl.clCreateContext(null, devices, null, intBuffer);
213 checkError("on clCreateContext", intBuffer.get());
214
215 //get number of devices
216 final PointerBuffer longBuffer = PointerBuffer.allocateDirect(1);
217 ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer);
218 checkError("on clGetContextInfo", ret);
219
220 final long contextDevices = longBuffer.get(0)/(is32Bit()?4:8);
221 out.println("context created on " + contextDevices + " devices");
222
223 //check if equal
224 assertEquals("context was not created on all devices specified", devices.capacity(), contextDevices);
225
226 ret = cl.clReleaseContext(context);
227 checkError("on clReleaseContext", ret);
228 }
229
230 @Test
231 public void lowLevelVectorAddTest() throws InterruptedException {
232
233 out.println(" - - - lowLevelTest2; VectorAdd kernel - - - ");
234
236
237 int ret = CL.CL_SUCCESS;
238 final IntBuffer intBuffer = newDirectIntBuffer(1);
239
240 // find all available OpenCL platforms
241 ret = cl.clGetPlatformIDs(0, null, intBuffer);
242 checkForError(ret);
243 assertTrue(intBuffer.get(0) > 0);
244
245 final PointerBuffer pb = PointerBuffer.allocateDirect(intBuffer.get(0));
246 ret = cl.clGetPlatformIDs(pb.capacity(), pb, null);
247 checkForError(ret);
248
249 final long platform = pb.get(0);
250 final PointerBuffer properties = PointerBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM)
251 .put(platform).put(0) // 0 terminated array
252 .rewind();
253 final long context = cl.clCreateContextFromType(properties, CL.CL_DEVICE_TYPE_ALL, null, null);
254 out.println("context handle: "+context);
255 checkError("on clCreateContextFromType", ret);
256
257 final PointerBuffer longBuffer = PointerBuffer.allocateDirect(1);
258 ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer);
259 checkError("on clGetContextInfo", ret);
260
261 final int deviceCount = (int) (longBuffer.get(0) / (is32Bit() ? 4 : 8));
262 out.println("context created with " + deviceCount + " devices");
263
264 // Was originally 4096, but had to make this bigger or it would crash in UITestCase.oneTimeTearDown(){ System.gc() }
265 // without even dumping a stack when using AMD drivers. Presumably the drivers would write past the end
266 // of the block and mess up GC info somehow.
267 final ByteBuffer bb = newDirectByteBuffer(32768);
268 ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, bb.capacity(), bb, null);
269 checkError("on clGetContextInfo", ret);
270
271 for (int i = 0; i < deviceCount; i++) {
272 out.println("device id: " + (is32Bit()?bb.getInt():bb.getLong()));
273 }
274
275 // use a random device
276 int offset = new Random().nextInt(deviceCount);
277 out.println("using device# " + offset);
278 offset *= (is32Bit() ? 4 : 8);
279 final long device = is32Bit()?bb.getInt(offset):bb.getLong(offset);
280
281 bb.rewind();
282 ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_MAX_WORK_GROUP_SIZE, bb.capacity(), bb, null);
283 checkError("on clGetDeviceInfo", ret);
284 final int maxWGS = bb.getInt();
285 out.println("max WGS: " + maxWGS);
286
287 // Create a command-queue
288 final long commandQueue = cl.clCreateCommandQueue(context, device, 0, intBuffer);
289 checkError("on clCreateCommandQueue", intBuffer.get(0));
290
291 final int localWorkSize = Math.min(128, maxWGS); // set and log Global and Local work size dimensions
292 int elementCount = ELEMENT_COUNT;
293 int globalWorkSize = 0;
294
295 ByteBuffer srcA = null;
296 ByteBuffer srcB = null;
297 ByteBuffer dest = null;
298 boolean allocated = false;
299 int divisor = 1;
300 while( !allocated ) {
301 try {
302 // round up to the nearest multiple of the LocalWorkSize
303 globalWorkSize = roundUp(localWorkSize, elementCount);
304 out.println("allocating three buffers of size: "+globalWorkSize);
305 srcA = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
306 srcB = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
307 dest = newDirectByteBuffer(globalWorkSize*SIZEOF_INT);
308 allocated = true;
309 }
310 catch( final OutOfMemoryError oome ) {
311 ++divisor;
312 elementCount /= divisor;
313 out.println("not enough direct buffer memory; retrying with smaller buffers");
314 }
315 }
316
317 // Allocate the OpenCL buffer memory objects for source and result on the device GMEM
318 final long devSrcA = cl.clCreateBuffer(context, CL.CL_MEM_READ_ONLY, srcA.capacity(), null, intBuffer);
319 checkError("on clCreateBuffer", intBuffer.get(0));
320 final long devSrcB = cl.clCreateBuffer(context, CL.CL_MEM_READ_ONLY, srcB.capacity(), null, intBuffer);
321 checkError("on clCreateBuffer", intBuffer.get(0));
322 final long devDst = cl.clCreateBuffer(context, CL.CL_MEM_WRITE_ONLY, dest.capacity(), null, intBuffer);
323 checkError("on clCreateBuffer", intBuffer.get(0));
324
325
326 // Create the program
327 final PointerBuffer lengths = PointerBuffer.allocateDirect(1).put(programSource.length()).rewind();
328 final long program = cl.clCreateProgramWithSource(context, 1, new String[] {programSource}, lengths, intBuffer);
329 out.println("program id: "+program);
330 checkError("on clCreateProgramWithSource", intBuffer.get(0));
331
332 // tests if the callback is called
333 final CountDownLatch latch = new CountDownLatch(1);
334 final BuildProgramCallback callback = new BuildProgramCallback() {
335 @Override
336 public void buildFinished(final long cl_program) {
337 try{
338 assertEquals(program, cl_program);
339 }finally{
340 latch.countDown();
341 }
342 }
343 };
344
345 // spec: building programs is not threadsafe (see loadtest)
346 synchronized(CLProgram.class) {
347 // Build the program
348 ret = cl.clBuildProgram(program, 0, null, null, callback);
349 checkError("on clBuildProgram", ret);
350
351 out.println("waiting for program to build...");
352 latch.await();
353 }
354 out.println("done");
355
356 // Read program infos
357 bb.rewind();
358 ret = cl.clGetProgramInfo(program, CL.CL_PROGRAM_NUM_DEVICES, bb.capacity(), bb, null);
359 checkError("on clGetProgramInfo1", ret);
360 out.println("program associated with "+bb.getInt(0)+" device(s)");
361
362 ret = cl.clGetProgramInfo(program, CL.CL_PROGRAM_SOURCE, 0, null, longBuffer);
363 checkError("on clGetProgramInfo CL_PROGRAM_SOURCE", ret);
364 out.println("program source length (cl): "+longBuffer.get(0));
365 out.println("program source length (java): "+programSource.length());
366
367 bb.rewind();
368 ret = cl.clGetProgramInfo(program, CL.CL_PROGRAM_SOURCE, bb.capacity(), bb, null);
369 checkError("on clGetProgramInfo CL_PROGRAM_SOURCE", ret);
370 out.println("program source:\n" + clString2JavaString(bb, (int)longBuffer.get(0)));
371
372 // Check program status
373 bb.rewind();
374 ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_STATUS, bb.capacity(), bb, null);
375 checkError("on clGetProgramBuildInfo1", ret);
376
377 out.println("program build status: " + CLProgram.Status.valueOf(bb.getInt(0)));
378 assertEquals("build status", CL.CL_BUILD_SUCCESS, bb.getInt(0));
379
380 // Read build log
381 ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_LOG, 0, null, longBuffer);
382 checkError("on clGetProgramBuildInfo2", ret);
383 out.println("program log length: " + longBuffer.get(0));
384
385 bb.rewind();
386 ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_LOG, bb.capacity(), bb, null);
387 checkError("on clGetProgramBuildInfo3", ret);
388 out.println("log:\n" + clString2JavaString(bb, (int)longBuffer.get(0)));
389
390 // Create the kernel
391 final long kernel = cl.clCreateKernel(program, "VectorAdd", intBuffer);
392 out.println("kernel id: "+kernel);
393 checkError("on clCreateKernel", intBuffer.get(0));
394
395// srcA.limit(elementCount*SIZEOF_FLOAT);
396// srcB.limit(elementCount*SIZEOF_FLOAT);
397
398 fillBuffer(srcA, 23456);
399 fillBuffer(srcB, 46987);
400
401 // Set the Argument values
402 ret = cl.clSetKernelArg(kernel, 0, is32Bit()?SIZEOF_INT:SIZEOF_LONG, wrap(devSrcA)); checkError("on clSetKernelArg0", ret);
403 ret = cl.clSetKernelArg(kernel, 1, is32Bit()?SIZEOF_INT:SIZEOF_LONG, wrap(devSrcB)); checkError("on clSetKernelArg1", ret);
404 ret = cl.clSetKernelArg(kernel, 2, is32Bit()?SIZEOF_INT:SIZEOF_LONG, wrap(devDst)); checkError("on clSetKernelArg2", ret);
405 ret = cl.clSetKernelArg(kernel, 3, SIZEOF_INT, wrap(elementCount)); checkError("on clSetKernelArg3", ret);
406
407 out.println("used device memory: "+ (srcA.capacity()+srcB.capacity()+dest.capacity())/1000000 +"MB");
408
409 // Asynchronous write of data to GPU device
410 ret = cl.clEnqueueWriteBuffer(commandQueue, devSrcA, CL.CL_FALSE, 0, srcA.capacity(), srcA, 0, null, null);
411 checkError("on clEnqueueWriteBuffer", ret);
412 ret = cl.clEnqueueWriteBuffer(commandQueue, devSrcB, CL.CL_FALSE, 0, srcB.capacity(), srcB, 0, null, null);
413 checkError("on clEnqueueWriteBuffer", ret);
414
415 // Launch kernel
416 final PointerBuffer gWS = PointerBuffer.allocateDirect(1).put(globalWorkSize).rewind();
417 final PointerBuffer lWS = PointerBuffer.allocateDirect(1).put(localWorkSize).rewind();
418 ret = cl.clEnqueueNDRangeKernel(commandQueue, kernel, 1, null, gWS, lWS, 0, null, null);
419 checkError("on clEnqueueNDRangeKernel", ret);
420
421 // Synchronous/blocking read of results
422 ret = cl.clEnqueueReadBuffer(commandQueue, devDst, CL.CL_TRUE, 0, dest.capacity(), dest, 0, null, null);
423 checkError("on clEnqueueReadBuffer", ret);
424
425 out.println("a+b=c result snapshot: ");
426 for(int i = 0; i < 10; i++)
427 out.print(dest.getInt()+", ");
428 out.println("...; "+dest.remaining()/SIZEOF_INT + " more");
429
430
431 // cleanup
432 ret = cl.clReleaseCommandQueue(commandQueue);
433 checkError("on clReleaseCommandQueue", ret);
434
435 ret = cl.clReleaseMemObject(devSrcA);
436 checkError("on clReleaseMemObject", ret);
437 ret = cl.clReleaseMemObject(devSrcB);
438 checkError("on clReleaseMemObject", ret);
439 ret = cl.clReleaseMemObject(devDst);
440 checkError("on clReleaseMemObject", ret);
441
442 ret = cl.clReleaseProgram(program);
443 checkError("on clReleaseProgram", ret);
444
445 ret = cl.clReleaseKernel(kernel);
446 checkError("on clReleaseKernel", ret);
447
448// ret = cl.clUnloadCompiler();
449// checkError("on clUnloadCompiler", ret);
450
451 ret = cl.clReleaseContext(context);
452 checkError("on clReleaseContext", ret);
453
454 }
455
456// @Test
457 public void loadTest() throws InterruptedException {
458 //for memory leak detection; e.g watch out for "out of host memory" errors
459 out.println(" - - - loadTest - - - ");
460
461 final ExecutorService pool = Executors.newFixedThreadPool(8);
462 final List<Callable<Object>> tasks = new ArrayList<Callable<Object>>();
463
464 for(int i = 0; i < 100; i++) {
465 final int n = i;
466 tasks.add(new Callable<Object>() {
467 @Override
468 public Object call() {
469 try {
470 out.println("###start iteration " + n);
471 final LowLevelBindingTest test = new LowLevelBindingTest();
472 test.ELEMENT_COUNT = 123456;
474 out.println("###end iteration " + n);
475 } catch (final InterruptedException ex) {
476 throw new RuntimeException(ex);
477 }
478 return null;
479 }
480 });
481 }
482
483 for (final Future<Object> future : pool.invokeAll(tasks)) {
484 try {
485 future.get();
486 } catch (final ExecutionException ex) {
487 ex.printStackTrace();
488 pool.shutdown();
489 fail();
490 }
491 }
492 pool.shutdown();
493 pool.awaitTermination(300, TimeUnit.SECONDS);
494 }
495
496 private ByteBuffer wrap(final long value) {
497 return (ByteBuffer) newDirectByteBuffer(8).putLong(value).rewind();
498 }
499
500 private void checkForError(final int ret) {
501 this.checkError("", ret);
502 }
503
504 private void checkError(final String msg, final int ret) {
505 if(ret != CL.CL_SUCCESS)
506 throw CLException.newException(ret, msg);
507 }
508
509 public static void main(final String[] args) throws IOException {
510 final String tstname = LowLevelBindingTest.class.getName();
511 org.junit.runner.JUnitCore.main(tstname);
512 }
513
514}
This object represents an OpenCL device.
Definition: CLDevice.java:53
CLPlatfrorm representing a OpenCL implementation (e.g.
Definition: CLPlatform.java:99
static CL getLowLevelCLInterfaceForDevice(final long device)
Returns the low level binding interface to the OpenCL APIs for the specified device.
static CL getLowLevelCLInterface()
Returns the low level binding interface to the OpenCL APIs.
Represents a OpenCL program executed on one or more CLDevices.
Definition: CLProgram.java:64
Test testing the low level bindings.
static void main(final String[] args)
Java bindings to OpenCL, the Open Computing Language (generated).
Definition: CLImpl12.java:33
Java bindings to OpenCL, the Open Computing Language (generated).
Definition: CLImpl20.java:33
Enumeration for the type of a device.
Definition: CLDevice.java:798
static Type valueOf(final long clDeviceType)
Definition: CLDevice.java:831
static Status valueOf(final int clBuildStatus)
Definition: CLProgram.java:746
Java bindings to OpenCL, the Open Computing Language.
Definition: CL.java:26
long clCreateKernel(long program, String kernel_name, IntBuffer errcode_ret)
Interface to C language function: cl_kernel {@native clCreateKernel}(cl_program program,...
int clBuildProgram(long program, int deviceCount, PointerBuffer devices, String options, BuildProgramCallback cb)
Interface to C language function: int32_t {@native clBuildProgram}(cl_program, uint32_t,...
static final int CL_PROGRAM_NUM_DEVICES
Define "CL_PROGRAM_NUM_DEVICES" with expression '0x1162', CType: int.
Definition: CL.java:555
int clGetDeviceIDs(long platform, long device_type, int num_entries, PointerBuffer devices, IntBuffer num_devices)
Interface to C language function: cl_int {@native clGetDeviceIDs}(cl_platform_id platform,...
static final int CL_PLATFORM_VERSION
Define "CL_PLATFORM_VERSION" with expression '0x0901', CType: int.
Definition: CL.java:137
static final int CL_PROGRAM_BUILD_STATUS
Define "CL_PROGRAM_BUILD_STATUS" with expression '0x1181', CType: int.
Definition: CL.java:45
int clGetProgramInfo(long program, int param_name, long param_value_size, Buffer param_value, PointerBuffer param_value_size_ret)
Interface to C language function: cl_int {@native clGetProgramInfo}(cl_program program,...
static final int CL_DEVICE_NAME
Define "CL_DEVICE_NAME" with expression '0x102B', CType: int.
Definition: CL.java:653
int clReleaseKernel(long kernel)
Interface to C language function: cl_int {@native clReleaseKernel}(cl_kernel kernel)
long clCreateBuffer(long context, long flags, long size, Buffer host_ptr, IntBuffer errcode_ret)
Interface to C language function: cl_mem {@native clCreateBuffer}(cl_context context,...
static final int CL_PROGRAM_SOURCE
Define "CL_PROGRAM_SOURCE" with expression '0x1164', CType: int.
Definition: CL.java:229
int clReleaseContext(long context)
Interface to C language function: cl_int {@native clReleaseContext}(cl_context context)
static final int CL_DEVICE_TYPE
Define "CL_DEVICE_TYPE" with expression '0x1000', CType: int.
Definition: CL.java:93
static final int CL_DEVICE_MAX_WORK_GROUP_SIZE
Define "CL_DEVICE_MAX_WORK_GROUP_SIZE" with expression '0x1004', CType: int.
Definition: CL.java:749
int clGetContextInfo(long context, int param_name, long param_value_size, Buffer param_value, PointerBuffer param_value_size_ret)
Interface to C language function: cl_int {@native clGetContextInfo}(cl_context context,...
int clGetPlatformIDs(int num_entries, PointerBuffer platforms, IntBuffer num_platforms)
Interface to C language function: cl_int {@native clGetPlatformIDs}(cl_uint num_entries,...
static final int CL_PLATFORM_NAME
Define "CL_PLATFORM_NAME" with expression '0x0902', CType: int.
Definition: CL.java:583
static final int CL_CONTEXT_DEVICES
Define "CL_CONTEXT_DEVICES" with expression '0x1081', CType: int.
Definition: CL.java:691
int clGetDeviceInfo(long device, int param_name, long param_value_size, Buffer param_value, PointerBuffer param_value_size_ret)
Interface to C language function: cl_int {@native clGetDeviceInfo}(cl_device_id device,...
int clEnqueueWriteBuffer(long command_queue, long buffer, int blocking_write, long offset, long cb, Buffer ptr, int num_events_in_wait_list, PointerBuffer event_wait_list, PointerBuffer event)
Interface to C language function: cl_int {@native clEnqueueWriteBuffer}(cl_command_queue command_qu...
static final int CL_MEM_READ_ONLY
Define "CL_MEM_READ_ONLY" with expression '(1 << 2)', CType: int.
Definition: CL.java:73
static final int CL_TRUE
Define "CL_TRUE" with expression '1', CType: int.
Definition: CL.java:211
int clReleaseMemObject(long memobj)
Interface to C language function: cl_int {@native clReleaseMemObject}(cl_mem memobj)
static final int CL_FALSE
Define "CL_FALSE" with expression '0', CType: int.
Definition: CL.java:801
static final int CL_PROGRAM_BUILD_LOG
Define "CL_PROGRAM_BUILD_LOG" with expression '0x1183', CType: int.
Definition: CL.java:571
int clSetKernelArg(long kernel, int arg_index, long arg_size, Buffer arg_value)
Interface to C language function: cl_int {@native clSetKernelArg}(cl_kernel kernel,...
int clGetProgramBuildInfo(long program, long device, int param_name, long param_value_size, Buffer param_value, PointerBuffer param_value_size_ret)
Interface to C language function: cl_int {@native clGetProgramBuildInfo}(cl_program program,...
int clReleaseProgram(long program)
Interface to C language function: cl_int {@native clReleaseProgram}(cl_program program)
static final int CL_PLATFORM_PROFILE
Define "CL_PLATFORM_PROFILE" with expression '0x0900', CType: int.
Definition: CL.java:403
int clEnqueueReadBuffer(long command_queue, long buffer, int blocking_read, long offset, long cb, Buffer ptr, int num_events_in_wait_list, PointerBuffer event_wait_list, PointerBuffer event)
Interface to C language function: cl_int {@native clEnqueueReadBuffer}(cl_command_queue command_que...
static final int CL_SUCCESS
Define "CL_SUCCESS" with expression '0', CType: int.
Definition: CL.java:325
int clReleaseCommandQueue(long command_queue)
Interface to C language function: cl_int {@native clReleaseCommandQueue}(cl_command_queue command_q...
static final long CL_DEVICE_TYPE_ALL
Define "CL_DEVICE_TYPE_ALL" with expression '0xFFFFFFFF', CType: long.
Definition: CL.java:647
int clGetPlatformInfo(long platform, int param_name, long param_value_size, Buffer param_value, PointerBuffer param_value_size_ret)
Interface to C language function: cl_int {@native clGetPlatformInfo}(cl_platform_id platform,...
long clCreateContextFromType(PointerBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret)
Interface to C language function: cl_context {@native clCreateContextFromType}(cl_context_properti...
long clCreateProgramWithSource(long context, int count, String[] strings, PointerBuffer lengths, IntBuffer errcode_ret)
Interface to C language function: cl_program {@native clCreateProgramWithSource}(cl_context context...
static final int CL_BUILD_SUCCESS
Define "CL_BUILD_SUCCESS" with expression '0', CType: int.
Definition: CL.java:261
int clEnqueueNDRangeKernel(long command_queue, long kernel, int work_dim, PointerBuffer global_work_offset, PointerBuffer global_work_size, PointerBuffer local_work_size, int num_events_in_wait_list, PointerBuffer event_wait_list, PointerBuffer event)
Interface to C language function: cl_int {@native clEnqueueNDRangeKernel}(cl_command_queue command_...
static final int CL_MEM_WRITE_ONLY
Define "CL_MEM_WRITE_ONLY" with expression '(1 << 1)', CType: int.
Definition: CL.java:183
long clCreateCommandQueue(long context, long device, long properties, IntBuffer errcode_ret)
Interface to C language function: cl_command_queue {@native clCreateCommandQueue}(cl_context contex...
static final int CL_CONTEXT_PLATFORM
Define "CL_CONTEXT_PLATFORM" with expression '0x1084', CType: int.
Definition: CL.java:419
static final int CL_PLATFORM_VENDOR
Define "CL_PLATFORM_VENDOR" with expression '0x0903', CType: int.
Definition: CL.java:235
long clCreateContext(PointerBuffer properties, PointerBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret)
Interface to C language function: cl_context {@native clCreateContext}(intptr_t * ,...
A callback an application can register to be called when the program executable has been built (succe...