panama experts meeting notes - oraclecr.openjdk.java.net/~jrose/pres/201708-panamaexperts.pdf16...
TRANSCRIPT
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.1
Panama experts meeting notesOracle Santa Clara, Friday 2017-0804 (a partial collection by John Rose)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.2
detailed presentation list
▪ Vector API, Intel TOI – Ian Graves, Sandhya Viswanathan ▪ Java ∩ Machine Learning – Adam Pocock, Tim Harris ▪ Layout Descriptor Language – Tobi Ajila ▪ Data and Method Binding – Mikael Vidstedt ▪ Thread Confinement – John Rose ▪ Crackable / Liftable Lambda – John Rose
(note: inquire of presenters for slide deck availability)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.3
codes like Java, works like native
▪ JNI that stays in the background ▪ roughly homomorphic code shapes (native concepts surfaced) ▪ the Binder pattern used for ANSI C, persistence, protocols, … ▪ safe, fast, flexible Java references to native memory (scoped/bounded)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.4
binder pattern
▪ Java-centric metadata: A JAR of annotated interfaces ▪ no executable bytecodes, just annotated API structure
▪ language-specific tool creates the JAR for language-specific binder ▪ language-specific annotations carry info. to binder ▪ native types and API points map to carrier types and Java API
▪ online binder that produces anonymous implementations ▪ also loads native code and other resources as needed
▪ binder can also be run at AOT time if needed ▪ basic tools: Pointer/Reference/Struct/Scope/MemoryRegion
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.5
jextract: the header file groveller
• What’s prototyped: • libclang integration • C header file extraction
• What we can deliver soon: • basic tooling APIs (command line) • data type extraction (stretch goal: function entry points)
• What we can’t do soon: • macros, inline constants and fns (require native code stubs) • C++ (initial studies only, requires native code stubs)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.6
ANSI C type mapping API
• What we have: • type descriptors • type registry • type conversions • unsigned types, bitfields • struct layout mechanism (including LDL interpreter)
• Groveler chooses API types (method returns) from registry • Binder takes Layout Desc. & Java API and generates code • What we don’t have:
• Civilizer story (how to up-level APIs to greater safety and EOU) • Mappings for other languages, schemas, or protocols (ANSI C only)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.7
layout definition language
• What we have: • prototype layout specs. in today’s jextract (C-centric)
• (jextract communicates field offsets piecemeal, not via LDL) • Ajila et al study (cross-platform support for C, packets, Cobol, etc.) • Rose/Ajila/Jen M-LDL document
• (minimized convex hull around known use cases) • agreed principles (platform-neutral, terse like printf/unpack)
• What we don’t have: • A full language and reusable layout engine (wary of xkcd-927)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.8
calling sequence generator (FFI)
• What we have: • abstract API • x86 implementation • JIT support (direct generation)
• What we don’t have: • Testing • Performance analysis • Functionality coverage (how much are we missing?)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.9
native programming APIs
• What we have: • pointers, structs, references, functions • scopes (temporal confinement), allocation • memory regions (spatial confinement)
• What we don’t have: • A story for uncontended thread confinement of native resources • Value-typed smart pointers (depends on Valhalla; box for now) • Exotic globals like errno and thread locals • Macros (native code stubs)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.10
Vector API
• What we have: • Excellent pathfinding, prototype & demos • Various JIT approaches (converging on C2 intrinsics) • Multiple vector formats supported (x86 only, but hey…) • C2 intrinsification experiments (coming to repo. soon)
• What we don’t have: • Ease of use, including natural lane-wise expressions • Other similar platforms (SPARC, SVE) • A story for GPUs
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.11
state of the repo
▪ Last merge from JDK (Henry Jen, February 2017). ▪ Recent activity:
▪ Vector kernel EL prototype (Ian, June 2017) ▪ Vector API prototype (Ian Graves, Paul Sandoz, 2016 to July 2017)
▪Older content: ▪ Array package, maybe good for ML (David Chase, 2014) ▪ Libclang bindings, jextract (Henry, 2014-2016) ▪ Code snippets, linkToNative (Vladimir Ivanov, 2015-2016) ▪ Binder, vectors, etc. (Mikael Vidstedt, Vladimir, 2015-2016) ▪MemoryRegion, Scope, Pointer (Henry, Mikael, 2016)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.12
demos
• What we have: • Simple stuff: getpid, stat, printf, qsort • Cool graphics (teapot) • Machine learning of cat faces (OpenCV, JNI-free & homomorphic)
• What we don’t have: • MOST IMPORTANT: Linear algebra packages (BLAS, etc.) • other languages: fortran, pascal, C++ • protocols (Protobuf, CapnProto, CBOR, Thrift, etc.) • embedded interpreters: lua, V8 (Jim has it working with JNI)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.13
other possible incoming
• Persistent memory binder (Steve Dohrmann, Intel) • V8 integration? • Lambda cracking experiments (token codes, probably)
• (token code = forth-like concatenative single-stack IR in BSM args) • DAX bindings? • Layout language upgrades? • Individual contribs? (e.g., Radek Smogura) • Work from Kudriavtsev/Voskresensky on Clank? • What else?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.14
external dependencies
• Stable libclang (incl. solutions on non-Linux systems) • Minimal value types (for smart pointers) • Crackable lambas (we are working on a JEP)
• (or an equivalent for lifting expressions; prototype with JVMCI and/or serialization)
• (more MH fu from javac?) • Better support for binder back end
• (anonymous class API, bridge-o-matic) • More collaborators? (Thank you Intel and IBM!!!) • More mature AOT strategy for on-line calculations (binder, BSMs)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.15
Metropolis
• Basic fact: Native interconnect required if HotSpot accepts Java code. • Future milestone: use Panama tools in our own HotSpot build
• Perhaps in NIO • May require AOT of Panama (run binder at AOT time) • Will require something like SVM static analysis
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.16
Some references
http://mail.openjdk.java.net/pipermail/panama-dev/ http://cr.openjdk.java.net/~jrose/panama/
using-interfaces.html, minimal-ldl.html, metadata.html, cppapi.cpp.txt, token-codes.html
http://cr.openjdk.java.net/~vlivanov/panama/ linkToNative, code snippets, long4_on_avx
http://cr.openjdk.java.net/~mikael/webrevs/panama/ http://cr.openjdk.java.net/~psandoz/panama/ http://j9java.github.io/panama-docs/ IBM LDL design notes http://llvm.org/devmtg/2017-03//assets/slides/ clank_java_port_of_c_cxx_compiler_frontend.pdf