TL;DR
This paper introduces two C# interfaces for using the Message Passing Interface (MPI), a standard for parallel computing. The authors present a low-level interface closely mirroring existing C++ MPI bindings and a higher-level, object-oriented interface designed for C# developers, demonstrating minimal performance overhead.
What Problem Does This Paper Address?
High-performance computing (HPC) traditionally relies on languages like C and Fortran. However, the growing ubiquity of platforms like Microsoft's .NET and the C# language presents an opportunity to bring HPC capabilities to a wider audience. The challenge is to bridge the gap between the .NET ecosystem and the established MPI standard for parallel communication without incurring prohibitive performance penalties. This paper addresses how to effectively integrate MPI with C# and the Common Language Infrastructure (CLI), offering developers familiar with .NET a path to parallel programming.
Methods
The authors propose two distinct layers of C# interfaces for MPI:
- CLI Bindings (Low-Level): This interface aims to be a direct translation of the MPI C bindings. It leverages the CLI's P/Invoke feature to call native MPI functions. This approach prioritizes minimal overhead and direct access to MPI functionality, even if it means adopting less idiomatic C# naming conventions. Explicit buffer pinning is required from the user.
- MPI.NET (High-Level): This interface is built upon the OOMPI C++ library and is designed to be more object-oriented and C#-idiomatic. It provides abstractions like "ports" and "messages" and automatically handles buffer pinning, simplifying the programming model for C# developers. This layer aims for ease of use and a smoother learning curve for those new to MPI.
Both interfaces are implemented on top of an internal set of bindings that closely match the C MPI bindings. The paper also discusses strategies for handling MPI's data types and error handling within the .NET environment.
Datasets
Not discussed in the paper. The paper focuses on performance benchmarking of the MPI bindings themselves, using a ping-pong test as a micro-benchmark.
Key Insights and Ideas
- Dual-Layer Approach: Offering both low-level (performance-focused) and high-level (usability-focused) interfaces caters to different developer needs and expertise levels.
- Automatic Buffer Pinning: The high-level MPI.NET interface's automatic handling of buffer pinning is a significant usability improvement, abstracting away a complex and error-prone aspect of low-level MPI programming.
- Minimal Overhead for C#: The performance results indicate that C# bindings can achieve performance comparable to C, especially when buffer pinning is managed efficiently. The overhead introduced by the .NET runtime and the binding layers is manageable for many HPC scenarios.
- P/Invoke as a Bridge: The P/Invoke mechanism is crucial for enabling direct calls to native MPI libraries from C#, providing a practical way to integrate existing HPC infrastructure.
- Idiomatic C# vs. MPI Conventions: The paper highlights the trade-off between adhering to C# naming conventions and maintaining compatibility with established MPI naming, opting for a pragmatic approach in both interfaces.
Key Results
- Performance: The C# bindings introduce a small performance overhead compared to native C implementations. This overhead is around 50 microseconds minimum and grows with message size, but remains relatively small for larger messages.
- Bandwidth: The communication bandwidth achieved with the C# bindings is comparable to native C, especially for larger message sizes, indicating that the .NET infrastructure does not severely bottleneck MPI communication.
- Buffer Pinning Impact: Performance is significantly reduced when buffer pinning is not handled efficiently (i.e., when it's not automatically managed or is repeatedly done by the user). The MPI.NET interface's automatic pinning demonstrates a substantial performance advantage in such cases.
- Abstraction Penalty: While abstraction layers (like MPI.NET) improve usability, they do introduce a slight performance penalty compared to the more direct P/Invoke approach. However, this penalty is not substantial for many use cases.
Limitations and Future Work
- Parametric Polymorphism: The paper notes that C# and CLI currently lack parametric polymorphism, which is a feature that could further enhance the expressiveness of these bindings.
- MPI.NET Implementation: The high-level MPI.NET bindings are described as being largely hand-written, with much of the code being repeated. Future work could involve more extensive code generation for this layer.
- Testing: While examples are provided and some tests were run, the paper acknowledges that most of the low-level CLI bindings have not yet been thoroughly tested.
- Future Work: The authors suggest that the complete set of MPI bindings to .NET will be made available, implying ongoing development and refinement. The paper also points to ongoing research in areas like parametric polymorphism for the CLI, which could benefit future MPI bindings.
Summary updated