HPC Development Using F#
< Go Back
The F# programming language is a high-performance, statically-typed functional programming language for the .NET Framework, specifically designed for technical users such as scientists and engineers. F# provides a wide variety of state-of-the-art features that simplify the solving of many important technical problems. These features include algebraic data types, pattern matching, first class functions and type inference, as well as full support for high-performance interactive use from sessions embedded in Microsoft Visual Studio.
This white paper introduces the F# programming language in the context of technical computing, and demonstrates how F# can be used for both shared-memory parallel programming using the Task Parallel Library, and distributed parallel programming using a Windows HPC Server 2008-based cluster and the Message Passing Interface (MPI).
The paper begins with details on how to install and get started with the F# interactive add-in for Microsoft Visual Studio. It then discusses use of the Task Parallel Library (TPL), which provides an intelligent scheduler and data parallelism routines designed to help programmers leverage parallelism on multi-core and multi-CPU computers. The paper also covers MPI, the de-facto standard protocol for handling message passing in distributed compute clusters. Parallel F# programs can be written to run on a Windows HPC Server 2008-based cluster using MS-MPI or MPI.NET.
In addition to basic message passing, MPI also provides some higher-level aggregate operations called scatter, gather, and reduce that allow computations to be farmed out across a cluster. These are described in detail.
Although the F# programming language offers many improvements over older languages (such as unmanaged C, C++, and Fortran), the need to interoperate with native code can still arise. The two most important uses for native code interoperability are performance and legacy. Considering such scenarios, this white paper describes how native code can be invoked from F# programs, including essential design advice for building robust interfaces for this often error-prone task.
Finally, the paper discusses some potential pitfalls that can be either avoided during development or checked for during optimization that can make F# programs run more quickly and efficiently.




