The mpC Program Examples

There does not exist yet a complete technology of the writing of high-quality efficient and efficiently-portable mpC applications to solve problems from a diverse areas. We are doing only first steps in the direction. Here, we are going to present examples of mpC applications that demonstrate diverse techniques for solving some typical problems with mpC.

The first example demonstrates an application solving a so-called irregular problem. An irregular problem is characterized by some inherent coarse-grained or large-grained structure implying quite deterministic decomposition of the whole program into a set of programs running in parallel and interacting via message passing. As rule, there are essential differences in volumes of computations and communications to perform by different programs. So, in mpC one can define a network object, to execute the set of programs, and specify performances of its virtual processors and lengths of its links in accordance with the different volumes of computations and communications, and mpC programming environment will map the virtual processors onto underlying hardware in such a way to ensure an efficient execution of the application.

The second example demonstrates an application solving a so-called regular problem. Unlike an irregular problem, for a regular problem a decomposition of the whole program into a large set of small equivalent programs, running in parallel and interacting via message passing, is the most natural one. The main idea of efficient solving a regular problem is to reduce it to an irregular problem the structure of which is determined by the topology of underlying hardware rather than the topology of the problem. So, the whole program is decomposed into a set of programs each made of a number of the small equivalent programs stuck together and running on a separate processor of the underlying hardware. To do it in mpC, one can detect with a special library function the topology of the underlying hardware, define a network object having the same topology and distribute computations and communications in accordance with the topology to ensure efficient execution of the program.


The mpC application simulating the evolution of a system of stars in a galaxy. This is an example of irregular application. It requires X-window to run. Download the mpC source file.

Matrix multiplication.This is an example of regular application. Download the mpC source file.


NEW   Try mpC right now through WWW by means of mpC Remote Development Environment.

Back to The mpC project