Parallel Programming in F# (IV.): Financial dashboard example
In the fourth part of the Parallel Programming in F# series, we'll take a look at the Adatum Financial Dashboard sample. The sample is a part of Parallel Programming with Microsoft .NET, which is a guide that introduces common parallel programming patterns on .NET 4.0. The C# version of the sample is in details discussed in the guide, but the F# translation contains several additional interesting aspects that I'll introduce in this article.
The sample simulates a financial modelling application that performs processing of market
data in several steps that can be partly executed in parallel. In this article we'll compare two
implementations. The first one (similar to the C# version) uses the
from .NET 4.0 and chains steps using the
ContinueWith method. The second version is
F# specific and it implements step as a sequential computation wrapped in asynchronous
workflows. Partial results are reported to the user interface using events.
Parallel Programming in F# (III.): Aggregating data
In this part of the Parallel Programming in F# series, we'll explore examples of parallel aggregation
from Chapter 4 of Parallel
Programming with Microsoft .NET, which is a guide that introduces common parallel programming patterns
on .NET 4.0. The C# version of the sample is in details discussed in the guide. In this article,
we'll look at the F# translation and in particular at several functions from the
module. Some of the functionality is currently available only in the "PSeq.fs" distributed with the
samples, but will eventually appear in F# PowerPack as well.
Aggregation of data in parallel is an interesting problem. As we've seen in the previous article,
PLINQ and tasks make it easy to parallelize independent blocks of code that don't share any state.
Unfortunatelly, not all programs are like that. In particular, we often need to aggregate all
elements of a sequence - when writing sequential code in F#, you would use the
function. In this article, we'll look at functions that implement fold parallel.
Parallel Programming in F# (II.): Using PLINQ and Tasks
In this part of the Parallel Programming in F# series, we'll look at some basic examples of parallel programming in F# that are available in Parallel Programming with Microsoft .NET. This is a guide that introduces common parallel programming patterns on .NET 4.0. The guide discusses the samples in C#, but it also contains an F# translation of the source code. Since the languages are different, the F# version deserves a brief explanation.
In this article, we'll discuss some of the F# examples and we'll look at a couple of aspects that
are specific for F#. In particular, we'll look at working with Parallel LINQ (both directly and using
PSeq module from F# PowerPack) and working with tasks. We'll also look at an interesting
example (using closures) where C# version doesn't behave as expected, but a literal translation in F# corrects the
Parallel Programming in F# (I.): Introducing the samples
Parallel Programming with Microsoft .NET is a guide written by the patterns & practices group at Microsoft. It introduces .NET programmers to patterns for including parallelism in their applications (using support for parallel programming in .NET 4.0). It introduces techniques such as parallel loops, parallel tasks, data aggregation and so on. The book includes numerous samples in C# and Visual Basic that can be easily copied and adapted to match your needs.
As part of a contracting work for the F# team, I developed an F# version of the samples, which is
now available on the book web site.
You can get it by downloading F# code samples (ZIP) from the 1.0 release, or you can download the latest version of the source code directly. The F# version of the
code is mostly a direct translation of the C# versions, but there are a few interesting places that
are worth discussing. In particular, some of the samples use the
PSeq module from F#
PowerPack and I also added a version of one example that uses F# asynchronous workflows.
In this article series, I'll look at several interesting examples from the F# version of the source code. We'll look how to use PLINQ and Tasks (which are available in .NET 4.0) from F# (Part II.) including some advanced topics such as the Map-Reduce algorithm (Part III.). We'll also look at a larger example built using tasks and an alternative implementation using asynchronous workflows (Part IV.) Here are links to the individual articles:
- Parallel Programming in F# (I.): Introducing the samples
- Parallel Programming in F# (II.): Using PLINQ and Tasks
- Parallel Programming in F# (III.): Aggregating data
- Parallel Programming in F# (IV.): Financial dashboard example