unified memory
**Unified memory** is the **shared virtual memory model that allows CPU and GPU to access a single logical address space** - it simplifies programming by automating page migration, but performance depends heavily on access locality.
**What Is Unified memory?**
- **Definition**: Managed memory system where runtime migrates pages between host and device memory on demand.
- **Ease-of-Use Benefit**: Developers can avoid manual memcpy choreography for many workflows.
- **Migration Behavior**: Page faults trigger data movement over interconnect such as PCIe or NVLink.
- **Risk**: Poor locality can cause page thrashing and severe slowdown under repeated bidirectional access.
**Why Unified memory Matters**
- **Development Productivity**: Reduces complexity for prototypes and irregular data-structure workloads.
- **Memory Flexibility**: Can handle datasets larger than device memory through managed paging.
- **Portability**: Unified programming model simplifies code maintenance across hardware tiers.
- **Operational Simplicity**: Fewer explicit transfer paths reduce integration bugs.
- **Selective Utility**: Useful in targeted scenarios where convenience outweighs migration overhead.
**How It Is Used in Practice**
- **Access Pattern Planning**: Design for locality so most accesses occur from one processor side at a time.
- **Prefetch Hints**: Use managed-memory prefetch APIs to move pages before compute phases.
- **Profiling**: Track page-fault counters and migration volume to catch thrashing early.
Unified memory is **a productivity-focused memory model with locality-dependent performance** - when migration behavior is managed carefully, it can simplify complex host-device workflows.