16.05.2010 at
10:05 pm · Saved under
.NET Help
Dear Parallel Computing Enthusiasts,
This week, Microsoft is rolling out a platform update to all blogs on the http://blogs.msdn.com site, including this one. Comments on this blog will be disabled at approximately 9pm PST tonight and will be off until mid-day on the 24th. We also do not expect to publish any new blog posts during this time. If you want to read a bit about some of the platform improvements that will be coming, Sean Jenkin’s blog is a good resource.
Thanks for your patience during this update. See you in a week!
Tagged: default-aspx • programming • wikipedia
04.02.2010 at
1:59 pm · Saved under
.NET Help
Several months ago, Microsoft announced for academic customers the availability of DryadLINQ. DryadLINQ is a LINQ provider developed by Microsoft Research that enables .NET developers to use the LINQ programming model for writing distributed queries and computations against a cluster of computers using Windows HPC Server. DryadLINQ enables developers to harness and tame the distributed data storage and computational resources of a cluster, all with a familiar LINQ-based syntax, just as PLINQ enables developers to more easily take advantage of multi-core and manycore. (In fact, DryadLINQ is capable of using PLINQ internally to harness multiple cores available on each cluster node.)
It’s a pleasure to announce that, as of today, MSR has also released DryadLINQ under an additional license agreement, one that allows for non academic use. The academic and non academic releases are largely identical: key differences are in the licenses themselves, and that the academic release supplies source code for the programming model layer whereas the commercial release is a binary-only distribution.
In order to download the new release, you will need to register on the Dryad connect site. You will also need a Windows HPC Server cluster (three nodes will suffice), for which you can download a free evaluation version at http://www.microsoft.com/hpc/en/us/try-it.aspx.
We are looking forward to receiving your feedback about this release!
Tagged: feedback-requested • hpc server • incubation • plinq • programming
29.01.2010 at
8:39 pm · Saved under
.NET Help
Are you using the CCR (Microsoft Robotics’ “Concurrency & Coordination Runtime”) today in production applications or libraries, and in particular for non-robotics purposes? If so, we’d love to hear about your experiences, and any and all information you’re willing to share would be very welcome.
What do you like about it and the programming model it employs? What don’t you like about it? What features are crucial to you, and what features do you never use? How are you architecting your applications with it? Any key code samples that are representative of your application you’d like to share, or even better, a standalone implementation that highlights how you use it? If you experiemented with it but ended up not using it, why? Etc. If you’re interested and willing to share, please send me an email at stoub at microsoft dot com.
We’re excited to hear from you!
Thanks,
Stephen
Tagged: default-aspx • media • programming • silverlight • tools
03.12.2009 at
7:10 pm · Saved under
.NET Help
Check out the updated Parallel Computing Developer Center on MSDN. Both the look and the content have been revised significantly…
Enjoy!

