Go under the hood
Go: Under the Hood

Chapter 18 GPU and Heterogeneous Compute

This chapter is the mechanical foundation of the part. The GPU is the most typical form of heterogeneous compute: a device with its own memory, its own execution model, and its own scheduling logic, hanging alongside the host and connected to Go by a single FFI boundary. We begin from that boundary, watching how a cgo call leaves Go’s stack and enters the driver; then we watch how the runtime faces a block it can neither preempt nor measure; next we draw the line between device memory and the Go heap, working out why the collector must not touch device memory and yet threatens the host memory handed across; and finally we return to the concurrency model itself, to see how the GPU’s asynchrony meets the concurrency of goroutines.