GPU-Direct Field Guide

CS 4251/6250 · study guide for the team

Can a GPU send its own network packets?

Everything you need to explain our project and survive any question about it. Read it top to bottom once, then use the Q&A section to quiz yourself.

The 60-second version

We made an NVIDIA GPU send network packets by writing directly into the Linux kernel’s io_uring queue, so no CPU thread has to relay each message.

  1. Normally a GPU can’t send anything itself. It raises a flag, and a CPU thread spinning on that flag calls send(). That thread is a “middleman” on every message.
  2. io_uring is a queue shared between a program and the kernel. With SQPOLL, a kernel thread watches the queue and sends whatever shows up, with no system call.
  3. Our trick: put that queue in memory the GPU can write to. The GPU writes the send request itself; the kernel sends it through a normal UDP socket. Works for plain UDP and for encrypted QUIC.
  4. It works and it’s correct: 166 million request–responses and 1.1 billion streamed messages, zero errors. No root, no kernel changes, no special hardware.
  5. Results: fastest path in every test, but only by 0.3–0.6 µs (~4%). It does not save CPU for one stream (the kernel thread takes a core instead of the relay), but it does when many streams share one kernel thread (−84%) or traffic is bursty (23× less). For data the GPU generates, it crushes the usual “launch a GPU kernel per message” approach: 41× the throughput.

Vocabulary

Words you need

Skim these now and come back when a term shows up. If someone asks “what’s X?”, the answer is probably here.

Kernel (two meanings!)
GPU kernel = a function that runs on the GPU. Linux kernel = the operating system core. Context tells you which; we say “Linux kernel” or “GPU program” to be clear.
Kernel launch
The CPU asking the GPU to start running a GPU function. Costs several microseconds every time.
Persistent kernel
A GPU program that starts once and keeps running forever, polling for work. Avoids paying the launch cost per message. Ours is one.
Warp / SM
A warp is 32 GPU threads that run together. An SM (streaming multiprocessor) is one GPU “core cluster”; the RTX 4090 laptop has 76.
PCIe
The connection between CPU and GPU. Every time one side reads the other’s memory it costs a round trip (~0.8 µs for us).
Pinned / mapped memory
Normal RAM that CUDA locks in place so the GPU can read and write it directly across PCIe. Our io_uring queue lives here.
BAR window
A window that lets the CPU write straight into GPU memory. We use it for the “doorbell” so the GPU polls its own fast memory.
System call (syscall)
A program asking the Linux kernel to do something (like send()). Costs a context switch. GPUs can’t make them.
io_uring
Linux’s async I/O interface: two ring buffers shared with the kernel, one for requests and one for results.
SQ / SQE
Submission queue / submission queue entry: a 64-byte “please do this” request (e.g. send these bytes on this socket).
CQ / CQE
Completion queue / entry: the kernel’s “done, here’s the result” reply. One per SQE.
Tail
A counter saying how far the producer has filled the queue. Bumping it is how you “announce” new requests.
SQPOLL
io_uring mode where a kernel thread keeps polling the SQ tail, so submitting needs no syscall. It sleeps after sq_thread_idle of no work.
NEED_WAKEUP
Flag SQPOLL sets when it goes to sleep. Someone must then make a syscall to wake it. The GPU can’t, so the CPU does.
UDP
Simple “fire a packet” transport. No connection, no retransmission.
QUIC / quiche
QUIC = the encrypted transport under HTTP/3 (runs over UDP, adds encryption, ordering, retransmission). quiche = Cloudflare’s QUIC library we used.
Loopback
Sending to 127.0.0.1: the packet goes through the whole Linux network stack but never leaves the machine.
p50 / p99
Median latency, and the latency that 99% of requests beat (the “tail”). Tails matter for real services.
RR
Request–response: send one request, wait for the reply, repeat. Our main benchmark.
Memory fence / release
An instruction that forces earlier writes to become visible before later ones. Key to correctness.
GSO / GRO
UDP segmentation/receive offload: send or receive many datagrams with one syscall. Used in streaming.
Green contexts
A CUDA feature to split the GPU’s SMs into partitions, so one job can’t crowd out another.
Handshake / 1-RTT packet
QUIC connections start with a handshake that sets up encryption keys. After that, application data travels in “1-RTT” packets encrypted with those keys. We do the handshake before timing starts and only time 1-RTT packets.
udp_sendmsg
The Linux kernel function that actually sends a UDP datagram. A relay reaches it through the send() syscall; SQPOLL calls it directly when it picks up an SQE.
x86-TSO
The x86 CPU’s memory rule: a core’s stores become visible to others in the order it made them. That’s why the CPU side needs no special fence between “write packet” and “ring doorbell”.
CCD / SMT
The Ryzen CPU has two chiplets (CCDs) with separate caches. SMT = two hardware threads sharing one physical core (“hyperthreads”).

Context

The problem: a CPU middleman on every message

Picture a GPU running an AI model. It finishes a result and wants to send it over the network. But GPUs can’t make system calls: they have no way to ask Linux to send a packet. So today it goes like this:

GPUfinishes a result,sets a flag MIDDLEMANCPU threadspins on the flag, calls send() Linux kernelUDP / QUIC stack Network burns a whole CPU core just watching+ adds delay to every message
The “CPU relay”. Each message costs a hop through a user-space thread, and that thread spins on a core the whole time.

Who avoids this already? Expensive data-center setups: RDMA network cards, NVIDIA’s DOCA GPUNetIO, NCCL’s GPU-initiated networking. They let the GPU drive special NICs directly. Research systems like GENESYS let GPUs make syscalls, but need operating-system changes.

Our question: can we get rid of the middleman on an ordinary computer: a normal Linux kernel, a normal UDP socket, an NVIDIA GPU, no root, no special network card? And if yes, is it worth it? (That second part is what the professor pushed us on after Report 2.)

Why it’s new

GPU-written io_uring had been shown on AMD GPUs (an LLVM project, for general I/O). Nobody had done it on NVIDIA, for networking, with QUIC, or measured the cost.

Context

io_uring, explained like a mailbox

io_uring gives a program two ring buffers shared with the Linux kernel:

  • The submission queue (SQ): the program writes requests (SQEs) into slots and then bumps the tail counter to say “new stuff here”.
  • The completion queue (CQ): the kernel writes a result (CQE) for each finished request.

Normally you still call io_uring_enter() (a syscall) to say “go”. But with SQPOLL, a kernel thread sits there checking the tail. Write an SQE, bump the tail, and the kernel picks it up. Zero syscalls.

Program1. write SQE2. bump tail SUBMISSION QUEUE (shared memory) tail COMPLETION QUEUE SQPOLL thread(in the Linux kernel)polls tail, sends CQE: done program reads result
Green slots = requests waiting. The tail points at the next free slot; moving it is the “announcement”.

Two newer flags make our project possible: IORING_SETUP_NO_MMAP (Linux 6.5) lets us allocate the ring memory instead of the kernel, and IORING_SETUP_NO_SQARRAY (6.6) removes an extra index array. Together, we can put the rings in memory that we also register with CUDA, so the GPU can write into the kernel’s queue.

Our approach

Our design: the GPU writes the request itself

