Angel \”Java\” Lopez on Blog

December 26, 2008

Fractals using MPI.NET and HPC

Filed under: .NET, C Sharp, High Performance Computing — ajlopez @ 5:50 am

I updated my fractal example to support MPI.NET (Message Passing Interface with .NET) and parametric tasks in Windows HPC Server 2008. The example can be download from my ajcodekatas Google code:

There are two solutions. Fractal.sln contains:

The Fractal.Console project is a console application that takes parameters from the command line. It uses that parameters to generate a serialized sector of the fractal, writing a file:


static void Main(string[] args) { if (args[4].Equals("*")) args[4] = "0"; SectorInfo sectorinfo = new SectorInfo() { RealMinimum = Convert.ToDouble(args[0]), ImgMinimum = Convert.ToDouble(args[1]), Delta = Convert.ToDouble(args[2]), FromX = Convert.ToInt32(args[3]), FromY = Convert.ToInt32(args[4]), Width = Convert.ToInt32(args[5]), Height = Convert.ToInt32(args[6]), MaxIterations = Convert.ToInt32(args[7]), MaxValue = Convert.ToInt32(args[8]) }; Calculator calculator = new Calculator(); Sector sector = calculator.CalculateSector(sectorinfo); SectorSerializer serializer = new SectorSerializer(); string filename = string.Format("{0}-{1}-{2}-{3}-{4}.bin", args[9], sectorinfo.FromX, sectorinfo.FromY, sectorinfo.Width, sectorinfo.Height); serializer.Serialize(sector, filename); }


You can run the project in Debug mode, with parameters:

Launch the new Fractal.GUIFiles project. It’s a winform application, with a new button Read:


Click Read button, and load the generated sector file located in the Fractal.Console bin\debug directory:

This is the result:

Creating the sectors with HPC

The console application can be used in a cluster. Suppose the application is installed in c:\FractalConsole in each node of a cluster. Suppose the name of the head node is HEAD-NODE, and that it has a shared directory named \shared. Then, we can submit a parametric job:

job submit /parametric:0-500:100 c:\FractalConsole\Fractal.Console.exe 0.3 0.3 0.01 0 * 1000 100 2000 4 \\HEAD-NODE\shared\sector

This command submit a parametric job to the cluster. The asterisk in the parameter lists will be replaced by the values 0,100,200,300,400 and 500 (this is the Y coordinate of the top left point of sector). Each execution will produce a file with a serialized sector in the shared directory, that you can read and show using the Fractal.GUIFiles app.


There is a second solution Fractal.MPI:

This code uses MPI (Message Passing Interface). The rank 0 receives a sector, and then, the sector is partitioned between all ranks in execution. Each instance writes a file, representing a subsector of the original sector. 

To compile and run this example I installed the HPC Pack I downloaded from:

HPC Pack 2008 SDK download

and then, I installed MPI.NET Software

(I installed MPI.NET SDK.msi but I expanded too: it has better examples, with VS solutions)

(note: if you want to run under XP Pro, you must download the previous version of the HPC SDK:
Microsoft Compute Cluster Pack SDK

The new SDK has an issue with XP. More info at:

You can run the program using mpiexec utility, that launch many instances of the same program:

mpiexec -n 10 Fractal.Mpi.Exe 0 0 0.01 0 0 500 1000 2000 4 sector

The sectors will be produced by ten instances:

that you can read and show using the Fractal.GUIFiles.

You can run the above command in an HPC cluster, using:

job submit /numnodes=10 mpiexec c:\FractalMpi\Fractal.Mpi.Exe 0 0 0.01 0 0 500 1000 2000 4 \\HEAD-NODE\shared\sector

(assuming you had deployed the application in each node, inside c:\FractalMpi folder)

You have a more complete example at:

Learning Parallel Programming — from shared-memory multi-threading to distributed-memory multi-processing

Angel “Java” Lopez

1 Comment »

  1. [...] Lopez posts an updated example of the fractal HPC Server example code I updated my fractal example to support MPI.NET (Message [...]

    Pingback by Fractals example in MPI on Windows HPC Server | insideHPC — December 29, 2008 @ 1:17 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme Blog at


Get every new post delivered to your Inbox.

Join 56 other followers

%d bloggers like this: