University of Limerick
Browse

Compiler support for lightweight context switching

Download (466.47 kB)
journal contribution
posted on 2013-02-28, 15:08 authored by Stephen Dolan, Servesh Muralidharan, David Gregg
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 SWAPSTACK, can be used by any language implementation based on LLVM to build higher-level language structures such as continuations, co-routines, 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.

Funding

A new method for transforming data to normality with application to density estimation

National Research Foundation

Find out more...

History

Publication

ACM Transactions on Architecture and Code Optimization;9(4), article no. 36

Publisher

Association for Computing Machinery

Note

peer-reviewed

Other Funding information

IBM, SFI, IRCSET

Rights

"© ACM, 2013. This is the author's version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in ACM Transactions on Architecture and Code Optimizatio http://dx.doi.org/10.1145/2400682.2400695

Language

English

Usage metrics

    University of Limerick

    Categories

    No categories selected

    Exports

    RefWorks
    BibTeX
    Ref. manager
    Endnote
    DataCite
    NLM
    DC