CPU appprepares packet, doorbell GPUpersistent warp,own 2 SMs Shared memoryio_uring SQ + CQ,send buffers Linux kernelSQPOLL thread →UDP stack Receiverchecks every byte,replies 1 2GPU computes / checks 3 4 5 6 7 1 doorbell · 2 GPU works · 3 GPU writes SQE + bumps tail · 4 SQPOLL submits udp_sendmsg 5 packet reaches receiver · 6 reply to the app · 7 CQE: kernel is done, buffer can be reused
Steps 3 and 4 are the whole trick: the GPU writes the request, the kernel sends it, and no user-space thread touches the message.

The pieces, one by one

  • The ring in GPU-mapped memory. We create the io_uring with raw syscalls (no liburing), on memory we allocate and then register with CUDA (cudaHostRegister). Now both the GPU and the kernel see the same queue.
  • The persistent sender warp. One warp runs forever on the GPU, polling a 16-byte “doorbell” descriptor. That doorbell lives in GPU memory and the CPU writes it through the BAR window, so the GPU’s polling is a cheap local read, not a PCIe trip.
  • Pre-staging. Right after sending, the warp already writes and fences the next SQE. So when the next request comes, publishing is a single store of the tail. This was our biggest latency optimization.
  • The CPU app thread. In our benchmark it plays the “application”: prepares packets (and owns all QUIC state), rings the doorbell, reaps completions and recycles buffers. It never sends a packet in GPU-direct mode.
  • The SQPOLL kernel thread. Pinned to its own CPU core. It does the actual udp_sendmsg inside the kernel.
Remember

The CPU isn’t gone. SQPOLL is a CPU thread too, just a kernel one. What disappears is the user-space relay hop on each message. That distinction is exactly why H2 (CPU savings) turned out mixed.

Two workloads

  • GPU-triggered (UDP or QUIC): the CPU prepares the packet; the GPU checks it (a checksum standing in for “a result is ready”) and triggers the send.
  • GPU-generated (UDP): the GPU computes the payload itself and writes it into the send buffer; the receiver recomputes and verifies every byte. Both a request–response version and a continuous stream. This came from the professor’s Report 1 feedback.

Our approach

The hard parts (and the bugs we hit)

The GPU and the CPU/kernel don’t see memory writes in the same order. Getting this wrong doesn’t crash: it silently sends garbage. Three rules made it correct:

Rule 1: finish writing, then announce

The kernel reads an SQE as soon as it sees the tail move. If the tail becomes visible before the SQE’s contents, the kernel reads a half-written request. So the GPU does a system-scope release fence before storing the tail.

GPU TIMELINE → write SQE + payload release fence store tail kernel seesa full request Without the fence: stale or half-written SQEs in 10 of 22 runs (45%). With pre-staging, the fence happens ahead of time, so “publish” is just the tail store.

For GPU-generated payloads, 32 threads each write part of the message. They first __syncwarp() so all lanes are done, then one lane does the release and the tail store. Without the release: corrupt payloads in 5 of 23 runs.

Rule 2: reuse a buffer only after its completion

The kernel may still be reading a send buffer after you submit. So each buffer is reused only after its CQE arrives. Freed buffers get overwritten with a poison pattern, so if anything reads a buffer too late, the receiver’s byte check catches it. Note: a CQE means “sent locally”, not “the peer received it”.

Rule 3: wake the sleeping kernel thread

SQPOLL goes to sleep after sq_thread_idle without work and sets NEED_WAKEUP. Waking it needs a syscall, which a GPU can’t make. So the GPU raises a wake request in shared memory and the CPU app thread does the syscall. This was literally our first bug: the GPU kept submitting into a sleeping SQPOLL and nothing happened.

All the bugs our tests caught

BugWhat went wrongLesson
SQPOLL asleepGPU kept submitting; kernel thread was sleepingEvery GPU wait on kernel progress must request a wake-up
Generator raceTail advanced before the SQE was visibleRelease before the tail, always
Receive overflowFlow-control window sized wrongWindow ≤ receiver buffer
BAR orderingCPU writes through the BAR to different addresses can arrive at the GPU out of order, so a GPU copy of the packet lagged its doorbell (1/12 test failures → 0/132 after fix)GPU re-checks the host copy before ever declining a send
ACK starvationLaunch + copy stream baseline stalledBound bursts to 64 messages
CUDA deadlocksLaunching a new kernel (lazy module loading) or calling cudaMalloc/cudaFree while the persistent kernel runs can hang foreverLoad every kernel and allocate everything before starting the persistent kernel

We have 42 automated tests including negative controls: versions with a rule deliberately removed, to prove each rule is actually needed. NVIDIA’s compute-sanitizer reports no errors.

Our approach

Where QUIC fits

QUIC is a lot more than UDP: encryption, packet numbers, congestion control, ACKs, retransmissions. We did not put any of that on the GPU. The key fact that makes the project possible: quiche’s send() writes a fully encrypted packet into a buffer we provide, and then we decide how to transmit it.

  • The CPU (quiche) prepares exactly one protected 1350-byte datagram per request, just before the trigger.
  • The GPU only decides when it leaves (triggers the send).
  • Every send path sends the exact same quiche-made bytes, so any speed difference is purely the submission mechanism. That’s what makes the comparison fair.

Safety test: we made the GPU deliberately decline every Nth packet. 40 declined packets → exactly 40 losses detected and 40 retransmissions, each in a new packet. Ciphertext is never replayed.

Real loss (Linux tc netem, 0.1–2% loss on loopback): recovery works identically on every path. Each loss costs ≈26 ms. Why so long? QUIC’s probe timeout = smoothed RTT + 4×RTT variance + the peer’s max ACK delay (25 ms). On loopback the RTT is microseconds, so the 25 ms ACK delay dominates. Fix: a smaller ACK delay, which has nothing to do with our send path.

Why quiche over quinn? quiche hands us the finished encrypted packet and lets us do the I/O ourselves, so every path sends identical bytes. It’s also widely used in production (Cloudflare).

Experimental setting

The four send paths

GPUCPUKERNEL 0. Launch + copy 1. Relay + send() 2. Relay + io_uring 3. GPU-direct (ours) launch kernel,copy result back set a flag set a flag write SQE + tail launch, sync, send() relay thread polls,calls send() relay thread polls,writes SQE nobody UDP send UDP send SQPOLL → UDP SQPOLL → UDP
Orange = a CPU thread works on every message. Paths 1–3 share the same persistent GPU kernel, packets, receiver and core pinning.

Why path 2 matters most: it uses io_uring and a relay. Comparing it with path 3 isolates exactly one thing: removing the relay. Comparing 1 vs 2 shows whether io_uring itself helps (it doesn’t, much). Comparing 1 vs 3 is the overall “ours vs what people do today”.

Path 0 (launch + copy + send) is the textbook CUDA way and only applies to GPU-generated data. We also tested three other CUDA tricks to answer “why not a standard mechanism?”: cudaLaunchHostFunc callbacks, CUDA graphs, and stream memory ops. And two no-GPU floors (the CPU sends itself) to see the lower bound.

Experimental setting

