Using the Vector API on (externally allocated) foreign memory

Antoine Chambille ach at activeviam.com
Mon Mar 9 11:02:21 UTC 2020


Hi John, thank you for the suggestion, wrapping native memory with a
ByteBuffer does work (com.sun.jna.Pointer.getByteBuffer(long address)).

However after running a few benchmarks it looks like the code loading
vectors from byte buffers is about twice slower than the same code loading
vectors from java arrays. Is this expected?

JDK freshly checked out and built for Windows 10 (
http://hg.openjdk.java.net/panama/dev -b vectorIntrinsics ). double[] data,
AVX2, Intel.


Best,
-Antoine



On Fri, Mar 6, 2020 at 8:43 PM John Rose <john.r.rose at oracle.com> wrote:

> On Mar 6, 2020, at 9:59 AM, Antoine Chambille <ach at activeviam.com> wrote:
>
>
> Is support for vector operations on (externally allocated) foreign memory
> being considered? Have we missed something?
>
>
> The current story is that you have to wrap a byte buffer around
> your native memory, using JNI’s NewDirectByteBuffer.  Please
> let us know if that doesn’t work for you.
>
> It is likely that vectors will interoperate with a more modern API
> for both on-heap and off-heap access, after it settles.  These “memory
> segments” are incubating in JDK 14:
>
>
> https://download.java.net/java/GA/jdk14/docs/api/jdk.incubator.foreign/jdk/incubator/foreign/MemorySegment.html
>
> — John
>


-- 
  [image: ActiveViam] <https://www.activeviam.com> [image: LinkedIn]
<https://www.linkedin.com/company/activeviam>

Antoine Chambille
*Global Head of Research & Development *

[image: Office] +33 (0)1 40 13 91 00
[image: YouTube] <https://www.youtube.com/user/QuartetFS/videos>
[image: Blog] <https://www.activeviam.com/blog/>
[image: Twitter] <https://twitter.com/active_viam>
[image: location]
<https://maps.google.com/?q=46+rue+de+l+Arbre+Sec,+75001+Paris,+France>  46
rue de l'Arbre Sec, 75001 Paris [image: url]
<https://www.activeviam.com>  visit
our website


More information about the panama-dev mailing list