Language Extensions for the Mobile Object Layer

Problem Description

The Mobile Object Layer (MOL) is one subsystem of the Portable Runtime Environment for Mobile Applications (PREMA) that is intended for provided the illusion of a global address space without special hardware. Quoting from here,

MOL supports a global distributed object space and provides correct and efficient protocols for message forwarding and communication between migrating objects. MOL is lean, language-independent, and easy to port and maintain system for developing dynamic load balancing libraries.

However, even though the underlying model is object-oriented, MOL's interface is in C, and there are no "nice" way to use MOL from a language like C++. So see this, let's consider a short example.

First, suppose we have a type Foo:

struct Foo {
	...
	void method(void* pParam); // Some method that does something
	...
};
// This handler must be defined externally to the struct, or else
// be static.
void myHandler(int nSrc, mol_mobile_ptr_t mp, void* pObject,
		void* pData, int nSize, void* pArg) {
	Foo* pFoo = (Foo*)pObject;
	pFoo->method(pData);
}

 

Currently, if we want a Mobile Object of type Foo, we would need to do this:

mol_init(argc, argv); // Params are passed to main()
mol_msg_handler_t handlers[] = {myHandler};
mol_register_msg_handlers(handlers, 1);
Foo* pFoo = new Foo();
mol_mobile_ptr_t mp = mol_create_mobile_ptr(pFoo);

Then, assuming another processor had the mobile pointer mp, it could communicate with the mobile object like this:

void* pData = <something>;
mol_message(mp, myHandler, pData, <data size>,
		MOL_DELAYED_HANDLER, NULL);

This works fine, but it would be nice if there was a way to express this in a way that was much closer to the way in which programmers write sequential, "normal" code. For instance, it would be more natural to declare Mobile objects like this,.

MobileObject<Foo>* pObject = new MobileObject<Foo>;

and use them like this,

pObject->method(pData);

There are several differences between the two. First, we no longer need to call a routine to initialize the Mobile Object layer. Second, we no longer need static handlers or handlers defined externally to the class definition.

There are two basic approaches that one might use for creating a C++ interface for MOL. The first is to use templates and other standard C++ features to create the interface. The second is to incorporate the interface into the C++ language by creating language extensions and to implement a preprocessor that translates the extended syntax into the standard syntax plus calls to the MOL library.

A very useful tool for creating syntactic extensions to C++ is the Open C++ system.

The goals of the project are the following :-

  1. Design and implement a C++-friendly interface for the MOL.
  2. Compare C++ programs written using the C-style interface with your C++ interface

What you need to do

  1. Read some of the papers on MOL. Download and install MOL and run some its test programs.
  2. Design an interface that allows Mobile Objects to be used as first-class C++ objects.
  3. Determine the whether a template-based or transformation-based approach is more suitable for your interface.
  4. Implement your interface.
  5. Rewrite some of the example programs to use your interface so that a comparison can be made between the old interface and your interface.
  6. Really cool idea - show that, using your interface, a sequential C++ program can be easily parallelized by making a small number of changes to its source. Show the performance of the resulting parallel program.

References

  1. MOL home page
  2. Open C++ home page