How we measured (and why you can trust it)

  • Machine: RTX 4090 Laptop GPU (76 SMs), AMD Ryzen 9 7945HX (16 cores on 2 CCDs), Arch Linux 7.3.5, CUDA 13.5, quiche 0.30.0. About 7.2k lines of Rust + 1.5k of CUDA.
  • Network: sender and receiver are separate processes over loopback (127.0.0.1). Full Linux network stack, no NIC noise.
  • Main benchmark: request–response, one request in flight, 256-byte payload (also 64, 1024, 1400). Isolates per-message overhead, which is what removing the relay targets. Bulk transfers would hide it.
  • Latency clock: one CPU clock, started right before the doorbell and stopped when the reply arrives. Same clock, same process, so no clock-sync problems.
  • One-way breakdown: the GPU’s own timer, calibrated to the CPU clock by a ping-pong kernel before and after each run (it drifts ~90 ppm and ticks every 1024 ns, so we use trimmed means).
  • Cost: CPU time per thread, system-wide CPU, GPU power/energy (NVML), CPU package power (RAPL), and how much a co-running job slows down.
  • Fairness: warm-up, every thread pinned to its own core, path order rotated each repetition, 10 repetitions for headline numbers, and a guard that waits until the machine is idle (one run was thrown out because a browser was open).
  • Stats: bootstrap 95% confidence intervals and Mann–Whitney tests. “GPU-direct won all 10 paired repetitions” gives p = 1.8×10⁻⁴.
  • Load tests: open-loop Poisson arrivals, latency measured from each request’s scheduled arrival, so queueing delay isn’t hidden.

Our four hypotheses

H1

Faster

Yes, but small

Removing the relay lowers latency.

H2

Less CPU

Depends

No relay thread → less CPU.

H3

Beats launching

Yes, by a lot

For GPU-made data, beats launch + copy.

H4

QUIC stays safe

Yes

Every packet accepted, recovery intact.

Results

H1: faster, but only by about 4%

Workload (median, µs)Launch + copyRelay + send()Relay + io_uringGPU-directGain vs path 2
UDP, CPU-prepared—8.298.338.00−0.33
GPU-generated UDP20.059.589.469.09−0.38
QUIC 1-RTT—12.8012.8612.31−0.56

10 repetitions × 100k requests each. GPU-direct won every paired repetition (p = 1.8×10⁻⁴) and also had lower p99. Paths 1 and 2 are basically tied, so the gain comes from removing the relay, not from io_uring itself.

Why so small? Look at where the time goes

CPU alone (no GPU)6.42 µs GPU + CPU relay8.33 µs GPU-direct8.00 µs CPU-side work added by the GPU trip the middleman
Bars to scale. A GPU in the loop adds ~1.9 µs; GPU-direct removes 0.33 of it (10–20% of the GPU’s overhead in every workload).

The one-way breakdown (GPU-generated) shows where each microsecond goes: doorbell → GPU sees it 0.54 µs, GPU generates + publishes 1.40, publish → receiver’s kernel 1.57 for GPU-direct vs 1.64–1.72 for the relays, receiver wake-up 3.2, reply 2.4. Kernel tracing (bpftrace) shows that once inside the kernel, both paths cost the same. The relay’s extra time is just noticing the flag and entering the syscall. The rest of the round-trip gain comes from less interference: no spinning relay thread competing on the same chiplet.

What can’t be removed: the doorbell becoming visible to the GPU (half of a 0.79 µs CPU↔GPU round trip), the GPU’s own work, and getting the request back to the kernel. That’s physics of a discrete GPU over PCIe, not software.

Under load, the gain grows

With random (Poisson) arrivals: −19% median latency at 90k requests/s and −57% at 100k (92 vs 214 µs). Why: near saturation, queueing delay explodes (roughly ρ/(1−ρ)), so a slightly shorter service time cuts waiting a lot. Launch + copy saturates near 50k/s because each request takes ~20 µs of serialized launch + copy + sync.

vs other CUDA mechanisms: every launch-based one (host callbacks, graphs, stream memory ops) is ~2× slower (18–21 µs). Host callbacks also cap at 37k/s with 2–3 ms spikes, since CUDA runs them one at a time on an internal thread. The big win is the persistent kernel; among persistent designs, GPU-direct is fastest.

Verdict

H1 supported, but modest. Statistically clear in every workload, ~4% of a round trip, bigger under load.

Results

H2: the twist, one stream saves no CPU

ONE STEADY STREAM · process cores (spinning threads) relay + send()≈1.9 relay + io_uring≈2.9 GPU-direct≈1.9 (same!) FOUR GPU STREAMS · send-path cores 4 relays3.66 GPU-direct, shared SQPOLL0.60 (−84%) BURSTY TRAFFIC · cores (10 requests every 50 ms) spinning relay≈0.99 sleeping relay · GPU-direct≈0.10 · 0.043 (23× less than spinning)
Bars use one scale within each panel. Bursty values: GPU-direct 0.043 cores is 23× below a spinning relay and 2.4× below a sleeping one.

Why no saving for one stream: SQPOLL is a busy-polling kernel thread on its own core. It replaces the relay’s core one-for-one, even though it does little real work (≤27% of its core at saturation, under 1.5% at ≤30k requests/s). GPU-direct is one core cheaper than path 2, but only because path 2 spins two threads (relay + SQPOLL). Against the classic relay, it’s a tie.

A relay can be cheap, GPU-direct can’t (for one stream): a relay that sleeps 5 µs between polls uses 66% less CPU for +3.6 µs latency. SQPOLL only sleeps after ≥1 ms of no work, so it can’t make that trade at a steady rate.

Energy: any GPU-driven sender keeps the GPU at full clock: 50–72 W vs 11–18 W idle, whether persistent or launching. And a spinning SQPOLL draws +4.4 W more CPU package power than a spinning user relay (39.4 vs 35.0 W), so GPU-direct’s CPU energy per message is 12–27% higher in streams. We don’t know exactly why the kernel loop draws more.

Where it does save:

  • Many streams: one SQPOLL thread can watch many rings (IORING_SETUP_ATTACH_WQ). Four streams: 0.60 send-path cores vs 3.66 for four relays (−84%), for +1.3 µs latency and −8% throughput, perfectly fair (Jain’s index 1.000).
  • Bursty traffic: with sq_thread_idle = 1 ms, SQPOLL sleeps between bursts. 0.043 cores, 23× less than a spinning relay, with lower in-burst latency (13.0 vs 20.3 µs). Cost: the first request after a gap waits ~26 µs for the wake-up.

Co-running cost: spinning senders slow a CPU job on the hyperthread sibling by ~5% (~2% elsewhere). On the GPU, a sender costs a compute kernel 6–8% of its throughput, mostly power headroom.

Verdict

H2 depends on the workload. One steady stream: GPU-direct buys latency, not CPU. Shared or bursty: real savings.

Results

H3 + H4: where it wins big, and QUIC is safe

GPU-GENERATED STREAM · 256 B · million messages/s GPU-direct3.15 relay + io_uring3.03 relay + send()2.96 launch + copy0.077 (41× less)
Every byte verified by the receiver. Sender CPU per message: 0.61 µs (GPU-direct) vs 0.65, 0.96 and 12.2.
  • Request–response: 9.1 µs vs 20.0 µs for launch + copy (2.2× faster).
  • Streaming: 41× the throughput. Peak 6.94M messages/s at 64 B; about 8 Gbit/s of GPU-generated payload at 1–1.4 KB.
  • Energy: 7–20× less energy per message than launch-based paths once messages are frequent (the GPU draws ~50 W either way, but delivers far more messages).
  • Data-dependent alerts: the persistent kernel can check 6–8M events/s and send only the interesting ones.
  • When it stops mattering: if the GPU computes ≥50 µs before each send, all persistent paths are within 1% (and GPU-direct is 15% ahead of launch + copy at 50 µs). Submission becomes a rounding error.

Why the persistent paths are close in streaming: batching (32 messages per send call with GSO) spreads the per-message submission cost; the limit becomes the kernel and the single-threaded receiver. Each optimization moved the bottleneck: cached completion count +23%, CPU watching for SQPOLL wake-ups +50%, GSO 2.7×, receiver GRO +22%, block-parallel generator +65%.

