%\chapter{Technical Background}
\chapter{Java for Scientific Parallel Programming}
%\chapter{Java for Scientific Parallel Computting}

....
%This chapter is organized as follows. .......

In this section we briefly discuss some of works related to our work.
The remainder of this chapter is organized as follows.
.....


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Java Grande}
\label{JAVAGRANDE}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The attractiveness of Java for scientific computing is being
encouraged by bodies like Java Grande\cite{JAVAGRANDE}.
The Java Grande forum is motivated by the notion that Java has the 
enough potential to be an excellent language than any previous
languages such as C and Fortran for developing large science and
Grande applications, particularly on distributed and high-performance
computers. 

%Java could be
%the best possible Grande application development environment and the
%extensive use of Java could greatly help the large scale computing and
%communication fields.

The goal of the Java Grande Forum is to develop community
consensus and recommendations for either changes to Java or
establishment of standards for Grande libraries and services. 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Message Passing with Java and Its Related Work}
\label{MPJAVA}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A distributed memory system consists of processors and their local
memories connected by interconnection network. Since there is no
global memory, it is necessary to move data from one local memory to
another by means of message-passing. This is typically done through
{\it send/receive} API calls which must be written into the
application program.  
Message-passing remains one of the most effective and widely used
communication paradigms in parallel computing.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Java sockets}
\label{SOCKETS}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The Unix socket model is most suitable for programming client-server
applications. Typical scientific parallel programs do nor fit directly
into this model. Before a SPMD program can start two conditions must
obtain: a pool of symetric peer processes must have been created, and
each peer must be able to address a message to any
other. Bootstrapping this situation typically involves one host
starting remote invocations of the program(for example by using {\it
rsh} or a specialized daemon). All the peers will create listening
sockets, and all the port numbers must be broadcast somehow, then
socket connections will be made.

.......
Even with the simplified Java socket API, direct socket programming
will remain unattractive to scientific parallel programming.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Java RMI and Object Serialization}
\label{RMIOBJS}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Java RMI}
\label{RMI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Java Remote Method Invocation(RMI) which is an object-oriented version
of Remote Procedure Call(RPC), has been included with the Java
Development Kit release 1.1. 
%It was developed to make distributed application programming as
%simple as possible. 
RMI provides an simple and powerful Java-to-Java communication model
for invoking member	functions on objects that exist in other Java
virtual machines exactly as if it were local objects running in the
same virtual machines. 
As most distributed processing is conceived, RMI is based on the
Client-Server model. An overview of the Java RMI model is shown in
figure~\ref{RMI.fig}.

\begin{figure*}[b]
\centerline{\epsfig{figure=Figs/rmi.eps,width=5in}}
\caption{RMI Architecture.  \label{RMI.fig}}
\end{figure*}

%\begin{figure}
%\begin{center}
%\begin{picture}(124,558)
%\psfig{figure=Figs/rmi.eps,width=324pt,height=158pt}
%\end{picture}
%\end{center}
%\caption{RMI Architecture.  \label{RMI}}
%\end{figure}
%

The RMI architecture consists of three independent layers between the
application program and the Java virtual machine. Each layer is
independent and can be replaced by an alternate implementation.  The
three layers are the Stub and Skeleton Layer, the Remote Reference
Layer, and the Transport Layer. 

The respective applications reside on both the client and server
machines. The client and server communicate with the RMI system
through a stub and skeleton respectively. These methods reside on top of the
Remote Reference Layer and Transport Layer, allowing the RMI system to
handle the interface. When a single request occurs, it travels down
through the layers on one computers and up through the layers at the
other end. 

The stub and skeleton layer is responsible for marshaling and
unmarshaling the data and transmitting and receiving them to/from the
Remote Reference Layer. The data are marshaled and unmarshaled using a
parameter-passing mechanism {\it object serialization}. We will
briefly discuss object serialization in section ~\ref{OBJSERI}.

The Remote Reference Layer is responsible for carrying out the
invocation.
It can be behave differently depending on the parameters passed by the
calling program. For example, this layer can determine whether the
request is to call a single remote service or multiple remote programs
as in a multi-cast.

The Transport Layer is responsible for setting up connections,
managing request, monitoring them and listening for incoming calls.

High performance distributed computing can be done with Java RMI, but
this has a few weakness since RMI is designed for client-server programming
in web based systems over slow networks.
In parallel programming, fast RMI with low latency, high bandwidth,
and better reliability are required. % in areas of scientific application.
Since Java's object serialization often takes 25\%-50\% of the
time\cite{PHILIPPSEN99} needed for a remote invocation, better
serilazation is also needed towards a fast RMI. 

% which enable more scientific and engineering
						% applications to be solved in Java.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Object Serialization}
