|
4 | 4 | [](https://docs.rs/async-ucx)
|
5 | 5 | [](https://github.com/madsys-dev/async-ucx/actions)
|
6 | 6 |
|
7 |
| -Async Rust UCX bindings. |
| 7 | +Async Rust UCX bindings providing high-performance networking capabilities for distributed systems and HPC applications. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Asynchronous UCP Operations**: Full async/await support for UCX operations |
| 12 | +- **Multiple Communication Models**: Support for RMA, Stream, Tag, and Active Message APIs |
| 13 | +- **High Performance**: Optimized for low-latency, high-throughput communication |
| 14 | +- **Tokio Integration**: Seamless integration with Tokio async runtime |
| 15 | +- **Comprehensive Examples**: Ready-to-use examples for various UCX patterns |
8 | 16 |
|
9 | 17 | ## Optional features
|
10 | 18 |
|
11 |
| -- `event`: Enable UCP wakeup mechanism. |
12 |
| -- `am`: Enable UCP Active Message API. |
| 19 | +- `event`: Enable UCP wakeup mechanism for event-driven applications |
| 20 | +- `am`: Enable UCP Active Message API for flexible message handling |
| 21 | +- `util`: Enable additional utility functions for UCX integration |
| 22 | + |
| 23 | +## Quick Start |
| 24 | + |
| 25 | +Add to your `Cargo.toml`: |
| 26 | + |
| 27 | +```toml |
| 28 | +[dependencies] |
| 29 | +async-ucx = "0.2" |
| 30 | +tokio = { version = "1.0", features = ["rt", "net"] } |
| 31 | +``` |
| 32 | + |
| 33 | +Basic usage example: |
| 34 | + |
| 35 | +```rust |
| 36 | +use async_ucx::ucp::*; |
| 37 | +use std::mem::MaybeUninit; |
| 38 | +use std::net::SocketAddr; |
| 39 | + |
| 40 | +#[tokio::main(flavor = "current_thread")] |
| 41 | +async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 42 | + // Create UCP contexts and workers |
| 43 | + let context1 = Context::new()?; |
| 44 | + let worker1 = context1.create_worker()?; |
| 45 | + let context2 = Context::new()?; |
| 46 | + let worker2 = context2.create_worker()?; |
| 47 | + |
| 48 | + // Start polling for both workers |
| 49 | + tokio::task::spawn_local(worker1.clone().polling()); |
| 50 | + tokio::task::spawn_local(worker2.clone().polling()); |
| 51 | + |
| 52 | + // Create listener on worker1 |
| 53 | + let mut listener = worker1 |
| 54 | + .create_listener("0.0.0.0:0".parse().unwrap())?; |
| 55 | + let listen_port = listener.socket_addr()?.port(); |
| 56 | + |
| 57 | + // Connect worker2 to worker1 |
| 58 | + let mut addr: SocketAddr = "127.0.0.1:0".parse().unwrap(); |
| 59 | + addr.set_port(listen_port); |
| 60 | + |
| 61 | + let (endpoint1, endpoint2) = tokio::join!( |
| 62 | + async { |
| 63 | + let conn1 = listener.next().await; |
| 64 | + worker1.accept(conn1).await.unwrap() |
| 65 | + }, |
| 66 | + async { worker2.connect_socket(addr).await.unwrap() }, |
| 67 | + ); |
| 68 | + |
| 69 | + // Send and receive tag message |
| 70 | + tokio::join!( |
| 71 | + async { |
| 72 | + let msg = b"Hello UCX!"; |
| 73 | + endpoint2.tag_send(1, msg).await.unwrap(); |
| 74 | + println!("Message sent"); |
| 75 | + }, |
| 76 | + async { |
| 77 | + let mut buf = vec![MaybeUninit::<u8>::uninit(); 10]; |
| 78 | + worker1.tag_recv(1, &mut buf).await.unwrap(); |
| 79 | + println!("Message received"); |
| 80 | + } |
| 81 | + ); |
| 82 | + |
| 83 | + Ok(()) |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +## Examples |
| 88 | + |
| 89 | +Check the `examples/` directory for comprehensive examples: |
| 90 | +- `rma.rs`: Remote Memory Access operations |
| 91 | +- `stream.rs`: Stream-based communication |
| 92 | +- `tag.rs`: Tag-based message matching |
| 93 | +- `bench.rs`: Performance benchmarking |
| 94 | +- `bench-multi-thread.rs`: Multi-threaded benchmarking |
13 | 95 |
|
14 | 96 | ## License
|
15 | 97 |
|
|
0 commit comments