JOCL v2.6.0-rc-20250722
JOCL, OpenCL® API Binding for Java™ (public API).
CLCommandQueueTest.java
Go to the documentation of this file.
1/*
2 * Copyright 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 org.junit.FixMethodOrder;
32import org.junit.Rule;
33import org.junit.rules.Timeout;
34import org.junit.runners.MethodSorters;
35
36import java.util.concurrent.CountDownLatch;
37
38import com.jogamp.opencl.test.util.MiscUtils;
39import com.jogamp.opencl.test.util.UITestCase;
40import com.jogamp.opencl.util.MultiQueueBarrier;
41import com.jogamp.opencl.CLCommandQueue.Mode;
42import com.jogamp.opencl.CLMemory.Mem;
43import com.jogamp.opencl.util.CLDeviceFilters;
44import com.jogamp.opencl.util.CLPlatformFilters;
45import com.jogamp.opencl.llb.CL;
46
47import java.io.IOException;
48import java.nio.ByteBuffer;
49import java.nio.IntBuffer;
50import java.util.EnumSet;
51import java.util.concurrent.TimeUnit;
52
53import org.junit.Test;
54
55import static org.junit.Assert.*;
56import static java.lang.System.*;
57import static com.jogamp.opencl.test.util.MiscUtils.*;
58import static com.jogamp.opencl.CLEvent.*;
59import static com.jogamp.opencl.CLVersion.*;
60import static com.jogamp.common.nio.Buffers.*;
61import static com.jogamp.opencl.CLCommandQueue.Mode.*;
62
63/**
64 * @author Michael Bien, et.al.
65 */
66@FixMethodOrder(MethodSorters.NAME_ASCENDING)
67public class CLCommandQueueTest extends UITestCase {
68
69 @Rule
70 public Timeout methodTimeout = new Timeout(20000);
71
72 @Test
73 public void enumsTest() {
74
75 //CLCommandQueueEnums
77 assertTrue(queueMode.contains(OUT_OF_ORDER_MODE));
78 assertTrue(queueMode.contains(PROFILING_MODE));
79
80 assertNotNull(Mode.valuesOf(0));
81 assertEquals(0, Mode.valuesOf(0).size());
82 for (final Mode mode : Mode.values()) {
83 assertEquals(mode, Mode.valueOf(mode.QUEUE_MODE));
84 }
85
86 // CLEvent enums
87 for (final ProfilingCommand cmd : ProfilingCommand.values()) {
88 assertEquals(cmd, ProfilingCommand.valueOf(cmd.COMMAND));
89 }
90
91 for (final CommandType type : CommandType.values()) {
92 assertEquals(type, CommandType.valueOf(type.TYPE));
93 }
94
95 for (final ExecutionStatus status : ExecutionStatus.values()) {
96 assertEquals(status, ExecutionStatus.valueOf(status.STATUS));
97 }
98
99 }
100
101 @Test
102 public void eventsTest() throws IOException {
103
104 out.println(" - - - event synchronization test - - - ");
105
106 final CLContext context = CLContext.create();
107
108 try{
109 final CLDevice device = context.getDevices()[0];
110 final int groupSize = device.getMaxWorkItemSizes()[0];
111
112 final int elements = roundUp(groupSize, ONE_MB / SIZEOF_INT * 5); // 5MB per buffer
113
114 final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
115 final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
116 final CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
117 final CLBuffer<ByteBuffer> clBufferD = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
118
119 fillBuffer(clBufferA.buffer, 12345);
120 fillBuffer(clBufferB.buffer, 67890);
121
122 final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build();
123 final CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements);
124 final CLCommandQueue queue = device.createCommandQueue();
125
126 out.println(queue);
127
128 final CLEventList events = new CLEventList(2);
129
130 out.println(events);
131
132 assertEquals(0, events.size());
133
134 queue.putWriteBuffer(clBufferA, false, events) // write A
135 .putWriteBuffer(clBufferB, false, events);// write B
136
137 out.println(events);
138
139 assertEquals(2, events.size());
140 queue.putWaitForEvents(events, true);
141
142 events.release();
143 assertEquals(0, events.size());
144
145 vectorAddKernel.setArgs(clBufferA, clBufferB, clBufferC); // C = A+B
146 queue.put1DRangeKernel(vectorAddKernel, 0, elements, groupSize, events);
147
148 vectorAddKernel.setArgs(clBufferA, clBufferB, clBufferD); // D = A+B
149 queue.put1DRangeKernel(vectorAddKernel, 0, elements, groupSize, events);
150
151 assertEquals(2, events.size());
152 queue.putWaitForEvent(events, 0, true)
153 .putWaitForEvent(events, 1, true);
154
155 events.release();
156
157 queue.putReadBuffer(clBufferC, false, events)
158 .putReadBuffer(clBufferD, false, events);
159
160 queue.putWaitForEvents(events, true);
161
162 events.release();
163
164 checkIfEqual(clBufferC.buffer, clBufferD.buffer, elements);
165 out.println("results are valid");
166 }finally{
167 context.release();
168 }
169 }
170
171 @SuppressWarnings("unchecked")
172 @Test
173 public void eventConditionsTest() throws IOException {
174
175 out.println(" - - - event conditions test - - - ");
176
177 final CLPlatform platform = CLPlatform.getDefault(CLPlatformFilters.queueMode(OUT_OF_ORDER_MODE));
178
179 CLDevice device = null;
180 // we can still test this with in-order queues
181 if(platform == null) {
183 }else{
184 device = platform.getMaxFlopsDevice(CLDeviceFilters.queueMode(OUT_OF_ORDER_MODE));
185 }
186
187 final CLContext context = CLContext.create(device);
188
189 try{
190
191 final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build();
192
193 final CLBuffer<IntBuffer> buffer = context.createBuffer(newDirectIntBuffer(new int[]{ 1,1,1, 1,1,1, 1,1,1 }));
194
195 final int elements = buffer.getNIOCapacity();
196
197 CLCommandQueue queue;
198 if(device.getQueueProperties().contains(OUT_OF_ORDER_MODE)) {
199 queue = device.createCommandQueue(OUT_OF_ORDER_MODE);
200 }else{
201 queue = device.createCommandQueue();
202 }
203
204 // simulate in-order queue by accumulating events of prior commands
205 final CLEventList events = new CLEventList(3);
206
207 // (1+1)*2 = 4; conditions enforce propper order
208 final CLKernel addKernel = program.createCLKernel("add").putArg(buffer).putArg(1).putArg(elements);
209 final CLKernel mulKernel = program.createCLKernel("mul").putArg(buffer).putArg(2).putArg(elements);
210
211 queue.putWriteBuffer(buffer, false, events);
212
213 queue.put1DRangeKernel(addKernel, 0, elements, 1, events, events);
214 queue.put1DRangeKernel(mulKernel, 0, elements, 1, events, events);
215
216 queue.putReadBuffer(buffer, false, events, null);
217
218 queue.finish();
219
220 events.release();
221
222 for (int i = 0; i < elements; i++) {
223 assertEquals(4, buffer.getBuffer().get(i));
224 }
225
226 }finally{
227 context.release();
228 }
229
230 }
231
232 @Test
233 public void profilingEventsTest() throws IOException {
234
235 out.println(" - - - event synchronization test - - - ");
236
237 final CLContext context = CLContext.create();
238
239 try {
240 final CLDevice device = context.getDevices()[0];
241 final int groupSize = device.getMaxWorkItemSizes()[0];
242
243 final int elements = roundUp(groupSize, ONE_MB / SIZEOF_INT * 5); // 5MB per buffer
244
245 final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
246 final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
247 final CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
248
249 fillBuffer(clBufferA.buffer, 12345);
250 fillBuffer(clBufferB.buffer, 67890);
251
252 final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build();
253 final CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements);
254 final CLCommandQueue queue = device.createCommandQueue(PROFILING_MODE);
255
256 out.println(queue);
257
258 queue.putWriteBuffer(clBufferA, true) // write A
259 .putWriteBuffer(clBufferB, true);// write B
260
261 final CLEventList events = new CLEventList(1);
262
263 assertEquals(0, events.size());
264
265 vectorAddKernel.setArgs(clBufferA, clBufferB, clBufferC); // C = A+B
266 queue.put1DRangeKernel(vectorAddKernel, 0, elements, groupSize, events);
267
268 assertEquals(1, events.size());
269 final CLEvent probe = events.getEvent(0);
270 out.println(probe);
271
272 queue.putWaitForEvents(events, true);
273 assertEquals(CLEvent.ExecutionStatus.COMPLETE, probe.getStatus());
274
275 out.println(probe);
276 final long time = probe.getProfilingInfo(CLEvent.ProfilingCommand.END)
278 out.println("time: "+time);
279 assertTrue(time > 0);
280
281 events.release();
282 }finally{
283 context.release();
284 }
285
286 }
287
288 @Test
289 public void customEventsTest() throws IOException, InterruptedException {
290 out.println(" - - - user events test - - - ");
291
292 final CLPlatform[] platforms = CLPlatform.listCLPlatforms();
293 CLPlatform theChosenOne = platforms[0];
294 for (final CLPlatform platform : platforms) {
295 if(platform.isAtLeast(CL_1_1)) {
296 theChosenOne = platform;
297 break;
298 }
299 }
300
301 if(!theChosenOne.isAtLeast(CL_1_1)) {
302 out.println("test disabled, required CLVersion: "+CL_1_1+" available: "+theChosenOne.getVersion());
303 return;
304 }
305
306 final CLContext context = CLContext.create(theChosenOne);
307
308 try{
309 final CLDevice device = context.getDevices()[0];
310 final int groupSize = device.getMaxWorkItemSizes()[0];
311
312 final int elements = roundUp(groupSize, ONE_MB / SIZEOF_INT * 5); // 5MB per buffer
313
314 final CLBuffer<ByteBuffer> clBufferA = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
315 final CLBuffer<ByteBuffer> clBufferB = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
316 final CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
317
318 fillBuffer(clBufferA.buffer, 12345);
319 fillBuffer(clBufferB.buffer, 67890);
320
321 final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build();
322 final CLKernel vectorAddKernel = program.createCLKernel("VectorAddGM").setArg(3, elements);
323 final CLCommandQueue queue = device.createCommandQueue();
324
325 queue.putWriteBuffer(clBufferA, true) // write A
326 .putWriteBuffer(clBufferB, true);// write B
327
328 vectorAddKernel.setArgs(clBufferA, clBufferB, clBufferC); // C = A+B
329
330 // the interesting part...
331
332 final CLUserEvent condition = CLUserEvent.create(context);
333 assertEquals(CommandType.USER, condition.getType());
334 assertEquals(ExecutionStatus.SUBMITTED, condition.getStatus());
335 out.println(condition);
336
337 final CLEventList conditions = new CLEventList(condition);
338 final CLEventList events = new CLEventList(1);
339 assertEquals(1, conditions.size());
340 assertEquals(1, conditions.capacity());
341 assertEquals(0, events.size());
342 assertEquals(1, events.capacity());
343
344 queue.put1DRangeKernel(vectorAddKernel, 0, elements, groupSize, conditions, events);
345 assertEquals(1, events.size());
346
347 Thread.sleep(1000);
348 final CLEvent status = events.getEvent(0);
349
350 // on Intel, user events start as submitted instead of queued
351 if(context.getPlatform().isVendorIntel())
352 assertEquals(ExecutionStatus.SUBMITTED, status.getStatus());
353 else
354 assertEquals(ExecutionStatus.QUEUED, status.getStatus());
355
356 condition.setComplete();
357 assertTrue(condition.isComplete());
358
359 queue.finish();
360 assertTrue(status.isComplete());
361
362 }finally{
363 context.release();
364 }
365
366 }
367
368 @Test
369 public void eventCallbackTest() throws InterruptedException {
370
371 out.println(" - - - event callback test - - - ");
372
373 final CLPlatform platform = CLPlatform.getDefault();
374
375 if(!platform.isAtLeast(CL_1_1)) {
376 out.println("test disabled, required CLVersion: "+CL_1_1+" available: "+platform.getVersion());
377 return;
378 }
379
380 final CLContext context = CLContext.create();
381
382 try{
383
384 final CLUserEvent customEvent = CLUserEvent.create(context);
385
386 final CountDownLatch countdown = new CountDownLatch(1);
387 customEvent.registerCallback(new CLEventListener() {
388 @Override
389 public void eventStateChanged(final CLEvent event, final int status) {
390 out.println("event received: "+event);
391 assertEquals(event, customEvent);
392 countdown.countDown();
393 }
394
395 });
396
397 customEvent.setStatus(ExecutionStatus.COMPLETE);
398 countdown.await(2, TimeUnit.SECONDS);
399 assertEquals(countdown.getCount(), 0);
400
401 customEvent.release();
402 }finally{
403 context.release();
404 }
405
406 }
407
408 @Test
409 public void concurrencyTest() throws IOException, InterruptedException {
410
411 out.println(" - - - QueueBarrier test - - - ");
412
413 final int elements = ONE_MB / SIZEOF_INT * 10; // 20MB per buffer
414
415 final CLContext context = CLContext.create();
416
417 try{
418
419 final CLDevice[] devices = context.getDevices();
420
421 // ignore this test if we can't test in parallel
422 if (devices.length < 2) {
423 out.println("aborting test... need at least 2 devices");
424 return;
425 }
426
427 final CLBuffer<ByteBuffer> clBufferC = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
428 final CLBuffer<ByteBuffer> clBufferD = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
429
430 final CLBuffer<ByteBuffer> clBufferA1 = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
431 final CLBuffer<ByteBuffer> clBufferB1 = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
432 final CLBuffer<ByteBuffer> clBufferA2 = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
433 final CLBuffer<ByteBuffer> clBufferB2 = context.createByteBuffer(elements * SIZEOF_INT, Mem.READ_ONLY);
434
435 final CLProgram program = context.createProgram(getClass().getResourceAsStream("testkernels.cl")).build();
436
437 //two independent kernel instances
438 final CLKernel vectorAddKernel1 = program.createCLKernel("VectorAddGM").setArg(3, elements);
439 final CLKernel vectorAddKernel2 = program.createCLKernel("VectorAddGM").setArg(3, elements);
440
441 final CLCommandQueue queue1 = devices[0].createCommandQueue();
442 final CLCommandQueue queue2 = devices[1].createCommandQueue();
443
444 out.println(queue1);
445 out.println(queue2);
446
447 fillBuffer(clBufferC.buffer, 12345);
448
449
450 final MultiQueueBarrier barrier = new MultiQueueBarrier(2);
451
452 final Thread thread1 = new Thread("C") {
453
454 @Override
455 public void run() {
456
457 final int groupSize = queue1.getDevice().getMaxWorkItemSizes()[0];
458
459 fillBuffer(clBufferA1.buffer, 12345);
460 fillBuffer(clBufferB1.buffer, 67890);
461
462 // System.out.println("C buffer");
463 queue1.putWriteBuffer(clBufferA1, false) // write A
464 .putWriteBuffer(clBufferB1, false); // write B
465
466 // System.out.println("C args");
467 vectorAddKernel1.setArgs(clBufferA1, clBufferB1, clBufferC); // C = A+B
468
469 // System.out.println("C kernels");
470 final CLEventList events1 = new CLEventList(2);
471 queue1.put1DRangeKernel(vectorAddKernel1, 0, elements, groupSize, events1)
472 .putReadBuffer(clBufferC, false, events1);
473
474 barrier.waitFor(queue1, events1);
475
476 }
477 };
478
479 final Thread thread2 = new Thread("D") {
480
481 @Override
482 public void run() {
483
484 final int maxWorkItemSize = queue2.getDevice().getMaxWorkItemSizes()[0];
485 final int kernelWorkGroupSize = (int)vectorAddKernel2.getWorkGroupSize( queue2.getDevice() );
486 final int localWorkSize = Math.min( maxWorkItemSize, kernelWorkGroupSize );
487
488 fillBuffer(clBufferA2.buffer, 12345);
489 fillBuffer(clBufferB2.buffer, 67890);
490
491 // System.out.println("D buffer");
492 queue2.putWriteBuffer(clBufferA2, false) // write A
493 .putWriteBuffer(clBufferB2, false); // write B
494
495 // System.out.println("D args");
496 vectorAddKernel2.setArgs(clBufferA2, clBufferB2, clBufferD); // D = A+B
497
498 // System.out.println("D kernels");
499 final CLEventList events2 = new CLEventList(2);
500 queue2.put1DRangeKernel(vectorAddKernel2, 0, elements, localWorkSize, events2);
501 queue2.putReadBuffer(clBufferD, false, events2);
502
503 barrier.waitFor(queue2, events2);
504
505 }
506 };
507
508 out.println("starting threads");
509 thread1.start();
510 thread2.start();
511 assertTrue(barrier.await(5, TimeUnit.SECONDS));
512 out.println("done");
513
514 checkIfEqual(clBufferC.buffer, clBufferD.buffer, elements);
515 out.println("results are valid");
516
517 } catch (final Throwable t ) {
518 t.printStackTrace();
519 } finally {
520 context.release();
521 }
522
523 }
524 public static void main(final String[] args) throws IOException {
525 final String tstname = CLCommandQueueTest.class.getName();
526 org.junit.runner.JUnitCore.main(tstname);
527 }
528}
OpenCL buffer object wrapping an optional NIO buffer.
Definition: CLBuffer.java:46
static void main(final String[] args)
The command queue is used to queue a set of operations for a specific CLDevice.
CLCommandQueue put1DRangeKernel(final CLKernel kernel, final long globalWorkOffset, final long globalWorkSize, final long localWorkSize)
Calls {@native clEnqueueNDRangeKernel}.
CLCommandQueue finish()
Calls {@native clFinish}.
CLDevice getDevice()
Returns the device of this command queue.
CLCommandQueue putWaitForEvents(final CLEventList list, final boolean blockingWait)
Calls {@native clWaitForEvents} if blockingWait equals true otherwise {@native clEnqueueWaitForEvents...
CLCommandQueue putWaitForEvent(final CLEventList list, final int index, final boolean blockingWait)
Calls {@native clWaitForEvents} if blockingWait equals true otherwise {@native clEnqueueWaitForEvents...
CLCommandQueue putWriteBuffer(final CLBuffer<?> writeBuffer, final boolean blockingRead)
Calls {@native clEnqueueWriteBuffer}.
CLCommandQueue putReadBuffer(final CLBuffer<?> readBuffer, final boolean blockingRead)
Calls {@native clEnqueueReadBuffer}.
CLContext is responsible for managing objects such as command-queues, memory, program and kernel obje...
Definition: CLContext.java:79
CLDevice[] getDevices()
Returns all devices associated with this CLContext.
Definition: CLContext.java:638
CLProgram createProgram(final String src)
Creates a program from the given sources, the returned program is not build yet.
Definition: CLContext.java:243
static CLContext create()
Creates a context on all available devices (CL_DEVICE_TYPE_ALL).
Definition: CLContext.java:139
final CLBuffer<?> createBuffer(final int size, final Mem... flags)
Creates a CLBuffer with the specified flags.
Definition: CLContext.java:341
final CLBuffer< ByteBuffer > createByteBuffer(final int size, final Mem... flags)
Creates a CLBuffer with the specified flags and buffer size in bytes.
Definition: CLContext.java:327
CLPlatform getPlatform()
Returns the CLPlatform this context is running on.
Definition: CLContext.java:569
This object represents an OpenCL device.
Definition: CLDevice.java:53
CLCommandQueue createCommandQueue()
Definition: CLDevice.java:72
int[] getMaxWorkItemSizes()
Returns the maximum number of work-items that can be specified in each dimension of the work-group.
Definition: CLDevice.java:339
EnumSet< CLCommandQueue.Mode > getQueueProperties()
Returns the command-queue properties supported by the device.
Definition: CLDevice.java:589
Fixed size list for storing CLEvents.
int capacity()
Returns the maximum size of this list.
void release()
Releases all CLEvents in this list.
CLEvent getEvent(final int index)
Event objects can be used for synchronizing command queues, e.g you can wait until a event occurs or ...
Definition: CLEvent.java:48
long getProfilingInfo(final ProfilingCommand command)
Definition: CLEvent.java:107
ExecutionStatus getStatus()
Returns the execution status of the command which triggers this event.
Definition: CLEvent.java:87
boolean isComplete()
Returns true only if getStatus returns ExecutionStatus#COMPLETE.
Definition: CLEvent.java:94
void registerCallback(final CLEventListener callback)
Registers a callback which will be called when the event terminates (COMPLETE or ERROR).
Definition: CLEvent.java:64
void release()
Releases the OpenCL resource.
Definition: CLEvent.java:78
High level abstraction for an OpenCL Kernel.
Definition: CLKernel.java:53
CLKernel setArg(final int argumentIndex, final CLMemory<?> value)
Definition: CLKernel.java:175
CLKernel putArg(final CLMemory<?> value)
Definition: CLKernel.java:107
long getWorkGroupSize(final CLDevice device)
Returns the work group size for this kernel on the given device.
Definition: CLKernel.java:332
CLKernel setArgs(final CLMemory<?>... values)
Definition: CLKernel.java:218
B getBuffer()
Returns the optional NIO buffer for this memory object.
Definition: CLMemory.java:137
int getNIOCapacity()
Returns the capacity of the wrapped direct buffer or 0 if no buffer available.
Definition: CLMemory.java:144
CLPlatfrorm representing a OpenCL implementation (e.g.
Definition: CLPlatform.java:99
boolean isAtLeast(final CLVersion other)
CLVersion getVersion()
Returns the OpenCL version supported by this platform.
static CLPlatform[] listCLPlatforms()
Lists all available OpenCL implementations.
CLDevice getMaxFlopsDevice()
Returns the device with maximal FLOPS from this platform.
static CLPlatform getDefault()
Returns the default OpenCL platform or null when no platform found.
Represents a OpenCL program executed on one or more CLDevices.
Definition: CLProgram.java:64
CLProgram build()
Builds this program for all devices associated with the context.
Definition: CLProgram.java:226
CLKernel createCLKernel(final String kernelName)
Creates a kernel with the specified kernel name.
Definition: CLProgram.java:410
Custom, user controlled event.
CLUserEvent setComplete()
Sets this event's status to CLEvent.ExecutionStatus#COMPLETE.
static CLUserEvent create(final CLContext context)
Creates a new user event.
CLUserEvent setStatus(final CLEvent.ExecutionStatus status)
Sets the event execution status.
CommandType getType()
Returns CLEvent.CommandType#USER.
static Filter< CLDevice > queueMode(final Mode... modes)
Accepts all devices supporting the specified command queue modes.
static Filter< CLPlatform > queueMode(final Mode... modes)
Accepts all platforms containing at least one devices supporting the specified command queue modes.
An utility for synchronizing multiple concurrent CLCommandQueues.
MultiQueueBarrier await()
Blocks until all Threads which called waitFor continue execution.
MultiQueueBarrier waitFor(final CLCommandQueue queue)
Blocks the current Thread until all commands on the CLCommandQueue finished excecution.
Enumeration for the command-queue settings.
static Mode valueOf(final int queueMode)
static EnumSet< Mode > valuesOf(final long bitfield)
COMPLETE
The command has completed.
Definition: CLEvent.java:242
START
A 64-bit value that describes the current device time counter in nanoseconds when the command identif...
Definition: CLEvent.java:186
END
A 64-bit value that describes the current device time counter in nanoseconds when the command identif...
Definition: CLEvent.java:192
Memory settings for configuring CLMemory.
Definition: CLMemory.java:289
READ_ONLY
Enum representing CL_MEM_READ_ONLY.
Definition: CLMemory.java:313
A callback for a specific command execution status.
Java bindings to OpenCL, the Open Computing Language.
Definition: CL.java:26
static final int CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
Define "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE" with expression '(1 << 0)', CType: int.
Definition: CL.java:537
static final int CL_QUEUE_PROFILING_ENABLE
Define "CL_QUEUE_PROFILING_ENABLE" with expression '(1 << 1)', CType: int.
Definition: CL.java:163