github链接
Aparapi 主要是用jni调用openCL封装库, 有点像javacv和opencv的感觉,那么我为什么不用JavaCL呢,因为SparkCL用的是Aparapi,所以惯性惰性就用这个了。(有人说javaCL更多底层调用,Aparapi注重high-level的)
Kernel.java
最核心的就是这个,sparkCL也是通过override这里面的run函数来实现的。
另外,线程的并行不是用implement runnable或者extends Thread来实现的,而是利用java.util.concurrent这个包。
/**
* A <i>kernel</i> encapsulates a data parallel algorithm that will execute either on a GPU
* (through conversion to OpenCL) or on a CPU via a Java Thread Pool.
* <p>
* To write a new kernel, a developer extends the <code>Kernel</code> class and overrides the <code>Kernel.run()</code> method.
* To execute this kernel, the developer creates a new instance of it and calls <code>Kernel.execute(int globalSize)</code> with a suitable 'global size'. At runtime
* Aparapi will attempt to convert the <code>Kernel.run()</code> method (and any method called directly or indirectly
* by <code>Kernel.run()</