Live360! and BuildStuff Talks: SIMD, Visual Studio Diagnostic Hub, and Swift

December 9, 2015


I’m writing this on the plane back home from a week-long trip to Orlando, Vilnius, and Kiev, where I had the chance to speak at Live360! and BuildStuff; I’ve just counted and it’s my tenth flight in three weeks, which is quite insane. But this is my second-to-last trip for 2015 — the last one is going to be in December to DotNext Moscow.


[slides, demos]

In this talk, we discussed vector registers and instructions that you could use from other languages like FORTRAN and C++ for more than 15 years. Starting from the MMX instruction set extensions in the 1997 Pentium and going all the way to AVX-512 in Intel’s Knight’s Landing coprocessor released in 2015, the idea of having a single instruction operate on multiple elements could speed many kinds of algorithms using only a single processor core. For .NET developers, access to SIMD instructions has been restricted by the fact the JIT compiler wouldn’t emit them; but that changed with .NET 4.6 and RyuJIT (currently only for x64).

Vector<float> vdp = Vector<float>.Zero;
for (int i = 0; i < a.Length; i += Vector<float>.Count)
  Vector<float> va = new Vector<float>(a, i);
  Vector<float> vb = new Vector<float>(b, i);
  vdp += va * vb;
float dp = 0.0f;
for (int i = 0; i < Vector<float>.Count; ++i)
  dp += vdp[i];

Among the demos you will find a benchmark of vectorizing the dot product operation on vectors of floating point values. The really cool thing, I think, is that the vectorized .NET version can be just as fast as the C++ one. To run the C++ benchmark, you will need a Haswell processor or later, that has the FMA (fused multiply-add, VFMA231PS) instruction.

Visual Studio Diagnostic Hub

[slides, demos]

The Diagnostic Hub in Visual Studio 2015 has undergone a lot of improvements, including memory leak analysis support for C++, IntelliTrace enhancements, GPU usage and network utilization tools, and a bunch of other features. In Update 1, you can use the CPU usage tool while debugging, which lowers the barrier of entry for profiling your code and understanding what your app is doing between breakpoints or steps. I expect this feature to be very useful and help shorten the time between coding a performance issue and discovering it.


[slides, demos]

Last but not least, my talk on Swift was fun as usual. I highlighted some of the cool language features and contrasted them with Objective-C, explained how Swift classes, structs and enums work, and wrote some code in an iOS app that illustrates most of the language features we talked about. Obviously a one-hour talk isn’t enough for a full exposition to Swift, but hopefully it served as an introduction. Apple seems to be quite serious about turning Swift into a general-purpose language targeting more than just iOS and OS X developers, and indeed I had a lot of people in the audience who aren’t building for iOS and were still interested in a cool new language. (And as a bonus, just a couple of weeks after the talk Apple finally open-sourced the Swift compiler and runtimeย and provided a functioning port for Linux, positioning it as a first-class systems programming language for OS X and Linux.)

In addition to blogging, I’m also using Twitter for quick updates and links. You can follow me: @goldshtn

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



  1. EoinFebruary 1, 2016 ื‘ 12:40 PM

    Thanks, Sasha.

    I was looking through your slides on SIMD, and wanted to ask: Is there any reason you use e.g. Vector.LessThan and Vector.ConditionalSelect to get the element-wise minimum? Wouldn’t Vector.Min give you the same result? It’s also a single line of C# and and makes use of pminsw (the equivalent is, obviously, possible for max too).

    1. Sasha Goldshtein
      Sasha GoldshteinFebruary 14, 2016 ื‘ 5:26 PM

      It might have been added after I wrote this demo ๐Ÿ™‚
      In any case it provides a good example of “reimagining” an algorithm to use SIMD concepts.