Affiliation:
1. Trinity College Dublin, Ireland
2. Lero, Trinity College Dublin, Ireland
Abstract
We propose a new language-neutral primitive for the LLVM compiler, which provides efficient context switching and message passing between lightweight threads of control. The primitive, called S
wapstack
, can be used by any language implementation based on LLVM to build higher-level language structures such as continuations, coroutines, and lightweight threads. As part of adding the primitives to LLVM, we have also added compiler support for passing parameters across context switches. Our modified LLVM compiler produces highly efficient code through a combination of exposing the context switching code to existing compiler optimizations, and adding novel compiler optimizations to further reduce the cost of context switches. To demonstrate the generality and efficiency of our primitives, we add one-shot continuations to C++, and provide a simple fiber library that allows millions of fibers to run on multiple cores, with a work-stealing scheduler and fast inter-fiber sychronization. We argue that compiler-supported lightweight context switching can be significantly faster than using a library to switch between contexts, and provide experimental evidence to support the position.
Funder
Science Foundation Ireland
Publisher
Association for Computing Machinery (ACM)
Subject
Hardware and Architecture,Information Systems,Software
Cited by
9 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Out of Hand for Hardware? Within Reach for Software!;Proceedings of the 19th Workshop on Hot Topics in Operating Systems;2023-06-22
2. CPU-free Computing: A Vision with a Blueprint;Proceedings of the 19th Workshop on Hot Topics in Operating Systems;2023-06-22
3. A Mixed PS-FCFS Policy for CPU Intensive Workloads;Proceedings of the 2022 ACM/SPEC on International Conference on Performance Engineering;2022-04-09
4. What You See Is What You Get: Practical Effect Handlers in Capability-Passing Style;Ernst Denert Award for Software Engineering 2020;2022
5. CTXBack: Enabling Low Latency GPU Context Switching via Context Flashback;2021 IEEE International Parallel and Distributed Processing Symposium (IPDPS);2021-05