Why launch + copy is “bimodal”: each request takes either ~12.5 µs or ~20.4 µs depending on the GPU’s clock state. Back-to-back launches on a warm GPU hit the slow mode; spaced-out launches hit the fast mode. That’s why Report 2 said 14.1 µs and the final runs say 20.0. Even in fast mode it’s 1.4× slower than GPU-direct.

Verdict

H3 supported by a lot. H4 supported: every QUIC datagram accepted, losses recovered normally, nothing replayed (details in Where QUIC fits).

Results

Deployment gotchas (great Q&A material)

  • Share the GPU carefully. Next to a compute kernel that fills the GPU, the sender warp shares its SM with ~32 compute warps: p99 latency 0.4–0.5 ms, and launch + copy queues behind compute (2.3 ms median). Fix: a 2-SM partition with CUDA green contexts → p99 back to 12–13 µs, launch + copy to 13.6 µs, and no cost when the GPU is idle. Under that load GPU-direct and relay + send() tie (10.11 vs 10.00 µs).
  • Place SQPOLL well. SQPOLL does the whole kernel send, touching socket data shared with the app and receiver. On the other CCD it gets cross-chiplet cache misses: GPU-direct becomes slower than relay + send() (+0.74 µs). On the app thread’s hyperthread sibling: +0.27 µs. Rule: its own physical core, same CCD as the socket users.
  • Load everything first. With CUDA’s lazy module loading, launching any new kernel while the persistent one runs can hang forever (it waits for running kernels to finish, which ours never does). Same for cudaMalloc/cudaFree. Preload (or set CUDA_MODULE_LOADING=EAGER) and allocate up front.
  • Cold start: after 1 s idle, the first request takes 84 µs (SQPOLL wake-up) vs 52 µs for the relay and 197 µs for launch + copy.
  • Stability: GPU-direct had the lower median in 30 of 30 alternating repetitions over five minutes, despite 0.4 µs of thermal drift common to all paths.
  • Requirements: Linux ≥ 6.6 with io_uring allowed for normal users (RHEL 9, which our university clusters run, disables it), any CUDA GPU that can map pinned memory, no root.

Conclusion

So, is it worth it?

SituationGPU-direct vs a CPU relay
One steady streamLowest latency and tail; same cores as a spinning relay; +4.4 W CPU. A sleeping relay is cheaper (0.16–0.40 cores) if a few µs more is OK.
High load−19% (90k/s) to −57% (100k/s) median latency.
Several GPU streams−84% send-path CPU at four streams on one kernel thread, +1.3 µs.
Bursty traffic0.043 cores with sq_thread_idle = 1 ms; +26 µs on the first request after a gap.
GPU also running computeNeeds a 2-SM partition (so does every GPU-driven sender); then p99 13 µs and a tie with the relay.
GPU work ≥ 50 µs per messageLatency differences vanish; choose by CPU cost.
vs launch-based CUDA≈2× lower latency, 41× throughput, 7–20× less energy per message; costs a persistent warp and ~50 W of GPU while active.
One-line takeaway

A GPU can send through ordinary Linux sockets by itself. It’s the fastest path, but the gain is small for one stream; it pays off most for GPU-generated data, many streams, and bursty traffic.

Conclusion

Limits and next steps

  • Loopback, one laptop. A real NIC adds latency that would dilute the µs gains. A cache-coherent machine like a GH200 could change the visibility costs (we planned it, but couldn’t get io_uring access on the clusters).
  • The CPU still encrypts QUIC. GPU-side encryption was out of scope.
  • SQPOLL still needs a core (shareable, or able to sleep).
  • GPU power stays ~50 W whenever anything GPU-driven sends; reducing it needs root clock control.
  • Unexplained: rare 1–3 ms stalls common to all paths in open-loop p99.9, and why SQPOLL draws more power than a user spin loop.
  • Next: GH200, a physical NIC, multiple QUIC connections, GPU-side encryption.

Practice

Q&A practice

Try answering out loud before opening each one.

The idea

In one sentence, what did you build?

An NVIDIA GPU that sends UDP and QUIC packets by writing requests straight into the Linux kernel’s io_uring queue, so no CPU thread relays each message.

Why can’t a GPU just call send()?

GPU code can’t make system calls. There’s no path from a GPU thread into the operating system, so normally a CPU thread has to do it on the GPU’s behalf.

Why not use RDMA or GPUDirect like data centers do?

Those need special network cards and their own protocols, and they bypass the normal Linux stack. We wanted ordinary sockets on an ordinary machine, keeping Linux’s protocols, firewall and sharing. Also no root and no kernel changes.

Does the CPU still do anything?

Yes. The kernel’s SQPOLL thread (on a CPU core) does the actual send, the CPU app prepares and encrypts QUIC packets, rings the doorbell, and recycles buffers. What’s removed is the per-message user-space relay hop.

What does io_uring give you that a normal syscall doesn’t?

A shared-memory queue: you submit by writing memory, not by calling the kernel. With SQPOLL the kernel polls that memory, so a device that can write memory (our GPU) can submit without ever making a syscall.

What made this possible only recently?

IORING_SETUP_NO_MMAP (Linux 6.5) lets the app allocate the ring memory, so we can register it with CUDA; NO_SQARRAY (6.6) removes an index array. Before that, the kernel owned the ring memory.

Correctness

How do you know it’s correct?

Every message has a sequence number and the receiver checks every byte (recomputing GPU-generated payloads). 166M request–responses and 1.1B streamed messages, zero errors. 42 automated tests, including negative controls, and compute-sanitizer is clean.

What’s a negative control and why do it?

A deliberately broken version (a rule removed) to prove the rule is necessary. Example: without the fence before the tail, 10 of 22 runs sent stale or half-written requests. It shows our tests can actually catch the bug.

What was the hardest bug?

Probably the BAR ordering one: CPU writes into GPU memory through the BAR window to different addresses can arrive out of order, so the GPU’s copy of a packet could lag its doorbell. Or the CUDA deadlocks: launching a new kernel or calling cudaMalloc while the persistent kernel runs can hang forever.

What happens if the kernel thread falls asleep?

SQPOLL sets NEED_WAKEUP and stops polling. Only a syscall wakes it, which the GPU can’t make, so the GPU raises a wake request and the CPU app thread makes the syscall. Forgetting this was our first bug.

QUIC

If the CPU still encrypts, what’s the point of QUIC here?

The question is whether a GPU can trigger real encrypted traffic safely, not whether it can encrypt. The GPU decides when each protected packet leaves; quiche keeps numbering, encryption and recovery, unmodified. That’s a realistic split for GPU apps.

Can the GPU break QUIC, e.g. by resending old packets?

No. Ciphertext is never replayed: a declined packet is treated as lost and quiche retransmits the data in a new packet. 40 declines → exactly 40 losses and 40 retransmissions.

Why does each loss cost 26 ms?

QUIC’s probe timeout includes the peer’s max ACK delay (25 ms). On loopback the RTT is microseconds, so that 25 ms dominates. It’s a QUIC tuning issue, identical on every send path.

Results

Why is the speedup so small?

The relay is a small part of what a GPU adds. A GPU in the loop costs ~1.9 µs (PCIe round trips plus GPU work); the relay is ~0.33 of that. You can’t remove PCIe physics with software.

Is 0.3 µs even meaningful?

