Closed GoogleCodeExporter closed 9 years ago
I am sure Ryan will like to see this ;) he has been talking about something
like this for a while.
This may be a little tricky from the JNI side using present code base. We
can't hold a pinned buffer across JNI calls, we like to pin buffers so that the
JVM does not move them around whilst we are executing or transferring between
host and device.
We have been toying with relaxing this and possibly only pinning during the
clEnqueueBufferRead and write Write phases, this will/might slow us down a
little, but it would mean that the writes, execute and reads can be performed
in separate separate JNI calls. (Do we know how other Java OpenCL bindings
handle this race condition?)
See
http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html#GetPrimit
iveArrayCritical
Assuming we can get around the pinning issue. So we could create a few API's
here
Future<Kernel> future1 = kernel1.async(range1);
Future<Kernel> future2 = kernel2.async(range2);
// do some code
while (!(future1.isDone() && future2.isDone()){
Thread.sleep(n); // or some other work here
}
or
future1.get() && future2.get(); // will block for both
Or we could pass a listener SAM type to the async call
Kernel.async(range, new KernelListener(){
public void done(Kernel _kernel){
/* .. */
}
});
or using lambdas ;)
kernel.async(range, k -> {/* .. */});
Gary
Original comment by frost.g...@gmail.com
on 31 Mar 2013 at 3:55
Dupe: http://code.google.com/p/aparapi/issues/detail?id=62
Plus that ticket was already a year+ in the making :)
Personally, I've been envisioning the use of Annotations to mark which methods
get called-back when a kernel.async() has completed, based on concepts such as
a Producer/Consumer Event Bus.
Original comment by ryan.lam...@gmail.com
on 1 Apr 2013 at 6:38
Original comment by ryan.lam...@gmail.com
on 20 Apr 2013 at 12:39
Original issue reported on code.google.com by
lats...@gmail.com
on 31 Mar 2013 at 8:58