JOCL v2.6.0-rc-20250722
JOCL, OpenCL® API Binding for Java™ (public API).
CLQueueContextFactory.java
Go to the documentation of this file.
1/*
2 * Created onSaturday, May 07 2011 00:40
3 */
4package com.jogamp.opencl.util.concurrent;
5
6import com.jogamp.opencl.CLCommandQueue;
7import com.jogamp.opencl.CLProgram;
8import com.jogamp.opencl.util.concurrent.CLQueueContext.CLSimpleQueueContext;
9
10/**
11 * Creates {@link CLQueueContext}s.
12 * @author Michael Bien
13 */
14public abstract class CLQueueContextFactory<C extends CLQueueContext> {
15
16 /**
17 * Creates a new queue context for the given queue.
18 * @param old the old context or null.
19 */
20 public abstract C setup(CLCommandQueue queue, CLQueueContext old);
21
22
23 /**
24 * Creates a simple context factory producing single program contexts.
25 * @param source sourcecode of a OpenCL program.
26 */
27 public static CLSimpleContextFactory createSimple(final String source) {
28 return new CLSimpleContextFactory(source);
29 }
30
31 /**
32 * Creates {@link CLSimpleQueueContext}s containing a precompiled program.
33 * @author Michael Bien
34 */
35 public static class CLSimpleContextFactory extends CLQueueContextFactory<CLSimpleQueueContext> {
36
37 private final String source;
38
39 public CLSimpleContextFactory(final String source) {
40 this.source = source;
41 }
42
43 @Override
45 final CLProgram program = queue.getContext().createProgram(source).build(queue.getDevice());
46 return new CLSimpleQueueContext(queue, program);
47 }
48
49 }
50
51}
The command queue is used to queue a set of operations for a specific CLDevice.
CLDevice getDevice()
Returns the device of this command queue.
CLProgram createProgram(final String src)
Creates a program from the given sources, the returned program is not build yet.
Definition: CLContext.java:243
CLContext getContext()
Returns the context for this OpenCL object.
Definition: CLObject.java:58
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
Creates CLSimpleQueueContexts containing a precompiled program.
CLSimpleQueueContext setup(final CLCommandQueue queue, final CLQueueContext old)
abstract C setup(CLCommandQueue queue, CLQueueContext old)
Creates a new queue context for the given queue.
static CLSimpleContextFactory createSimple(final String source)
Creates a simple context factory producing single program contexts.
A simple queue context holding a precompiled program and its kernels.
Superclass for all per-queue contexts as used in CLCommandQueuePools.