Statistically yes (won 10/10 paired repetitions, p < 0.001). Practically it’s small for one request, but under load it compounds: 57% lower median latency at 100k requests/s because queues amplify small savings.

If it doesn’t save CPU, why bother?

For one stream it buys latency, not CPU. It does save CPU when many GPU streams share one kernel thread (−84% at four streams) or traffic is bursty (23× less). And for GPU-generated data it’s 41× the throughput of launching kernels.

Why does io_uring with a relay (path 2) use the most CPU?

It spins two threads: the user relay and SQPOLL. GPU-direct keeps only SQPOLL, and the classic relay keeps only the relay, so those two tie.

Couldn’t you just make the relay sleep to save CPU?

Yes, and we measured it: sleeping 5 µs between polls cuts its CPU 66% for +3.6 µs. That’s the cheapest option for one stream if a few µs is OK. GPU-direct can’t do that at steady rates because SQPOLL only sleeps after ≥1 ms idle.

What about GPU power?

Any GPU-driven sender keeps the GPU at ~50–72 W vs 11–18 W idle, regardless of design. That’s a fixed cost of letting the GPU drive I/O. Per message, GPU-direct is 7–20× more energy-efficient than launch-based paths.

Why did launch + copy change from 14 µs (Report 2) to 20 µs?

It’s bimodal: each request takes ~12.5 or ~20.4 µs depending on GPU clock state. Back-to-back launches on a warm GPU hit the slow mode. The persistent paths don’t have this problem.

Does it still help if the GPU does heavy work per message?

Not much: with ≥50 µs of GPU compute per message, all persistent paths are within 1%. The send path stops mattering; pick by CPU cost.

Method and scope

Why loopback? Does it apply to real networks?

Loopback runs the full Linux network stack while removing NIC and wire noise, so differences come only from the submission path. A real NIC adds latency, so the relative gain would be smaller. That’s our main limitation.

How did you make the comparison fair?

Same GPU kernel, same packets, same receiver, same core pinning; only the submission step differs. Warm-up, path order rotated, 10 repetitions, idle-machine guard, nonparametric statistics.

Why request–response and not bulk transfer?

RR isolates per-message overhead, which is exactly what removing the relay targets. In bulk transfers each send is a tiny fraction of the total, which would hide the effect. We also tested streaming separately.

Would this work on a server or in the cloud?

On any Linux ≥ 6.6 that allows io_uring for normal users. Some distros disable it (RHEL 9, used by our university clusters). Deploy with an SM partition, SQPOLL on its own core near the app, and all CUDA kernels loaded first.

Can multiple GPU streams share it?

Yes: one SQPOLL thread can serve many rings (ATTACH_WQ). Four streams used 84% less send-path CPU than four relays, with perfect fairness.

How is this different from GENESYS or AGIO?

GENESYS lets GPU threads make syscalls but needs OS changes. AGIO does async GPU I/O for storage. We use an unmodified kernel interface for networking, with no privileges, and we measured the cost.

What would you do next?

Test on a cache-coherent GH200 and a physical NIC, multiple QUIC connections, and GPU-side encryption.

More tough ones

Who is on the other end of the QUIC connection?

The receiver process runs a quiche server; our sender runs the quiche client. They complete the handshake over loopback before timing starts. Then each request is a 1-RTT packet, and the server checks it and replies on the same connection.

Why UDP and not TCP?

QUIC runs over UDP, and the professor asked for GPU-generated UDP. With UDP one message is one datagram is one SQE, with no byte stream to manage. The io_uring SEND operation also works on TCP sockets, so the mechanism should carry over, but we didn’t test TCP.

Doesn’t SQPOLL need root?

It used to. Since Linux 5.11 a normal user can create SQPOLL rings. Everything in our setup runs unprivileged.

Why do some systems turn io_uring off?

io_uring has had many security bugs, so some distributions (RHEL 9 by default, which our university clusters run) and some companies disable or restrict it. Our design needs it enabled for normal users. That’s a real deployment limitation.

Is it safe to let a GPU write kernel requests?

It grants no new privileges: the ring belongs to our process, so the GPU can only do what our process could already do. But a buggy GPU kernel could submit any io_uring operation the process is allowed, not just sends. io_uring can lock a ring down to specific operations (IORING_REGISTER_RESTRICTIONS); we didn’t use it, and it would be the obvious hardening step.

Why doesn’t the io_uring relay (path 2) beat the send() relay (path 1)?

Once inside the kernel the send costs the same either way (we checked with bpftrace). Path 2 still pays for the relay noticing the flag, and then adds a second hop: the relay writes an SQE and SQPOLL has to pick it up. The two effects cancel out, so they tie.

Why 2 SMs for the partition, not 1?

2 of 76 SMs (2.6% of the GPU) was enough to bring the worst case back to 12–13 µs with no cost when idle, so we didn’t go smaller. We didn’t test a 1-SM partition. The sender is one warp, so it only needs a sliver of the GPU; the point is that nobody else can use that sliver.

Why is the receiver such a big part of the round trip (3.2 µs)?

The receiver sleeps in a blocking receive, so the kernel has to wake its thread through the scheduler. A spinning receiver would be faster, but it’s the same cost on every path, so it doesn’t affect the comparison.

Would it work with multiple GPUs, or AMD/Intel GPUs?

With several GPUs, each would get its own rings (possibly sharing one SQPOLL thread); untested. AMD GPUs writing io_uring was shown by earlier work for general I/O, but our code is CUDA-specific and our measurements are NVIDIA-only.

Why not liburing?

We needed the rings in memory we allocate and register with CUDA, and we wanted to check the exact layout the kernel expects. Raw io_uring_setup calls give full control and make that check possible.

What would change on a real network card?

Nothing in the mechanism: it’s an ordinary socket, so the packet would just go out the NIC. The wire and NIC add microseconds of latency to every path, so the relative gain shrinks. Throughput-bound cases (many streams, GPU-generated data) should still benefit.

Why doesn’t GPU-direct make the GPU itself use less power?

Any design where the GPU drives I/O keeps the GPU awake at full clock (50–72 W vs 11–18 W idle), whether it polls, backs off, stays persistent or launches kernels. We tried GPU back-off with __nanosleep: no power saved, only added latency. Lowering clocks needs root.

What’s the biggest lesson from the project?

Faster isn’t the same as cheaper. Removing the middleman made every path faster, but the CPU just moved into the kernel. The real wins showed up only once we measured cost: sharing one kernel thread across streams, letting it sleep for bursty traffic, and replacing kernel launches for GPU-generated data.

Memorize these

Numbers cheat sheet

0.3–0.6 µsfaster than the relay (≈4%), p < 0.001
−57%median latency at 100k req/s
1.9 µswhat a GPU adds to a UDP round trip (6.42 → 8.33)
±0 coressaved for one stream; +4.4 W CPU
−84%send-path CPU, four streams on one SQPOLL
23×less CPU for bursty traffic (0.043 cores)
41×throughput vs launch + copy (3.15M vs 77k msg/s)
2.2×faster per request vs launch + copy (9.1 vs 20.0 µs)
7–20×less energy per message vs launch-based
45%runs corrupted without the ordering fence
0 errorsin 166M requests + 1.1B messages
0.5 ms → 13 µsp99 next to GPU compute, with a 2-SM partition
50–72 WGPU power whenever GPU-driven sending is active
26 mscost of one QUIC loss (25 ms ACK delay)
0.79 µsCPU↔GPU round trip over PCIe
76 SMsRTX 4090 Laptop; sender uses 2

