[foreign] Pointer to fixed-size array: is jexctract's mapping to Java correct?

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Feb 28 15:08:44 UTC 2019


On 28/02/2019 14:52, Lev Serebryakov wrote:
> On 28.02.2019 16:50, Maurizio Cimadamore wrote:
>
>> On 28/02/2019 13:16, Lev Serebryakov wrote:
>>> Yep. And copy data from "java native" array and back. It will dominate
>>> execution time for small transform sizes, I'm afraid — copying from
>>> native Java array to these pairs. Performance-wise, best solution will
>>> be to have `Array<Double>` transparently backed by `double[]`, it will
>>> mimic C code as close as possibly (and as fast as possibly).
>> So, if efficiency is your main concern, I'd suggest to:
>>
>> 1) allocate a double array, as this:
>>
>> Array<Double> buffer  = Scope.allocateArray(NativeTypes.DOUBLE, npairs *
>> sizeofDouble * 2);
>    Should it be "npairs * 2"? It is not clear, is allocateArray() takes
> size in number of elements or in number of bytes.
>
>
Whoops - sorry, should be just npairs * 2 - it's element size, yes. The 
layout will do the rest.

Maurizio



More information about the panama-dev mailing list