# ankusht369/wiregpu architecture

> Architecture diagram of the GitHub repository ankusht369/wiregpu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ankusht369/wiregpu
- Repository: https://github.com/ankusht369/wiregpu

## Overview

wireGPU is a lightweight CUDA-over-IP bridge. Its intended workflow is a CUDA caller entering exported API hooks, sending a request to a remote server, and having the server receive and inspect it. The sampled code shows an important gap: only cuInit opens a TCP connection, and it sends a text line, while the server expects a binary WgPacket. Other exported CUDA calls currently return placeholder values locally. The protocol defines GPU event IDs and argument encoding, but no GPU execution or response handling is shown. The sampled evidence does not establish a functioning end-to-end workload path.

Main entry points: [`libwgpu/src/lib.rs`](https://github.com/ankusht369/wiregpu/blob/main/libwgpu/src/lib.rs) (CUDA API hooks), [`protocol/src/lib.rs`](https://github.com/ankusht369/wiregpu/blob/main/protocol/src/lib.rs) (Packet receive and decode), [`wiregpu/src/main.rs`](https://github.com/ankusht369/wiregpu/blob/main/wiregpu/src/main.rs) (TCP listener)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client API"]
  node_api_hooks["CUDA API hooks<br/>[lib.rs]"]
  node_cuinit_transport["cuInit TCP call<br/>[lib.rs]"]
  node_local_stubs["Local API stubs<br/>[lib.rs]"]
end

subgraph group_transport["Wire Protocol"]
  node_packet_handling["Packet receive and decode<br/>[lib.rs]"]
  node_gpu_event_format["GPU event and argument format<br/>[lib.rs]"]
end

subgraph group_server["Remote Server"]
  node_tcp_listener["TCP listener<br/>[main.rs]"]
end

node_cuda_caller(("CUDA caller"))

node_cuda_caller -.->|"calls exports"| node_api_hooks
node_api_hooks -->|"routes cuInit"| node_cuinit_transport
node_api_hooks -->|"returns placeholders"| node_local_stubs
node_cuinit_transport -->|"connects TCP"| node_tcp_listener
node_tcp_listener -->|"receives packet"| node_packet_handling
node_packet_handling -->|"decodes header"| node_gpu_event_format

click node_api_hooks "https://github.com/ankusht369/wiregpu/blob/main/libwgpu/src/lib.rs"
click node_cuinit_transport "https://github.com/ankusht369/wiregpu/blob/main/libwgpu/src/lib.rs"
click node_local_stubs "https://github.com/ankusht369/wiregpu/blob/main/libwgpu/src/lib.rs"
click node_tcp_listener "https://github.com/ankusht369/wiregpu/blob/main/wiregpu/src/main.rs"
click node_packet_handling "https://github.com/ankusht369/wiregpu/blob/main/protocol/src/lib.rs"
click node_gpu_event_format "https://github.com/ankusht369/wiregpu/blob/main/protocol/src/lib.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api_hooks,node_cuinit_transport,node_local_stubs toneBlue
class node_packet_handling,node_gpu_event_format toneAmber
class node_tcp_listener toneMint
class node_cuda_caller toneIndigo
```

## Components

### Client API

- [CUDA API hooks](https://github.com/ankusht369/wiregpu/blob/main/libwgpu/src/lib.rs): `libwgpu/src/lib.rs`
- [cuInit TCP call](https://github.com/ankusht369/wiregpu/blob/main/libwgpu/src/lib.rs): `libwgpu/src/lib.rs`
- [Local API stubs](https://github.com/ankusht369/wiregpu/blob/main/libwgpu/src/lib.rs): `libwgpu/src/lib.rs`

### Wire Protocol

- [Packet receive and decode](https://github.com/ankusht369/wiregpu/blob/main/protocol/src/lib.rs): `protocol/src/lib.rs`
- [GPU event and argument format](https://github.com/ankusht369/wiregpu/blob/main/protocol/src/lib.rs): `protocol/src/lib.rs`

### Remote Server

- [TCP listener](https://github.com/ankusht369/wiregpu/blob/main/wiregpu/src/main.rs): `wiregpu/src/main.rs`

### Other components

- **CUDA caller**

## Connections

- CUDA caller → CUDA API hooks: calls exports
- CUDA API hooks → cuInit TCP call: routes cuInit (evidence: `libwgpu/src/lib.rs`)
- CUDA API hooks → Local API stubs: returns placeholders (evidence: `libwgpu/src/lib.rs`)
- cuInit TCP call → TCP listener: connects TCP (evidence: `libwgpu/src/lib.rs`)
- TCP listener → Packet receive and decode: receives packet (evidence: `wiregpu/src/main.rs`)
- Packet receive and decode → GPU event and argument format: decodes header (evidence: `protocol/src/lib.rs`)