Deep dive · for the hard questions

How it actually works, down to the code

Everything above is enough for the talk. This part is for when someone asks “but how exactly…?”. Code snippets are simplified from the real files in gtq/, with the file named in each one.

1. Map of the code

About 7.2k lines of Rust (host side) and 1.5k of CUDA/C, in five crates:

gtq-uring

Creates the io_uring with raw syscalls (no liburing) on memory we allocate. Also the Waker that wakes a sleeping SQPOLL.

gtq-cuda

The CUDA side. gtq.cu has the GPU kernels (request–response, stream, block-parallel stream, calibration, burn). gtq_sq.cuh is the GPU’s io_uring producer. gtq_abi.h holds structs shared by CPU and GPU.

gtq-bench

The harness: rr.rs (request–response, all send paths), stream.rs (streaming), transport.rs (QUIC via quiche), cost.rs (CPU/GPU/energy meters), corun.rs (co-running load).

gtq-wire

Packet format, the receiver loops (including GRO), payload generator and checker, the poison byte.

gtq-recv

The receiver process binary that verifies every byte and replies.

Before the code: the idea behind each mechanism

Every mechanism in the project exists because of one problem. Know the problem and you can rebuild the mechanism yourself, which is the best way to answer “why did you do it like that?”.

The big idea first: the whole system is a chain of counters that only go up. One side writes its data, then bumps a counter; the other side watches the counter and reads the data only after it moves. The doorbell, the io_uring tail, the completion queue and the completed count are all the same trick, pointed in different directions:

CPU appprepares packets, reaps GPU sender warpwaits, checks, submits Linux kernelSQPOLL sends Completion queueone CQE per send ① doorbell = seq+1 (CPU → GPU) ② SQ tail(GPU → kernel) ③ CQEs (kernel → CPU) reap ④ completed count (CPU → GPU: buffers free)
Four counters, four directions. Each one says “everything up to this number is ready”. Nobody ever resets them, so there is nothing to race on.

The doorbell

ProblemOur GPU program never stops running (it’s persistent, to avoid paying a kernel launch per message). So nobody “starts” it for a new request. How does it find out that there’s new work, and which request it is?

IdeaExactly like a doorbell: a known spot in memory the GPU keeps checking. The CPU “rings” by writing a number there. When the number changes, the GPU knows there’s a request.

Why a counter, not a yes/no flagA flag has to be reset by someone after each use. If the GPU resets it while the CPU is already setting it for the next request, a ring gets lost, and resetting costs an extra write across PCIe. Our doorbell is seq + 1 and only goes up: the GPU waits until doorbell ≥ next. Nothing is ever reset, 0 means “nothing yet”, the value also says which request it is (and therefore which buffer slot), and all-ones means “stop”.

Why it’s written lastSame rule as the io_uring tail: the CPU writes the packet, its length and checksum first, and rings last. Ring first, and the GPU might read a packet that isn’t there yet.

Why it lives in GPU memoryThe GPU checks the doorbell millions of times; the CPU writes it once per request. So put it on the side that reads it most: in GPU memory each check is a fast local read, and the CPU pays one write through the BAR window per request. (When it lived in host memory, every check was a PCIe round trip, so the GPU kept 4 staggered reads in flight to notice changes sooner.)

Why 16 bytesDoorbell, length and checksum sit together and are read in one load. Reading the doorbell and then the length separately would be two PCIe round trips in a row.

Same idea, reversedIn the relay paths the GPU “rings” the CPU with a ready counter the relay thread watches. That one hop is exactly what GPU-direct removes.

The persistent kernel

ProblemLaunching a GPU kernel per message costs several microseconds of driver work, plus a copy and a sync. That’s why launch + copy is 2.2× slower.

IdeaLaunch once, keep a warp spinning forever, feed it work through the doorbell. Price: it occupies a warp (and an SM partition if the GPU is shared), keeps the GPU at ~50 W, and means every other CUDA kernel must be loaded before it starts, or CUDA can deadlock.

The tail (write, then announce)

ProblemTwo sides share a queue without locks. The reader must never see a half-written entry.

IdeaThe classic single-producer ring: write the entry, then advance a counter. The reader trusts only entries below the counter. Rings are fixed-size and power-of-two, so slot = counter & mask and memory is never allocated on the fly. One producer per ring means the tail needs no atomics or locks; more streams means more rings, not shared tails.

Pre-staging

ProblemMaking an SQE visible needs a system fence that costs ~0.9 µs, and it sat on the critical path between “request arrives” and “packet sent”.

IdeaThe next SQE is almost entirely predictable (same socket, next slot, usually same length). So write it and pay the fence before the request arrives, while the GPU is idle anyway. When the doorbell rings, publishing is one cheap tail store. Like addressing and stamping the next envelope while you wait, so you only drop it in the mailbox. If the request doesn’t match the staged one, the GPU just re-stages (we count hits and misses).

Caching the other side’s counters

ProblemReading host memory from the GPU costs a PCIe round trip (~0.8 µs). Checking “is there queue space?” or “is this buffer free?” on every message would add that each time.

IdeaRemember the last value you read and only re-read when it would make you wait. This is safe because the counters only go up: an old value is always too pessimistic, never too optimistic, so it can make you wait unnecessarily but never overwrite something in use. Caching completed alone gave +23% stream throughput.

One “completed” number instead of per-buffer flags

ProblemA “done” flag per buffer means one read per buffer.

IdeaA single number meaning “every message below N is finished”. The CPU only advances it over a continuous run of finished messages, so one late completion can’t accidentally free a later buffer. The GPU reuses slot m when completed + nslots > m.

Poison bytes

ProblemIf a buffer were reused too early, the kernel would send old data that still looks like a valid packet. Nothing would crash; the bug would just hide.

IdeaA tripwire: every freed buffer is filled with 0xDD. Any packet built from a freed buffer arrives as obvious garbage, and the receiver (which checks every byte) reports it. That turns a silent bug into a loud one.

The wake-up handshake (two counters)

ProblemA sleeping SQPOLL only wakes on a syscall, which the GPU can’t make. A simple “please wake” flag would either flood the CPU with duplicate requests or lose one.

IdeaThe counter trick again: wake_req (GPU bumps it) and wake_served (CPU bumps it). The GPU only asks when the previous request was served, so there’s at most one outstanding; the CPU makes the syscall, waits until the kernel clears NEED_WAKEUP, then marks it served.

The GPU-side mirror copy (and its safety net)

ProblemThe GPU checksums each packet. Reading the packet from host memory means more PCIe traffic on the critical path.

IdeaThe CPU also writes a copy into GPU memory, so the checksum reads locally. But writes through the BAR window can arrive out of order, so the copy may lag the doorbell. Safety net: if the copy’s checksum doesn’t match, re-check the host copy, which is what the kernel actually sends. Fast in the common case, correct in every case.

Sharing one SQPOLL thread

ProblemThe polling thread costs a whole core, whether it serves one ring or ten.

IdeaSince its cost is per thread, not per ring, attach many rings to one thread (ATTACH_WQ) and split that cost. That’s where the −84% at four streams comes from.

The SM partition

ProblemThe GPU’s scheduler shares an SM between all resident warps. Next to heavy compute, our sender warp gets a tiny slice of issue slots, so latency spikes to 0.5 ms.

IdeaA reserved lane: green contexts give the sender 2 of the 76 SMs that compute work can’t touch. It costs 2.6% of the GPU and nothing at all when the GPU is otherwise idle.

