summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLContext.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-10-20 00:53:50 +0200
committerMichael Bien <[email protected]>2009-10-20 00:53:50 +0200
commit7f2db980b303fa75f3830679ce65fe4ae41c30dc (patch)
treea22f4ad2a068ff0816ebc2a4ca71bb2426ee46e4 /src/com/mbien/opencl/CLContext.java
parent224985638b2a1486e4b7da1642a4f2cc22fc8644 (diff)
added CLCommandQueue to CLContext's resource management code, minor fixes...
Diffstat (limited to 'src/com/mbien/opencl/CLContext.java')
-rw-r--r--src/com/mbien/opencl/CLContext.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/CLContext.java b/src/com/mbien/opencl/CLContext.java
index fcbb8041..dda8eb05 100644
--- a/src/com/mbien/opencl/CLContext.java
+++ b/src/com/mbien/opencl/CLContext.java
@@ -7,7 +7,9 @@ import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import static com.mbien.opencl.CLException.*;
/**
@@ -23,6 +25,7 @@ public final class CLContext {
private final List<CLProgram> programs;
private final List<CLBuffer> buffers;
+ private final Map<CLDevice, List<CLCommandQueue>> queuesMap;
static{
System.loadLibrary("gluegen-rt");
@@ -34,6 +37,7 @@ public final class CLContext {
this.ID = contextID;
this.programs = new ArrayList<CLProgram>();
this.buffers = new ArrayList<CLBuffer>();
+ this.queuesMap = new HashMap<CLDevice, List<CLCommandQueue>>();
}
/**
@@ -78,6 +82,20 @@ public final class CLContext {
return buffer;
}
+ CLCommandQueue createCommandQueue(CLDevice device, long properties) {
+
+ CLCommandQueue queue = new CLCommandQueue(this, device, properties);
+
+ List<CLCommandQueue> list = queuesMap.get(device);
+ if(list == null) {
+ list = new ArrayList<CLCommandQueue>();
+ queuesMap.put(device, list);
+ }
+ list.add(queue);
+
+ return queue;
+ }
+
void programReleased(CLProgram program) {
programs.remove(program);
}
@@ -86,6 +104,14 @@ public final class CLContext {
buffers.remove(buffer);
}
+ void commandQueueReleased(CLDevice device, CLCommandQueue queue) {
+ List<CLCommandQueue> list = queuesMap.get(device);
+ list.remove(queue);
+ // remove empty lists from map
+ if(list.isEmpty())
+ queuesMap.remove(device);
+ }
+
/**
* Releases the context and all resources.
*/