Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Thursday, 25 August 2011

I am looking for a job

News - I greatly appreciate your comments below and surprisingly plenty of information and valuable advices came to me during the last one year. Thanks to all your concern, I finally accepted a thermal expert position in ABB USA (www.abb.com) and am sitting in North Carolina.

I particularly thank the three companies in England, France and America that I personally consulted for and their encouraging recommendations. I cherish the experiences I have obtained from the part-time working with them.

Within my PhD study, I have published eight research papers. Four of them are in leading journals and their links are as follows:

I am graduating in September 2011 with a PhD degree from School of Electrical and Electronic Engineering, University of Manchester. I am looking for a numerical modelling job.

I spent the past more than three years on the CFD simulations which are coupling between electric, thermal and fluid dynamic fields, from which I have accumulated rich experiences on modelling packages such as SALOME, Code_Saturne, Elmer, ParaView and COMSOL etc. I share experiences in this blog, which has also gained worldwide popularity.

I have been programming in C/C++, C#, VB.NET and Matlab since 2002. I also have experiences in Python (the script widely used for automation of modelling and the software such as SALOME and ParaView etc) and Fortran (the user routine definition for Code_Saturne) etc. Meanwhile, probably as a bonus, I am a fan of open-source software, Linux and Mac OS X. I even wrote device drivers for Linux and ported the MySQL client tool running on desktops onto embedded Linux platforms.

I bear high interests in numerical modelling and would like to pursue a career in this field. If you have relevant opportunities, please drop me an email (salad00 at gmail dot com). I really appreciate your help very much.

Sunday, 11 July 2010

A brief test on the efficiency of a .NET 4.0 parallel code example - Part II

With respect to the article, "A Brief Test on the Efficiency of a .NET 4.0 Parallel Code Example", Daniel Grunwald proposed additional interesting pieces of code to compare. First of all, the LINQ and PLINQ methods are present as

// LINQ (running on single core)
final_sum = data.Sum(d => d * d);
// PLINQ (parallelised)
final_sum = data.AsParallel().Sum(d => d * d);

They are the most concise code to implement the computation. However, when the individual calculations are very cheap, for example, this simple multiplication d => d * d, the overhead of delegates and lambda expressions could be largely noticable.

When parallelising an algorithm, it is essential to avoid false sharing. In the previous article I split the raw data array into a group of pieces and compute the sub-summation for each piece. Actually I manually determine the number of the pieces - I did a sensitivity study and found that 16 k pieces are sufficient for a data size less than 32 M; larger data size might need more pieces.

Daniel reminded that, by using an advanced overload of Parallel.For, the work can be distributed into pieces by .NET. The code is as

// localSum
final_sum = 0;
Parallel.For(0, DATA_SIZE,
             () => 0, // initialization for each thread
             (i, s, localSum) => localSum + data[i] * data[i], // loop body
             localSum => Interlocked.Add(ref final_sum, localSum) // final action for each thread
            );

However this method didn't improve the efficiency as expected, at least not efficient as my manual method grouping the array into 16 k pieces, because of, we believe, the dramatic overhead caused by delegates relatively to the cheap multiply-add operation.

Then the working units can be combined to be slightly heavier to compensate the delegate overhead, for example, processing 1024 elements in each invocation.

// localSum & groups
final_sum = 0;
Parallel.For(0, (int)(DATA_SIZE / 1024),
             () => 0,
             (i, s, localSum) =>
             {
                 int end = (i + 1) * 1024;
                 for (int j = i * 1024; j < end; j++)
                 {
                     localSum += data[j] * data[j];
                 }
                 return localSum;
             },
             localSum => Interlocked.Add(ref final_sum, localSum)
            );

Finally, this piece of code becomes the most efficient one we have ever found.

In order to generally look at the comparison between the methods, I, once again, list a table as


and the corresponding curves


Note that, in the comparison, I neglected the methods which have already been proved as inefficient in the previous article for clarity.

Any comments are welcome.

Friday, 2 July 2010

A brief test on the efficiency of a .NET 4.0 parallel code example

As a piece of accompanying work of the article, "A short test on the code efficiency of CUDA and thrust", I published a new parallel code example in C# 4.0 on CodeProject. The new example tests the new parallel programming support provided from .NET 4.0, and the corresponding article can be found as

A Brief Test on the Efficiency of a .NET 4.0 Parallel Code Example

Briefly the test results could be depicted by


and pictorially


however the original text is suggested to read for more details if you are interested.

I hope the work helps and your comments are welcome.