Tagged: default-aspx • parallel • programming • silverlight • tools • wikipedia
02.11.2009 at
8:55 pm · Saved under
.NET Help
Are you attending PDC09? Want to meet with members of the Parallel Computing Platform team? See http://blogs.msdn.com/visualizeparallel/archive/2009/11/02/the-parallel-computing-platform-team-pcd-09.aspx for more details.
Tagged: default-aspx • media • programming • search • silverlight • talks
20.07.2009 at
6:32 pm · Saved under
.NET Help
Update: The survey is now closed. Thanks to all that participated!
We’ve heard our customers’ frustrations with asynchronous programming and their call for improved support. We are hoping to better understand why and how you and your customers use asynchronous programming in .NET and how the support we provide for it can be improved in the future.
We invite you to complete a short survey on the Asynchronous Programming Model (APM) as well as on a theoretical language construct called “Asynchronous Methods.” Completing this survey shouldn’t take more than 5-10 minutes of your time, and doing so will help us to better understand where the APM is lacking, how we can make asynchronous programming better and, ultimately, how we can increase your productivity and the scalability and reliability of your code. We encourage you to forward this message on to others who may also have had experience with asynchronous programming.
http://deploy.ztelligence.com/start/index.jsp?PIN=15TMLTB8M3X9C
Thank you!
Josh Phillips
![Asynchronous programming in .NET survey Asynchronous programming in .NET survey]()
Tagged: asynchronous • cancellation • contests • media • message-passing • microsoft • news • notification • parallel-extensions • programming • survey • tools
09.07.2009 at
9:37 pm · Saved under
.NET Help
Parallel Extensions offers a large variety of APIs supporting parallelism.
During this blog the discussion will be focused on the methodology for making a choice between two of the new Parallel Extensions concepts: parallelism achieved by using Parallel.Invoke() and parallelism achieved through the use of Tasks.
Suppose that you wanted the two actions below to be executed in parallel:
Action hello = () => { Console.Write(”Hello”); };
Action world = () => { Console.Write(”World”); };
Should you use Tasks or Parallel.Invoke() to achieve the desired parallelism?
Parallelism through Parallel.Invoke()
The code to execute our actions in parallel with Parallel.Invoke() looks like this:
Parallel.Invoke(hello, world);
This is simple and easy, and we get the desired result: either “HelloWorld” or “WorldHello” output to the console, depending on the order in which the parallel actions were scheduled.
Parallelism through Explicit Task Management
For convenience, creating and starting a Task can be done with a single method:
Task.Factory.StartNew(hello);
Task.Factory.StartNew(world);
If we run this code sequence, something surprising happens – nothing is displayed! The reason is that the Tasks are scheduled via ThreadPool threads, which are background threads. The main process will execute while the Tasks are still running. At the same time, if one of the actions throws an exception, the exception will not be thrown until the Finalizer throws it. We can solve both of these problems by performing an explicit Wait() on the Tasks:
Task taskHello = Task.Factory.StartNew(hello);
Task taskWorld = Task.Factory.StartNew(world);
Task.WaitAll(taskHello, taskWorld);
Running this sample now, the result is the same as in the Parallel.Invoke case: either “HelloWorld” or “WorldHello” is printed to the console.
An Example: Tree Traversal
Let’s see now how we can implement a binary tree traversal using Parallel.Invoke():
ConcurrentBag<int> _dataStorage = new ConcurrentBag<int>();
void TreeTraversal(Tree<int> node)
{
if (node == null)
return;
var actions = new List<Action>();
if(node._left != null)
actions.Add(() => TreeTraversal(node._left));
if(node._right != null)
actions.Add(() => TreeTraversal(node._right));
Parallel.Invoke(actions.ToArray());
_dataStorage.Add(node._data);
}
And let’s look at a similar version using explicit Task management:
ConcurrentBag<int> _dataStorage = new ConcurrentBag<int>();
void TreeTraversal(Tree<int> node)
{
if (node == null)
return;
var tasks = new List<Task>();
if(node._left != null)
tasks.Add(Task.Factory.StartNew(
() => TreeTraversal(node._left));
if(node._right != null)
tasks.Add(Task.Factory.StartNew(
() => TreeTraversal(node._right));
_dataStorage.Add(node._data);
Task.WaitAll(tasks.ToArray());
}
Note that the syntax is more concise in the Parallel.Invoke() version, and the Parallel.Invoke() call takes care of waiting and exception handling. The flip side of that is that the explicit task management version allows for more control. Note that the “_dataStorage.Add(node._data);” operation can be performed in parallel with the processing of the left and right branches when explicit task management is used, while the same operation must wait for left/right processing to complete in the Parallel.Invoke() version.
Conclusions
Parallel.Invoke() is a higher-level mechanism for providing parallelism, and allows for more concise code that one would typically get from using explicit task management.
However, if the coder is interested in more control, perhaps for more complicated scenarios, then explicit task management is probably the way to go.
Tagged: actions • cristina-manu • management • media • programming • silverlight • task- • wikipedia
24.06.2009 at
3:26 pm · Saved under
.NET Help
In a previous post, it was demonstrated how for loops with very small loop bodies could be parallelized by creating an iterator over ranges, and then using Parallel.ForEach over those ranges. A similar technique can be used to write parallel loops over iteration spaces of non-integers. For example, let’s say I wanted to parallelize the following loop, where the iteration range is based on doubles:
for(double d = 0.0; d < 1.0; d += .001)
{
Process(d);
}
Parallel.For only contains overloads for where the iteration variable is an Int32 or an Int64. To accomodate doubles, one approach would be to translate the range into an integer-based range in order to use Parallel.For, and then within the body of the loop translate it into a double. As an example, the previously shown loop could be rewritten as:
Parallel.For(0, 1000, i =>
{
double d = i / 1000.0;
Process(d);
});
Due to floating point arithmetic, this may not be exactly the same, but it may be close enough. Another approach is to implement an iterator like the following:
private static IEnumerable<double> Iterate(
double fromInclusive, double toExclusive, double step)
{
for(double d = fromInclusive; d < toExclusive; d += step) yield return d;
}
With that Iterate method, now I can parallelize the sequential loop using Parallel.ForEach:
Parallel.ForEach(Iterate(0.0, 1.0, .001), d =>
{
Process(d);
});
This same technique can be applied to a wide variety of scenarios. Keep in mind, however, that the IEnumerator<T> interface isn’t thread-safe, which means that Parallel.ForEach needs to take locks when accessing the data source. While ForEach internally uses some smarts to try to ammortize the cost of such locks over the processing, this is still overhead that needs to be overcome by more work in the body of the ForEach in order for good speedups to be achieved.
Parallel.ForEach has optimizations used when working on indexible data sources, such as lists and arrays, and in those cases the need for locking is decreased. Thus, performance may actually be improved in some cases by transforming the iteration space into a list or an array, which can be done using LINQ, even though there is both time and memory cost associated with creating an array from an enumerable. For example:
Parallel.ForEach(Iterate(0.0, 1.0, .001).ToArray(), d =>
{
Process(d);
});
Happy coding.
Tagged: -net-4-0 • code-samples • contests • iteration • jobs • media • microsoft • news • parallel • programming • task-parallel-library • tools • wikipedia