next up previous contents
Next: The polymorphism of Java Up: MPI Java Wrapper Implementation. Previous: Java datatypes   Contents

Problems due to strong typing and no pointer

All MPI functions with choice arguments associate actual arguments of different datatypes with the same dummy argument. This is not allowed by Java. In C, the void* formal arguments avoid these problems.

The following code fragment is technically illegal and may generate a compile-time error.

  float f = new float[10];
  double r = new double[10];

  MPI.COMM_WORLD.Send(f, *);
  MPI.COMM_WORLD.Send(r, *);
Technically, we will have to use methods overload with different argument datatype or methods with different identifier.

The methods overload implementation in native method will cause problem. Because the methods that has the same name will have the same sub initialization function generated by javah.

The methods with different identifier will implement as following.

  MPI.COMM_WORLD.SendFloat(f, *);
  MPI.COMM_WORLD.SendDouble(r, *);
But, there are many MPI communication functions, eg. MPI_Send, MPI_Bsend, MPI_Ssend, MPI_Rsend, etc. If we use this approach, than we are going to have tons of native methods for each functions and datatypes. Which we believe is quite a waste. So we introduce a Java Datatype class which perform the polymorphism between different Java datatypes.


next up previous contents
Next: The polymorphism of Java Up: MPI Java Wrapper Implementation. Previous: Java datatypes   Contents
Bryan Carpenter 2002-07-12