[2022 javaone] Blisful linear algebra with project panama

Speaker: Paul Sandoz

For more see the table of contents

There was a lot of code/data so linking to the deck

BLIS

  • Superset of Basic Linear Algebra Subprograms
  • C library
  • On github

Panama

  • FFM (Foreign Function and Memory) API and tooling
  • Preview in Java 19
  • Call native libraries/process native data without brittleness/danger of JNDI
  • MemorySegment – contiguous region of memory – replaces ByteBuffer without size limits and memory management constraints
  • SegmentAllocator – malloc like for producing segments
  • MemorySession – manages deallocation of segments

Example

  • C and Java versions have same structure
  • Can do some logic in Java and use lambdas

MSET

  • Multivariate state estimation technique
  • Machine learning
  • MSET2 – proprietary enhancement to MSET
  • Design matrix – matrix of sensors and observations

My take

While I don’t think I’d ever need to use this, it is cool to see. I don’t miss C!

[kcdc 2021] Java 17’s Project Panama Newbies

This post is my live blog from KCDC. For more, see the 2021 KCDC live blog TOC

Speaker: Carl Dea (Azul)

Twitter: @carldea

————————-

Foojay.io has more

JEP 412 – Foreign Access API

  • https://openjdk.java.net/jeps/412 – ties together other JEPs
  • incubator module. Third incubabor
  • in making for at teast 6 years

Problems with old way

  • Communicating with required wrapper code and distributing a .ddl
  • Have to do a lo of work yourself to interfaces with C

URLs

  • jdk.java.net/panama
  • https://github.com/openjdk/panama-foreign
  • panama-dev@openjdk.java.net
  • https://foojay.io/today/project-panama-for-newbies-part-1/
  • https://foojay.io/today/project-panama-for-newbies-part-2/
  • https://foojay.io/today/project-panama-for-newbies-part-3/
  • https://github.com/carldea/panama4newbies

Using

  • java -version. Make sure says 17-panama. (Not part of main JDK)
  • jextract -h to get help
  • jextract will generate Java code for you by looking at C header file
  • Most important options
    • -I (capital Eye) – include file path
    • -d – destination for generate files
    • -l (lowercase ell) – specify a library
    • -t – target package
  • Must add incubator module and enable native access flag to run
  • Can call C methods from Java by importing them
  • Java wil hande the memory allocation/cleanup based on scope

Include

  • Copies file and puts in this file.
  • Not like import where it a reference

My take

This is a topic I knew nothing about. (Or forgot what I had known.) It was really cool to see!