$ show sandialabs/qthreads
Qthreads is a user-level threading library designed for high-performance computing (HPC) environments. It provides lightweight, stackful coroutines (qthreads) that are scheduled across 'shepherds' (groups of workers) with topology-aware affinity via hwloc. The library's core synchronization model is the full/empty bit (FEB) on every aligned word, enabling efficient producer-consumer and data-flow patterns. It includes lock-free data structures (queues, hash maps, distributed arrays), parallel loop constructs, and algorithmic skeletons (allpairs, wavefront). The codebase is heavily research-oriented, with multiple scheduler backends (nemesis, sherwood, distrib) and synchronization primitives (sincs, barriers, syncvars). While the architecture is sophisticated and demonstrates deep knowledge of parallel systems, it shows signs of academic evolution: multiple implementations of similar concepts, conditional compilation for optional lock-free paths, and some dead or incomplete code. The library is primarily targeted at HPC applications needing fine-grained task parallelism and is used in benchmarks like UTS (unbalanced tree search) and HPCCG.
The LLM identified 5 files worth highlighting for reuse:
Implements a lock-free multi-producer/multi-consumer queue (NEMESIS) used for work-stealing between workers. This is a self-contained, high-performance concurrent queue that could be extracted and reused in other parallel runtimes or libraries. It uses CAS operations and hazard pointers for safe memory reclamation.
A thread-caching memory pool allocator that provides fast allocation and deallocation of fixed-size blocks. Each thread has a local cache to reduce contention, with periodic returns to a global pool. This pattern is ideal for any concurrent application needing low-overhead memory management and is reusable with minimal adaptation.
A portable abstraction over Linux futex and other platform-specific waiting mechanisms. It provides 'wait' and 'wake' operations on atomic memory locations, enabling efficient blocking synchronization without spinloops. This header is small, self-contained, and demonstrates how to build cross-platform atomic waiting primitives.
A lock-free hash map implementation using split-ordered lists (Shavit). It supports insertion, deletion, and lookup using only CAS operations, and dynamically resizes without locks. This is a non-trivial, reusable concurrent hash map that can be extracted for use in other systems requiring lock-free associative storage.
A logarithmic barrier implementation using syncvar trees. It creates a tree of syncvar-based barriers where each node synchronizes two subtrees, achieving O(log N) time. This pattern is reusable as a building block for hierarchical synchronization in parallel applications.