\label{OBJSERI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
As Java RMI, Object Serialization has been included with the Java
Development Kit release 1.1.
Object Serialization is a essential feature needed by Java's
RMI implementation. It provides a program the ability to read or write
a whole object to and from a raw byte stream. Object Serialization
allows Java objects and primitives and to be encoded into a byte stream
suitable for streaming to some type of network or to a file-system.
%more generally, to transmission medium or storage facility.
In order to provide this functionality, a object must implement the
Serializable interface. 

.....

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsection{Distributed Computing using RMI}
%\label{NEXUSRMI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%NexusRMI\cite{NEXUSRMI}.....
%NINJARMI....
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Efficient RMI and Object Serialization}
\label{EFFRMIOS}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Some groups have published ideas on more efficient RMI implementations
%or on better serilazations.
%Currently several projects are under way that achieve increased
%bandwidth, reduced latency, and better reliability within workstation
%clusters. 

%Since Java's object serialization often takes 25%-50% of the time
%needed for a remote invocation, an essential step towards a fast RMI
%is to reduce the cost of serialization as far as possible.
Several research groups are pursuing research to improve more efficient
Java RMI and object serialization implementation and its performance.

%
As part of the JavaParty\cite{JAVAPARTY} project at the University of
Karlsruhe, Germany, a more efficient RMI and object serialization have
been studied. JavaParty system provides a mechanism for parallel
cluster programming in Java.
Philippsen et al\cite{PHILIPPSEN98} describe detailed analysis of
RMI and object serialization and it's performance problem. It also
suggests modifications to improve RMI and object serialization.
Based on these suggestions, they implement more efficient version of
RMI and object serialization called KaRMI and UKA-serialization.
KaRMI\cite{NESTER99} improves the performance of RMI by clean
interfaces between layers and the separation of RMI's design from
transport level sockets. 
It also modify RMI to support non-TCP/IP communication networks.
KaRMI can not handle code that uses socket factory or port numbers.
UKA-serialization\cite{PHILIPPSEN99} uses explicit
marshaling/unmarshaling routines instead of reflection and a minimal
encoding of type information to achieve better performance. 
%Similar to this work, ...
In our work, we use ...JNI...to handle multidimensional array.....

%
Henri Bal's group of Vrije University, Netherlands, study alternative
approach for implementing RMI, called Manta RMI\cite{MAASSEN99}, based
on native compilation for better optimization. 
Manta\cite{MANTA99} is compiler-based Java system and uses a native
compiler that generates executable code rather than byte code. 
Manta system supports two different communication protocols.
Between Manta nodes, it can communicate through Manta's own a fast RMI
protocol using Manta's own serialization format. 
Manta node can communicate with another JVM through a JDK-compliant
protocol using Sun's serialization format. 
With Manta, the serialization code is generated by the compiler which
make it possible to avoid the overhead of dynamic inspection of the
object structure. 


Krishnaswamy et al\cite{KRISHNASWAMY98} improve RMI performance by
adding object caching at the reference layer and using UDP(User
Datagram Protocol) based reliable message delivery protocol.
% that exploits the request-response nature of RMI communications.
%(PHILIPPSEN99:realted work)An orthogonal approach is to avoid object
%serialization by means of object caching. Objects that are not sent
%will not cause any serialization overhead. 

Another implementation of RMI is provided by Thiruvathukal et al.
%RRMI\cite{RRMI98} offers
Reflective RMI(RRMI)\cite{RRMI98} adopted reflection feature of Java
programming language to invoke remote methods.
RRMI makes it possible of use RMI without stubs and skeletons. A
remote object is created dynamically at the run time by implementing
its own class loader on the server side.
It also supports both synchronous and a asynchronous remote method
invocations.

%
ARMI(Asynchronous RMI)\cite{RAJE} allows an asynchronous remote method
to RMI. It achieve asynchronous communication by replacing the RMI
client-side stub by adding thread mechanism. 

%
NexusRMI\cite{BREG98a} implements Java RMI on top of
NexusJava\cite{NEXUSJAVA}, which is a Java interface to the Nexus
communication system developed at Argone National Laboratory. 
NexusRMI also has support for object serialization of all object types
except for exception objects.
%NexusRMI object serialization.....

%
At the group of the University of California, Berkeley,
NinjaRMI\cite{WELSH} has been developed to support Ninja
project\cite{NINJA}. NinjaRMI has some features that are not found in
Sun's RMI including  multiple communication protocols.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Message Passing Libraries in Java}
\label{MPJAVA}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The most popular message-passing libraries are PVM and MPI.
Several projects are under way that make message-passing
packages support programs written in Java.
Current message-passing in Java can be categorized into two
categories. First category consists of Java based implementations use
Java as wrapper for existing message-passing libraries that are called
through the Java native interface(JNI). 
The use of native methods achieves better performance and allows
programmers to reuse existing codes. However, it restricts jobs to run
only on system where both Java and coressponding message-passing
library are supported.  

The other is that use only pure Java libraries. 
%This case the basic communication libraries are Java's RMI or socket.
The pure Java implementation obtains high degree of code portability
among platforms but relatively lower performance.  The performance
problem is expected to be overcome with just-in-time(JIT) compilation
and other compiler technologies.

%The inferior performance is expected to fade away with the fast
%evolving hardware support, just-in-time(JIT) compilation and other
%compiler technologies for Java.

....
%There are also available for networks of workstations. making it
%possible to treat many workstations as a single parallel machine.

%The use of native methods helps to obtain a high-performance
%communication layer and hides the slower computation speed of
%Java-based parallel message-passing programs.
%The 100% Java implementation helps to achieve cross-platform
%portability by benefiting from the standard Java execution
%environment. 

%Some groups have published ideas on more efficient RMI implementations
%or on better serilazations.
%Currently several projects are under way that achieve increased
%bandwidth, reduced latency, and better reliability within workstation
%clusters. 

%Some research groups are pursuing research to improve more efficient
%Java RMI implementation and its performance.

%Currently several projects are under way that achieve increased
%bandwidth, reduced latency, and better reliability within workstation
%clusters.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Parallel Virtual Machine(PVM) in Java}
\label{PVM}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PVM developed at Oak Ridge National Laboratory is a message-passing
system that permits a heterogeneous collection of networked computing
systems to be used as a single large parallel machine. 
Thus large computational problems can be solved more cost
effectively by using the aggregate power and memory of many 
computers. 
%The software is very portable and the source, which is
%available free through netlib, has been compiled on everything from
%PCs to super-computers. 
PVM consists of two parts: a daemon process,{\it pvmd}, that
any user can install on a machine, and a user library that contains
routines for initiating processes on other machine. PVM provides a
rich set of dynamic resource management and process control
functions(eg., load balancing). It also allows the development of
fault-tolerant applications with host or task failure and has good
interoperability between heterogeneous hosts.
PVM supports programs written in C, C++, and Fortran. 
Currently there are two groups working on making PVM support programs
written in Java. 


