an opencl binding - zcl/panama
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Jan 27 11:36:03 UTC 2020
On 27/01/2020 05:07, Michael Zucchi wrote:
> The break-even point here is about 16 longs so a loop is currently
> better for where i'm using it, and even up to 256 the time is dwarfed
> by allocateNative() if used. And in some other testing I found
> varLongPtr.[gs]et(,i) is a still a good bit slower than ByteBuffer -
> which I believe is the performance target.
I think VarHandles and BB should be roughly the same - at least in the
Panama branch, but there are some tips and tricks to be mindful of:
* the VarHandle should always be in a final static (you follow this
guideline in your Native.java)
* when accessing arrays, indexed accessors should be preferred to single
element accessor + MemroyAddress::addOffset
* when using indexed accessors it is important that the index being
passed is a "long", not an "int" or some other type (you want to make
sure the VarHandle invocation is 'exact').
You seem to follow all these advices. By any chance, is "varLongPtr" a
var handle which accesses memory and get/set MemoryAddresses? Or does it
just retrieve longs (I can't find varLongPtr in the benchmark you
linked)? If the former, I'm pretty sure the slow down is related to this:
https://bugs.openjdk.java.net/browse/JDK-8237349?filter=37749
Maurizio
More information about the panama-dev
mailing list