GPU spinlocks can starve writers if readers continuously arrive. Solution: writer preference flag.
Idea: Each warp elects a leader. The leader acquires a global reader slot; other threads in warp just increment a shared-memory warp-local count.
Data structures:
Algorithm (reader):
__syncwarp(); // ensure leader’s increment visibleRelease:
Writer algorithm:
Analysis: Reduces global atomic traffic from num_threads to num_warps. Reduces contention by factor ~32. nv items reader writer
When evaluating or building an NV Items Reader Writer, prioritize these advanced capabilities:
For certain NV items, reader-writer locks can be replaced with lock-free or wait-free structures. GPU spinlocks can starve writers if readers continuously