C# is a wonderful programming language, evolving quickly. Microsoft has pushed C# into parallel programming by adding the Task Parallel Library, simplifying development of efficient parallel algorithms. In this blog I’ll describe the parallel library that I’ve developed, with some excellent preliminary results.
Preliminary Performance Results
Parallel Sorting is running more than 2X faster than built-in C# Array Sort.
Parallel Merge is running more than 3X faster than the sequential merge.
These results were obtained on my quad-core laptop.
Parallel Sorting and Parallel Merge algorithms are generic, able to sort not just integers, but any data type that can be compared. Both algorithms support Arrays and Lists. For instance, both can process Arrays of floating-point numbers, or Arrays of strings, or custom classes which contain a key to sort or merge by.
C# Task Parallel Library (TPL) facility is similar to an earlier library developed by Intel for C++, Threading Building Blocks (TBB). Microsoft later adopted TBB and integrated it into VisualStudio as Parallel Patter Library. All of these libraries enable programmers to use tasks instead of threads, which simplifies thinking and programing parallelism.