The sequence number everywhere

ProblemCompletions, replies and buffers need to be matched back to the right request.

IdeaOne number does it all: it’s the doorbell value (minus one), it picks the buffer slot, it rides in the SQE’s user_data so the CQE says which send finished, and it’s inside the payload so the receiver can check order and recompute GPU-generated bytes.

2. Creating a ring the GPU can write

  1. Allocate one region ourselves with mmap: [SQEs][ring header + CQEs], both page-aligned. Defaults: 8 SQ entries, CQ twice that, sq_thread_idle = 20 ms.
  2. Call io_uring_setup with SQPOLL | NO_MMAP | NO_SQARRAY, pointing sq_off.user_addr and cq_off.user_addr into our region. Optionally SQ_AFF (pin SQPOLL to a CPU) and ATTACH_WQ (share another ring’s SQPOLL thread).
  3. Sanity-check that every offset the kernel returned lies inside our region.
  4. Register the region with CUDA as mapped host memory, and hand the GPU a small struct of device pointers: khead, ktail, kflags, sqes, plus mask and entries.
// gtq-uring/src/lib.rs (simplified)
let region = mmap(sqes_len + rings_len, PROT_READ | PROT_WRITE, ...);
let mut p = Params { flags: IORING_SETUP_SQPOLL | IORING_SETUP_NO_MMAP | IORING_SETUP_NO_SQARRAY,
                     sq_thread_idle: cfg.sq_thread_idle_ms, .. };
if let Some(cpu) = cfg.sq_thread_cpu { p.flags |= IORING_SETUP_SQ_AFF; p.sq_thread_cpu = cpu; }
if let Some(fd)  = cfg.attach_wq     { p.flags |= IORING_SETUP_ATTACH_WQ; p.wq_fd = fd; }
p.sq_off.user_addr = region as u64;                  // SQEs live here
p.cq_off.user_addr = region.add(sqes_len) as u64;    // ring header + CQEs here
let fd = syscall(SYS_io_uring_setup, sq_entries, &mut p);

No privileges are needed for any of this. The only requirement is a kernel ≥ 6.6 that allows io_uring for normal users.

3. The GPU’s send path

The GPU side is one struct, GtqSqProducer, used by exactly one GPU thread per ring (so the tail never has two writers). An SQE is 64 bytes: opcode IORING_OP_SEND (26), the socket fd, the host address of the send buffer, the length, and user_data = the message sequence number.

// gtq-cuda/kernels/gtq_sq.cuh (simplified)
bool reserve() {                         // is there a free SQ slot?
  if (tail - cached_head < entries) return true;      // cheap: no PCIe read
  while (tail - (cached_head = load_acquire(khead)) >= entries) {
    __threadfence_system();
    maybe_request_wakeup();              // a sleeping SQPOLL never frees space
  }
  return true;
}
void write_sqe(const gtq_sqe& s) {       // 8 x 64-bit stores into the kernel's SQ
  for (int k = 0; k < 8; k++) sqes[tail & mask].word[k] = s.word[k];
}
void publish(const gtq_sqe& s) {         // simple version: ONE release store
  write_sqe(s); ++tail;
  store_release(ktail, tail);            // SQE (+ payload) visible before the tail
  after_publish();
}
void stage(const gtq_sqe& s) {           // pre-staging: done BEFORE the request arrives
  write_sqe(s); __threadfence_system();
}
void publish_staged() {                  // the critical path: one relaxed store
  ++tail; store_relaxed(ktail, tail);    // ordered by the fence in stage()
  after_publish();                       // wake-up check, off the critical path
}

Tricks in there worth knowing:

  • Never read host memory unless forced. Every read of host memory is a PCIe round trip (~0.8 µs), so the GPU keeps a cached copy of the kernel’s head and re-reads it only when the queue looks full. Statistics are kept in registers and only ever written to host memory.
  • Fun fact: 64-bit % by a runtime value is emulated on the GPU and costs hundreds of cycles, so slot numbers use 32-bit remainders.
  • Batching (streaming): push() writes several SQEs, then commit() publishes all of them with one tail store.

4. Memory ordering, at the instruction level

We use cuda::atomic_ref<…, thread_scope_system>. System scope matters: a normal __threadfence() only orders writes for other GPU threads, but the reader here is the Linux kernel on the CPU, across PCIe. A system-scope release store or __threadfence_system() compiles to a MEMBAR.SYS, which makes all earlier writes visible system-wide.

Why ~0.9 µs per barrier: the GPU has to drain its outstanding writes across PCIe before continuing. We measured that each system barrier costs about 0.9 µs as seen by a polling CPU, regardless of how many writes are pending, while the SQE stores themselves are nearly free. That’s why the design is built around barrier count: the first version used two barriers and was 1.1 µs slower than the relays; pre-staging moved the only barrier off the critical path.

Why a relaxed tail store is safe after staging: the fence in stage() already ordered the SQE before anything that follows. The send buffer itself was written by the CPU before it rang the doorbell, and x86 keeps the CPU’s stores in order (TSO), so the data is visible by then. For GPU-generated payloads (written after staging), publish_staged(release = true) uses a release store instead.

The missed-wake-up race: after storing the tail, the GPU checks NEED_WAKEUP. Without a fence between “store tail” and “load flags”, the GPU could read “awake” while the kernel is going to sleep, and both would miss each other (the classic store-buffer pattern). The fence in after_publish() pairs with the kernel’s own memory barrier when it sets the flag.

The BAR ordering bug, explained: the CPU writes the doorbell and a mirror copy of the packet into GPU memory through the BAR window, and that path does not keep writes to different addresses in order (we observed it under load). So a GPU-local mirror copy of the packet (used to make the checksum fast) could arrive after its doorbell. Fix: if the mirror’s checksum doesn’t match, the GPU re-checks the host copy (which is ordered correctly) before ever declining a send. Test failures went from 1/12 to 0/132.

5. The doorbell

The CPU publishes a packed 16-byte descriptor {doorbell, len, sum32} in GPU memory: it writes len and the checksum first, then the doorbell (= sequence number + 1, or all-ones to stop the kernel). The GPU’s lane 0 reads all 16 bytes in one load (two dependent loads would be a second round trip), then __syncwarp() so all 32 lanes read the packet only after the doorbell. The warp computes a checksum of the packet and compares it with sum32: that’s the “GPU work” standing in for “a result is ready”.

6. Waking SQPOLL

// GPU side (gtq_sq.cuh, simplified)
void maybe_request_wakeup() {
  if (!(load_acquire(kflags) & IORING_SQ_NEED_WAKEUP)) return;   // awake: nothing to do
  uint32_t req = wake_req;
  if (load_acquire(&wake_served) == req)                      // only one request outstanding
    store_release(&wake_req, req + 1);
}
// CPU side (gtq-uring Waker): sees wake_req != wake_served, then
io_uring_enter(fd, 0, 0, IORING_ENTER_SQ_WAKEUP);   // the syscall the GPU can't make
// ...waits (bounded) until the kernel clears NEED_WAKEUP, then wake_served = req

Waiting for the flag to clear stops the GPU from firing a storm of duplicate wake requests. An alternative mode has a CPU thread watch NEED_WAKEUP directly instead of the GPU checking it; in streaming that was worth +50% throughput because it removed PCIe reads from the GPU’s loop.

