info logo

Documentation (Programming)

Programming: writing programs with P2P-MPI

Documentation concerning the programming model and the API:

Examples: API documentation:
  • Prototypes of available functions in current implementation of P2P-MPI: API documentation
  • The specification P2P-MPI partially covers (see section Links): MPJ specification

Compiling and running programs

  • Compilation is as simple as javac
  • Running a program implies to transfer at least the .class file and optionally input files.
    • A shorthand is provided when you run a class file alone (e.g. myprogram.class):

      p2pmpirun -n 3 myprogram
      In that case, the MPD searches for a myprogram.class in the current directory, and if found will transparently transfer it to requested peers.

    • In a general way, you should use the -l option to specify a file in which are listed (one per line) the files to transfer.

      p2pmpirun -n 3 -l xferfiles myprogram
      where xferfiles is for example:
      Note that
      • files should be specified with their absolute path,
      • the class file must be in the list (whatever its place),
      • http:// URL can be used instead of files.

Using a jar file

The last argument in p2pmpirun (myprogram hereabove) is actually a class name that must contain a main method. In the case of applications embedded in some jar files, this argument is exactly what you would write when running it with "java".

Example: you have the following jar file myjar.jar, containing (i.e, what you can see with jar tvf)

assuming has a main method. Then, you must insert the absolute pathname of myjar.jar in the xferfiles file, and the run command should be :
p2pmpirun -l xferfiles -n 4 query.StartQuery

Data Caching

Since each execution may involve different peers, programs and input data are transfered before each execution. This is a waste of bandwidth when the selected peers from one execution to another remain the same.

Since 0.29.0, you can request remote peers to cache the transfered data. For that, you must add the cache keyword after the filename in the transfer file. For example,

p2pmpirun -n 3 -l xferfiles myprogram
where xferfiles is:
/home/john/examples/myapp.jar       cache 
/home/john/examples/largedata.dat   cache
will request all remote peers to keep the contents of the two files myapp.jar and largedata.dat in their disk cache. Wheter they really cache these data or not depends on the size they grant to the disk cache.
On subsequent executions, if the data is still in the cache of a remote peer, it will not be transfered again. Note, that cache files are identified by their MD5 sums, so that the filenames can change without disturbance.

About P2P-MPI · Download · Documentation (Middleware) · Documentation (Programming) · Mailing list · Links · Contact · FAQ