Microsoft is building two new additions to its .Net framework that should make it much easier for programmers to utilize all the cores of a multicore processor.
The additions should not only ease the complexities of writing a program to run across multiple cores, but also address how the requirements for programs have changed over the past few years, said Danny Shih, the Microsoft program manager for .Net concurrency development.
"Applications are becoming more and more connected," Shih said, speaking at the Microsoft TechEd conference in Atlanta. "It's more common for applications to use Web services, to store data in the cloud, or offload general computation into the cloud."
This waiting for the data can be the source of latency, and badly written applications may just hang in a state of suspension until the data is delivered. Shih described a new approach to tackle this problem, called asynchronous programming.
The way data is handled is another area of change in the requirements of programs. Traditional programming assumes that a predefined data set already exists and the amount of the data is fairly well-known. Newer programs, however, may have to process a wildly varying amount of data.
The two new libraries, Asynch and The Task Parallel Library Dataflow (TPL Dataflow), both available in preview form for .Net and the Visual Studio IDE (integrated developer environment), address these problems.
Parallel programming is not new to .Net. Version 4 of .Net already includes some tools to help create a program that runs on multiple processors, most notably APM (Asynchronous Programming Model) and the Event-based Asynchronous Pattern (EAP).
"These patterns were pretty good when they came out, but as asynchronous programming became more prevalent, we're finding more and more flaws with these patterns," Shih said. One is complexity: Shih showed an example of how four lines of code can balloon to more than 40 by using APM.
In a program with a standard "synchronous" approach, as Shih called it, the program halts executing until the data it requested is delivered. The Async library offers a set of keywords that developers can use to signify a block of code can be executed in parallel with the rest of the program. The "await" keyword, for instance, when placed in front of a block of code such as a method, tells the rest of the program not to wait for the results of that operation.
Shih said that the company is developing Async for inclusion in a future version of .Net. It will first be implemented in Microsoft's own C# and Visual Basic languages, with the hope it will be adopted by other languages as well.
Async is now available in a CTP (Community Technology Preview) that can run on the newest edition of Visual Studio. The download replaces the standard compiler with one that supports the new keywords.
The TPL Dataflow .Net library allows developers to break blocks of codes into what Shih called dataflow blocks. Dataflow blocks can act like agents, an instrumental concept in programming for parallel computing.
Blocks can send messages to one another in predetermined patterns. The input for one block can be the output for another. Unlike traditional programs, they do not execute synchronously. Multiple agents can run at once as long as each agent has its required input.
"This model of doing things is often referred to as data flow parallelism. In essence you are creating a computational network through which data will eventually flow," Shih said.
TPL Dataflow has a number of predefined blocks, or primitives, for handling tasks such as buffering data, broadcasting data, filtering data, joining two different flows of data, or transforming data in some way. Developers can also build their own blocks.
One session attendee, who wished to remain anonymous, noted that the concepts being previewed were "dead-on" in their attack of how to fully harness multicore processors. But he also worried that the presentation glossed over too many implementation details, which may have given attendees a false impression that running these technologies on their own systems may be easier than it actually turns out to be.