Members - Reputation: 390
Posted 18 December 2012 - 10:27 AM
In recent news, some folks at Microsoft Research published a paper about an auto-threading compiler. Yes, it should be able to analyze a single-threaded code and determine what parts are safe to run in parallel.
Research on this field is happening for some time now, but this is the most recent (promising) news I've seen so far.
Moderators - Reputation: 1621
Posted 18 December 2012 - 08:41 PM
You can't add it in afterwards and expect it to work well.
So this compiler would make it easier to write new threaded libraries but it won't do much for existing code.
Moderators - Reputation: 39112
Posted 19 December 2012 - 09:04 AM
They needed to add a few keywords (readable, writable, immutable, isolated, consume). They have several logistical restrictions that make it impossible to add to C++ as an extension, but keep it possible to add to C#.
I find section 6.6 of the paper the most interesting section. Just like adding const correctness to a program helps you discover various types of bugs, when the researchers started specifying a readable/writable intent they similarly discovered software defects.
It still has the issues that several other keywords (restrict, const, etc) face: It is up to the programmer to add it; the program runs just fine without it; and if they aren't added the compiler will silently be unable to take the optimization.
They've still got some serious bugs to work out, but I can imagine this getting added to C# around 2016 or so.
Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.
Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.