Novell's Mono Brings SIMD Support to C#
Parallel programming is not just about multi-threading and multi-core. There's also a lot of power in the SIMD (Single Instruction Multiple Data) extended instruction set available in most modern microprocessors from Intel and AMD.Many applications written in C and C++ take advantage of these instruction sets to work on vectors and matrixes. They are very useful to improve performance in algorithms that need to perform multiple calculations on many data blocks. Many C and C++ compilers optimize loops to take advantage of SIMD instruction sets. Therefore, they are able to perform an automatic parallelization.
Nevertheless, .Net and C# developers working with managed code didn't have a simple way to take advantage of these powerful instruction sets in C# code. This scenario changes with the release of Mono 2.2 and the outstanding work done by Miguel De Icaza. Mono is an open source project, sponsored by Novell, which offers a multiplatform .Net development framework. However, it goes beyond this goal and, as a bonus, among other features, it offers access to hardware accelerated SIMD-based primitives. The key is the namespace Mono.Simd. Using it, you can take advantage of SIMD instruction sets in C#. It is a work in progress. Thus, it only supports up to SSE3 and some SSE4. However, it is a great improvement over the lack of support in C#.
Most operations for updating vectors and matrixes offer an incredible performance improvement and you don't have to leave C#.
It offers support for the following hardware accelerated packed types:
* Mono.Simd.Vector16b: 16 unsigned bytes. * Mono.Simd.Vector16sb: 16 signed bytes * Mono.Simd.Vector2d: 2 doubles * Mono.Simd.Vector2l: 2 signed 64-bit longs * Mono.Simd.Vector2ul: 2 unsigned 64-bit longs * Mono.Simd.Vector4f: 4 floats * Mono.Simd.Vector4i: 4 signed 32-bit ints * Mono.Simd.Vector4ui: 4 unsigned 32-bit ints * Mono.Simd.Vector8s: 8 signed 16-bit shorts * Mono.Simd.Vector8us: 8 unsigned 16-bit shorts
If you are interested in taking advantage of SIMD support offered in Mono, you can take a look at the excellent slide show presented by Miguel De Icaza at PDC 2008 here. You can find a further explanation of SIMD extensions in the article "I've Fallen In Love With the Vectoriser" written by Stephen Blair-Chappel, a few weeks ago. It uses C/C++, but you will be able to use C# with the Mono.Simd namespace.
You can check the kind of SIMD support that your current CPU offers using the freeware CPU-Z. It's an excellent utility to discover the different versions of SIMD available in a CPU.
If you work with vectors, matrixes and C#, you'll love the SIMD support that Mono offers.
For more details, go here