7. Completions and buffer ownership

  • The CPU reaps CQEs. Each one’s user_data is the sequence number, and its result must equal the length sent.
  • It then overwrites the freed slot with the poison byte 0xDD. If anything ever sends a buffer that was already freed, the receiver sees 16 bytes of 0xDD and flags it as corrupt.
  • It advances a single counter, completed, but only over the contiguous prefix of finished messages, so an out-of-order CQE can’t free a buffer early.
  • The GPU may reuse the slot of message m only when completed + nslots > m. It caches completed and re-reads it only when it must (“cgate”, +23% stream throughput), instead of reading a flag per message.
  • The kernel copies the payload into its own socket buffer during udp_sendmsg, so once the CQE arrives our buffer really is free.

8. GPU-generated payloads and the stream protocol

  • Payload: each 8-byte word is splitmix64 of the sequence number and word index. Deterministic, so the receiver recomputes and compares every byte without the data being sent twice.
  • Block-parallel generator: one warp per message (up to 1024 threads per block). Each warp writes its message, __syncwarp(), then one lane releases and publishes. +65% throughput over one warp doing everything.
  • Flow control: the receiver replies with a cumulative ACK every K datagrams; the sender never has more than a window of messages in flight. The receive-overflow bug was this window being bigger than the receiver’s buffer.
  • GSO: the payloads of a run sit back to back in one buffer, the socket is told the datagram size once (setsockopt UDP_SEGMENT), and a single ordinary SEND SQE covers the whole run. The kernel cuts it into up to 32 datagrams, which cut the per-datagram cost (2.7×). GRO: the receiver gets up to 64 coalesced datagrams per receive (+22%).
  • A request with sequence number all-ones is the stop signal.

9. QUIC integration

In transport.rs the CPU owns a quiche Connection. For each request it calls conn.send() straight into the send slot, producing one protected 1-RTT datagram (1350 bytes), then rings the doorbell. The GPU checks and submits it like any UDP payload. If the GPU declines a packet (the safety test), the datagram never leaves; quiche’s own loss detection notices and retransmits the data in a brand-new packet with a new packet number and fresh encryption. Nothing is replayed, and quiche itself is unmodified.

10. Measurement internals

  • One-way timing: the GPU reads %globaltimer when it sees the doorbell and right after the tail store. A calibration kernel ping-pongs through pinned memory 2000 times before and after each run; the offset comes from the fastest 10% of round trips (≥0.79 µs) and is interpolated per request, because the GPU timer drifts ~90 ppm. It ticks every 1024 ns, so segments are trimmed means (requests aren’t synchronized to the ticks, so this is unbiased). The receiver uses the kernel’s RX timestamp (SO_TIMESTAMPNS).
  • CPU cost: per-thread CPU time ÷ wall time, plus system-wide /proc/stat, plus SQPOLL’s own accounting from /proc/self/fdinfo (newer kernels report its busy time).
  • Power: GPU power and energy through NVML; CPU package energy through RAPL (needed read permission once).
  • Mann–Whitney U: a rank test with no normality assumption. GPU-direct beat the relay in all 10 vs 10 repetitions (U = 0), which gives p ≈ 1.8×10⁻⁴ with the normal approximation. Bootstrap CIs resample the repetitions to put error bars on medians.
  • Open loop: request times follow a Poisson schedule; the driver spin-waits to each scheduled time (sleeping added jitter), and latency counts from the scheduled time, so a slow request also delays the ones queued behind it (no “coordinated omission”).
  • Fairness across streams: Jain’s index = (Σx)² / (n·Σx²); 1.0 means perfectly equal.
  • Green contexts: cuDevSmResourceSplitByCount splits the SMs, cuGreenCtxCreate makes a context on the 2-SM part, and the sender’s stream is created in it, so compute kernels physically can’t land on the sender’s SMs.

11. Hard questions, with answers

Why system scope and not a normal __threadfence()?

Device scope only orders writes as seen by other GPU threads. The reader is the Linux kernel on the CPU, across PCIe, so we need system scope (a MEMBAR.SYS). Without it the kernel can see the tail before the SQE.

Why is the last store relaxed instead of release, and still safe?

The SQE was written and fenced ahead of time in stage(), and the CPU-written payload was already ordered by x86 TSO before the doorbell the GPU acquired. So nothing new needs ordering at publish time. For GPU-written payloads we switch to a release store.

What happens if the submission queue fills up?

reserve() spins re-reading the kernel’s head, and requests a wake-up each time (a sleeping SQPOLL never frees space). We stress-tested this with deliberately tiny rings to force backpressure.

Can several GPU threads publish to one ring?

Not in our design: one producer per ring, so the tail is never contended. Multiple streams use multiple rings, which can still share one SQPOLL thread via ATTACH_WQ.

Why doesn’t the GPU read the completion queue itself?

Every read of host memory is a PCIe round trip. The CPU reaps CQEs cheaply and publishes one counter; the GPU caches it and only re-reads when it needs a buffer back.

Where does the kernel get the packet bytes from?

The SQE holds the host address of the send buffer in pinned memory. During udp_sendmsg the kernel copies it into a socket buffer, then posts the CQE. After that our buffer can be reused.

Why does the doorbell live in GPU memory?

The GPU polls the doorbell constantly. In GPU memory each poll is a fast local read; in host memory each poll would cross PCIe. The CPU writes it once per request through the BAR window.

Why did putting SQPOLL on the other chiplet make GPU-direct slower than the relay?

SQPOLL runs the whole kernel send, touching socket and buffer cache lines that the app and receiver also touch. Across chiplets those lines bounce over the interconnect (+3.0 µs for SQPOLL vs +1.7 µs for a relay that only makes a syscall), so GPU-direct ends up +0.74 µs behind.

Why does SQPOLL use a full core even when it’s barely working?

It busy-polls the tail until sq_thread_idle passes with no work, then sleeps. Under steady traffic that timeout never expires, so it spins at 100% while doing ≤27% useful work.

Why can a CUDA launch deadlock next to the persistent kernel?

With lazy module loading, the first launch of a new kernel loads its module, which waits for running kernels to drain. Ours never finishes, so the launch waits forever. cudaMalloc/cudaFree can block the same way. Fix: load and allocate everything before starting.

How do you know your timestamps don’t change the result?

With timestamps on, RR p50 was 9.02 µs vs 9.09 µs without: no measurable effect. And the GPU’s publish timestamp is taken right after the tail store, off the critical path.

What exactly do the negative controls disable?

Fault flags passed to the GPU kernel (zero in normal runs): NO_FENCE (tail store without ordering: 10/22 runs corrupt), NO_TAIL (SQE written but never published: deterministic failure), and skipping the buffer-ownership gate (deterministic failure). Plus removing the payload release (5/23 corrupt).

Is the zero-error claim statistically meaningful?

Over the final campaign’s 139.4M request–responses, zero errors gives a 95% upper bound on the error rate below 2.2×10⁻⁸ (the “rule of three”: 3/n).

Why can’t GPU-direct trade latency for CPU like a sleeping relay?

SQPOLL’s shortest idle timeout is 1 ms; it only sleeps after that long without work. A user relay can sleep for microseconds between polls. That’s why for bursty traffic (gaps ≫ 1 ms) GPU-direct wins big, and for steady traffic it can’t.

What would change on a GH200 (cache-coherent CPU–GPU)?

The expensive parts are PCIe visibility: system fences, round trips, BAR ordering. A coherent link could make those much cheaper, which might make the GPU-direct gain larger. We planned to test it but couldn’t get io_uring on the cluster.