\begin{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\item {\bf Java-to-PVM interface} \\	
%	\subsubsection{Java-to-PVM interface}
%	\label{JAVAPVM}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JavaPVM(or jPVM)\cite{JAVAPVM} is an interface written using the
Java native methods capability which allows Java applications to use
the Parallel Virtual Machine (PVM) software.
Since it is using native method, it limits cross-platform
portability. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\item {\bf Pure Java implementation of PVM} \\
%	\subsubsection{Pure Java implementation of PVM}
%	\label{JPVM}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JPVM\cite{JPVM} is a pure Java implementation of PVM. Therefore unlike
JavaPVM, it is better matched Java programming styles and the
standardization of the JVM makes the JPVM code much simpler to
maintain across heterogeneous machine.
The performance is poor compared to JavaPVM.
The detail comparison of communication benchmark of native PVM,
JavaPVM, and JPVM is reported in\cite{YALAMA98}.

	\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Message-Passing Interface(MPI) in Java} 
\label{MPI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MPI\cite{MPIFORUM,USINGMPI} is a library of functions and macros that
can be used in C, FORTRAN, and C++ programs. 
MPI is intended for use in programs that
exploit the existence of multiple processors by message-passing. 
MPI was developed by a group of researchers from academia, industry,
and government. As such, it is one of the first standards for
programming parallel processors, and it is the first that is based on
message-passing. 
MPI provides a rich set of communication libraries,
application topology and user defined data types. The first phase of
MPI(MPI1) was focused on developing a message-passing standard. The
second phase of MPI effort(MPI2) is underway adding parallel I/O,
fault tolerance, language binding for C++ and additional
communications. 
Currently there are several known efforts towards the design of early
MPI interfaces for Java.

\begin{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\item {\bf Automatic generation of Java wrappers to MPI} \\
%\subsubsection{Java wrappers to MPI}
%\subsubsection{JavaMPI: Automatic generation of MPI wrappers}
%\label{JAVAMPI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A comparable approach to creating full Java MPI interfaces has been
taken by University of Westminster\cite{MINCHEV97,GETOV98}. In their
work Java wrappers were automatically generated from the C MPI header
using Java-to-C interface generator(JCI). This eases the
implementation work, but does not lead to a fully object-oriented API.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\item {\bf Pure Java implementation of MPI} \\
%\subsubsection{Pure Java implementation of MPI}
%\subsubsection{MPIJ: Pure Java implementation of MPI}
%\label{MPIJ}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MPIJ\cite{MPIJ} is a pure Java based subset of MPI developed at
Brigham Young University as part of the Distributed Object Group
Meta-computing Architecture(DOGMA)\cite{DOGMA} system.
Since it is implemented in only Java, portability....

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsubsection{jmpi: Pure Java implementation of MPI built upon JPVM}
%\label{JMPI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
jmpi\cite{JMPI98a,JMPI99} is a pure Java implementation of MPI built on
top of JPVM.
Due to additional wrapper layer to JPVM routines, its performance is
poor compared to JavaPVM.  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsubsection{JMPI: Pure Java implementation of MPI}
%\label{JMPI}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
JMPI\cite{JMPICOM} is a commercial effort underway at MPI Software Technology,
Inc. to develop a message-passing framework and parallel support
environment for Java. It targets to build a pure Java version of MPI-2
standard specialized for commercial applications. 

	\end{itemize}


%**********************************************************************

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Others}
\label{OTHERS}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Titanium\cite{TITANIUM98} is a Java based language and system for
high-performance parallel computing. It has additional features over
Java like immutable classes, multidimensional arrays, an explicitly
parallel SPMD model of computation with a global address space, and
a mechanism for programmer to control memory management. 
Immutable classes allow the compiler pass objects by value.
Because Titanium compiler translates Titanium into C, users do not
have full access to the AWT and certain other Java libraries directly
from Titanium. 
In our HPJava project, we have features like multidimensional
distributed arrays, explicit communication interface to MPI and fully
accessible to the Java libraries.... 

Spar\cite{SPAR97} is a programming language for semi-automatic
parallel programming, in particular for the programming of array-based
applications, supporting multidimensional and sparse arrays. 
Spar has been designed as part of the Automap project,
in which a compiler and run-time system are being developed for
distributed memory systems.

Java/DSM is heterogeneous computing system which implements a JVM on
top of Tread-Marks distributed shared memory(DSM) system.
In DSM system, no explicit communication is necessary and that
eliminates the need for the programmer to write message-passing code.
Because of the portability feature of Java, the combination of Java and DSM
completely hides the hardware differences and the distributed nature
of the system from the programmer view, providing a better platform
for heterogeneous computing environments.

javar\cite{JAVAR97} is a simple Java restructuring compiler, which is
written in C, that can automatically transform a Java program into a
form in which implicit parallelism is made explicit by means of
multi-threading. 

%JavaNOW is shared memory based system
JavaNow\cite{JAVANOW99} is a pure Java based framework that includes
features found in Linda, Actors, and Message Passing
Interface(MPI). It creates a PVM like virtual parallel machine and
provides distributed associative shared memory.  JavaNow is currently
available as stand-alone software and must be used with a remote (or
secure) shell tool in order to run on a network of workstations.
 
% Web-based :
%(JPVM)Another software package for network parallel computing in Java is
%the IceT system. IceT is an inherently collaborative, multi-user
%environment. IceT provides mechanism by which resources can be made
%available to the system for use by users who do not have log-on
%privileges. The attractive goals of this metacomputing-based approach
%include better utilization of larger resource bases, as well as an
%enhanced collaborative environment for high performance
%computing. Among the challenges introduced by this idea are the
%numerous security issues introduced by code-upload capabilities for
%non-privileged uses.
IceT\cite{ICET97} 



Javelin\cite{JAVELIN97} is internet-based global computing
infrastrutrs that support Java.






