Introduction: The Dilemma of Legacy Scientific Code
High-performance scientific computing often relies on massive, legacy codebases that were never designed for modern, modular "plug-and-play" environments. As researchers move toward complex Problem Solving Environments (PSEs)—where different solvers and models are linked together—they face a fundamental software engineering dilemma between two traditional execution models.
In the Threads Model, multiple execution flows share the same memory space. While fast, it is disastrous for legacy code using global variables, as different components inadvertently overwrite each other's data. Conversely, the Processes Model runs each component in an isolated memory space. While safe, it incurs massive overhead for communication and context switching, making it unscalable for simulations involving hundreds of interfaces.
The authors identify a need for "selective state sharing"—a way to keep global variables separate for independent solvers while allowing them to share state through a "mediator" component, all without rewriting the original source code.
The Weaves Framework
To bridge this gap, the authors introduce Weaves, a framework built on a hierarchy of abstractions:
- Modules: Compiled object files.
- Beads: Specific instantiations of a module.
- Weaves: A collection of "data contexts" (global variables) belonging to different beads.
- Strings: Execution flows (similar to threads) that operate within a specific weave.
The technical innovation lies in how Weaves handles the Global Offset Table (GOT) within ELF (Executable and Linking Format) files. On Linux/x86 systems, position-independent code uses a base register (like %ebx) to point to the GOT, which contains pointers to global variables. Weaves intercepts this mechanism by creating multiple GOTs—one for each "weave"—and swapping the base register during a context switch. This allows the system to switch between entirely different sets of global variables in a single CPU instruction, making a "weave" context switch as fast as a standard thread context switch.
Selective State Sharing and the Inverted Tree
A core insight of the Weaves project is that multiple namespaces (sets of global variables) can coexist within a single address space. This decouples execution from data scoping. Most scientific compositions follow an "inverted tree" structure where solvers at the top are isolated but converge on shared mediators or OS resources at the bottom.
Weaves is optimized for this natural flow of scientific computation. Because it operates at the binary level (ELF files), it is truly transparent. A scientist can take a 20-year-old Fortran 77 code and "weave" it into a modern simulation without touching a single line of the original source code.
Performance and Scalability
The framework was evaluated using Sweep3D (a standard benchmark for 3D neutron transport) and Sullivan’s Benchmark (a communication-heavy test) on hardware ranging from single-processor workstations to a 200-processor cluster named "Anantham."
Key results include:
- Performance: In head-to-head tests, the execution time for Weaves was nearly identical to standard pthreads and significantly faster than the "process" model using
fork(). - Scalability: The authors successfully ran Sweep3D with over 1,000 virtual machines (weaves) on a single processor.
- Accuracy: When simulating a 150-processor run on a single machine, the timing results from the Weaves implementation matched actual cluster runs to within 0.2%. This proves that the framework can be used to create highly accurate performance models of massive systems on modest hardware.
Conclusion
While the current prototype is specifically implemented for Intel x86 architectures and the Linux ELF format, it demonstrates a powerful path forward for scientific computing. By manipulating symbol tables at runtime, Weaves provides the isolation of the "processes" model with the high performance and low overhead of the "threads" model. Future work may include "string migration" for dynamic load balancing and transparent checkpointing of complex, multi-component simulations.
Summary updated