Just sharing some of my inconsequential lunch conversations with you... RSS  

Thursday, September 20, 2007

Parallelizing is here to stay

André Cardoso and infoq has just about this great MSDN article about PLINQ.

André also makes reference to another article from last MSDN: TPL (Task Parallel Library). It's purpose is to write managed code that can automatically use multiple processors. Using the library, you can conveniently express potential parallelism in existing sequential code, where the exposed parallel tasks will be run concurrently on all available processors. Usually this results in significant speedups. Here's a sample:


void ParMatrixMult(int size, double[,] m1, double[,] m2, double[,] result)

{

Parallel.For( 0, size, delegate(int i) {

for (int j = 0; j <>

result[i, j] = 0;

for (int k = 0; k <>

result[i, j] += m1[i, k] * m2[k, j];

}

}

});

}

The performance benchmarking are just great, can't wait to use it (hopefully I'l have a change on my next project, where I'll have a change to do some Linear Programming groovy application).

I'll have to end with a question: wouldn't it make sense if parallel support was added to the languages them self, not to the class library?

No comments:

Development Catharsis :: Copyright 2006 Mário Romano