Java2C++_090528_Graf - Indico

Download Report

Transcript Java2C++_090528_Graf - Indico

Java to C++:
What would be needed ?
Norman Graf (SLAC)
ILC-CLIC Software, CERN
May 28, 2009
Problem Statement

Need to identify areas where access to C++
from a Java environment is needed and/or
provides an overwhelming benefit.
2
3
Why Java?

Java is a pure Object Oriented Language

Simpler to learn and use than C++


Language design emphasizes ease-of-use
Garbage collector takes care of freeing unused objects


Very powerful standard library


Not understanding core dumps and learning difference between a pointer and a
reference.
Performance of Java code is close to that of C++

Dynamic (runtime) optimization can take into account actual usage patterns



Linux, Windows, Mac OSX)
Physicist gets to concentrate on writing clean OO code to perform analysis
tasks


Large number of open-source libraries including libraries for scientific computing
Platform independent, compile once just runs everywhere


Avoids distorting OO design by avoiding need for “ownership”
not available to static optimizers used by Fortran, C++
Garbage collection often more efficient than user malloc/free (or new/delete)
Java is mainstream language


Taught in university courses
Used by majority of sourceforge “open-source” projects
4
Why Java?

Full access to runtime information makes interface to scripting languages easy



Jython, JRuby, Pnuts, …
Get reflection for free because it is an OO language.
Wide availability of tools

Several very powerful,free, IDE’s available:



e.g. Netbeans, Eclipse
Support editing, code completion, GUI building, debugging, performance profiling, refactoring, version control (CVS,
Subversion), etc…
Advanced tools such as maven (Apache) make project management easy

Maven is a Java based project management tool

After checking out code, single command “maven”

downloads dependencies,

Required libraries

Test Data

compiles code

runs test suite

deploys code
Maven can be integrated into IDE’s like Netbeans


Excellent support for threads


Running on grid/cloud is straightforward.


Will become more important with hyper-core machines.
JVM already provides the virtual machine
Performance of org.lcsim in end-to-end LOI physics benchmarking exercise has been
excellent
5
Technical possibilities

JNI

Currently used to access legacy event generators
Java  C++  Fortran


Also has been used to call C++ track-finding and
fitting code as a proof-of-principle.
JNA

Dynamically access native libraries from Java without
JNI.
6
Interoperability – Next Step



LCIO has been very successful in providing some interoperability
between disparate ILC tools
Obvious next step is to attempt “common geometry” system
 org.lcsim and Marlin (GEAR) geometry already very similar
 Have discussed this in the past (LCGO)
 This is a good area for someone interested in ILC software to get
involved.
Java -> C++ interoperability
 Ability to call C++ (MarlinReco) modules from org.lcsim??


Some experimentation ongoing with using SWIG to build glue code
See somewhat related (pre-alpha) project G4Java
 http://java.freehep.org/sandbox/G4Java/
7
Biases





Mixing C++ and Java in same program does not
work in a reasonable way.
Passing objects back and forth between
Java/C++ rapidly becomes a mess
Lose all advantages of Java's portability
Should only be a “last resort”
Plug-compatibility, i.e. exchanging data via
LCIO, works well and is our preferred method of
proceeding.
8

ALCPG simulation & reconstruction group plans
to continue development and support of SLIC
and org.lcsim and SiD plans to continue to use
these as their primary tools for detector
optimization going forward in the short term.
9