libfabric (Open Fabrics Interfaces)

repository·main·Indexed 21 days ago

https://github.com/ofiwg/libfabric

A high-performance networking framework for parallel and distributed applications and middleware. It provides a standardized API to access diverse networking hardware and protocols through a provider-based architecture. The project includes the ofi-libfabric-sys Rust crate for low-level FFI bindings, a suite of examples for RDM, MSG, and RMA messaging, and fabtests for comprehensive performance and functional testing across various providers.

Tokens
229.1K
Snippets
372
Records
897
Agent score
73%

What's inside libfabric

  1. Overview of libfabric architecture and purpose

    main
    libfabric is a communication library framework designed for high-performance computing (HPC) applications. It provides communication interfaces that maintain a tight semantic map between applications and underlying network services. The library is co-designed with network hardware providers and application developers to meet the performance and scalability requirements of HPC users.
  2. Overview of Fabtests

    main

    Fabtests is a suite of example programs for libfabric providers designed to demonstrate various high-performance fabric features. While most tests report performance metrics, their primary purpose is to verify functionality and familiarize users with the libfabric API.

    Most tests operate in a client-server model, meaning they require both a server process and a client process to run. Note that not all providers support every test in the suite.

  3. Overview of EFA RDM Communication Protocol version 4

    main

    The Elastic Fabric Adapter (EFA) Reliable Datagram (RDM) communication protocol version 4 (protocol v4) is the protocol used by the libfabric EFA provider's RDM endpoint (starting from libfabric 1.10.0).

    This protocol provides a platform-independent definition for RDM communication, separating the protocol specification from specific implementations. It is structured into several functional areas:

    • Basics: Fundamental concepts including packet structures, headers, and raw addresses.
    • Handshake Subprotocol: Mechanisms for establishing connections, ensuring backward compatibility, and exchanging raw addresses.
    • Baseline Features: Core capabilities for both two-sided (eager, medium, and long-cts message transfers) and one-sided (emulated writes, reads, and atomics) communications.
    • Extra Features/Requests: Advanced capabilities such as RDMA-Read/Write based transfers, delivery completion, connection IDs (connid), and error handling (peer-abort).

    Developers implementing or debugging EFA-based communication should refer to this protocol definition to ensure compatibility and correct behavior.

  4. Overview of the fi_tcp provider

    main
    The tcp provider runs over TCP (SOCK_STREAM) sockets and is compatible with all operating systems supported by libfabric. It implements a custom protocol over TCP/IP to support libfabric communication APIs. It can leverage platform-specific features like io_uring and zero-copy transfers to improve performance.
  5. What is the CXI provider?

    main

    The CXI provider enables libfabric on Cray's Slingshot network (comprised of Rosetta switches and Cassini NICs). While Slingshot is Ethernet-compliant, the CXI provider uses proprietary extensions to support high-performance computing (HPC) applications.

    Key Capabilities:

    • Reliable, connection-less endpoint semantics.
    • Two-sided messaging with message matching offloaded by the Cassini NIC.
    • One-sided RMA (Remote Memory Access) and AMO (Atomic Memory Operations) interfaces.
    • Light-weight counting events.
    • Triggered operations (via the deferred work API).
    • Fabric-accelerated small reductions.

    For exhaustive technical details, refer to the fi_cxi(7) man page.

  6. Overview of the SHM Fabric Provider

    main
    The SHM (Shared Memory) provider is a complete provider for Linux systems that support shared memory and process_vm_readv/process_vm_writev calls. It is designed for high-performance communication between processes residing on the same physical system.
  7. Overview of the EFA Libfabric Provider

    main

    The EFA Libfabric provider enables support for the Amazon Elastic Fabric Adapter (EFA), an OS bypass network interface available on Amazon EC2 instances. It is designed for High-Performance Computing (HPC) and Machine Learning applications to achieve lower latency and higher throughput compared to TCP.

    Key features provided by the software layer include:

    • Tag matching
    • Reordering
    • Software emulation for hardware features not natively supported by the EFA device

    The provider supports both reliable and unreliable datagram send and receive semantics.

  8. Overview of EFA RDM Communication Protocol v4

    main

    The EFA RDM (Remote Direct Memory Access) communication protocol allows two libfabric endpoints to communicate using an EFA device. While EFA hardware natively supports MTU-sized send/receive, 1GB RDMA reads, and 1GB RDMA writes, Protocol v4 extends these capabilities via software subprotocols to support:

    • Large Transfers: Send, read, and write operations up to $2^{64}-1$ bytes.
    • Atomics: Atomic operations up to the MTU size.
    • Advanced Requirements: Mechanisms for ordered send/receive (FI_ORDER_SAS) and Delivery Complete (DC) notifications, which are not natively guaranteed by the EFA hardware.
  9. What is the LINKx (LNX) provider?

    main
    The LNX provider is designed to link two or more providers, allowing applications to seamlessly use multiple providers or NICs. It utilizes the libfabric peer infrastructure and can link any libfabric provider that supports the FI_PEER capability.
  10. Understanding Memory Footprint and Scalability in libfabric

    main

    In High-Performance Computing (HPC) applications communicating with thousands of peers, memory footprint is a critical factor for scalability. Excessive memory consumption can limit the number of parallel peers an application can support.

    Key trade-offs include:

    • Buffering vs. Performance: Larger internal network buffers generally increase bandwidth and performance but increase the memory footprint.
    • Addressing vs. Scalability: The memory required to address peers typically has a linear relationship with the total number of peers. For example, using IPv4 struct sockaddr_in requires 8 bytes per peer; communicating with a million peers consumes ~8 MB just for the address list.
    • Eliminating Buffering: Reducing network-level buffering helps both performance and scalability by lowering the memory footprint required to support the application.
  11. Understand Memory Registration (MR) and Modes

    main

    Registered memory regions (MRs) associate memory buffers with permissions for fabric resources. A buffer must be registered with a resource domain before it can be used for remote RMA, atomic data transfers, or certain collective operations.

    Memory registration behavior is controlled by mr_mode bits. When calling fi_getinfo, an application should check these bits to understand the provider's requirements. If a provider supports a specific mode, it will leave the bit set; otherwise, it may clear it. Applications should be prepared to handle the mode even if the provider clears the bit (indicating the requirement is not strictly necessary for that specific provider).

  12. Emulated long-read write subprotocol

    main

    The emulated long-read write subprotocol uses RDMA read to emulate a write operation. It is initiated with a LONGREAD_RTW packet. Unlike the long-read message subprotocol, the receiver side does not receive a completion event by default.

    Key header fields include:

    • rma_iov_count and rma_iov: Information about the target buffer on the responder side (provided by the application via libfabric's write API).
    • read_iov_count and read_iov: Information about the source buffer on the requester side (constructed by the write requester).
    ### LONGREAD_RTW Mandatory Header
    | Name | Length (bytes) | Type | C language type | Notes |
    |---|---|---|---|---|
    | `type` | 1 | integer | `uint8_t` | part of base header |
    | `version` | 1 | integer | `uint8_t` | part of base header |
    | `flags` | 2 | integer | `uint16_t` | part of base header |
    | `rma_iov_count` | 4 | integer | `uint32_t` | number of RMA iov on the responder |
    | `msg_length` | 8 | integer | `uint64_t` | total length of the message |
    | `send_id` | 4 | integer | `uint32_t` | ID of the receive operation |
    | `read_iov_count` | 4 | integer | `uint32_t` | number of iov on requester (to be read by responder) |
    | `rma_iov` | `rma_iov_count` * 24 | array | `efa_rma_iov[]` | write iov information |