Skip to content

trolando/lace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

288 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lace

Linux macOS Windows License: Apache

Lace is a C framework for fine-grained fork-join parallelism on multi-core computers.

TASK_1(int, fibonacci, int, n)  // declare a Lace task (place in header or source)

int fibonacci_CALL(lace_worker* lw, int n) {
    if (n < 2) return n;
    fibonacci_SPAWN(lw, n-1);         // fork: push task onto deque
    int a = fibonacci_CALL(lw, n-2);  // run another instance directly
    int b = fibonacci_SYNC(lw);       // join: retrieve result of spawned task
    return a + b;
}

int main(int argc, char** argv)
{
    lace_start(0, 0, 0);              // 0 = auto-detect cores, default deque, default stack
    int result = fibonacci(42);
    printf("fibonacci(42) = %d\n", result);
    lace_stop();
}

Full documentation — user guide, API reference, and benchmarks.

Features

  • ⚡ Low-overhead, lock-free work-stealing
  • 💤 Sleeps when idle (exponential backoff) to save CPU time
  • 📌 Optional thread pinning with hwloc
  • 📈 Low-overhead statistics per worker
  • ⛔ Interrupt support for coordinating all workers to a safe point (e.g. stop-the-world GC)

Lace uses a scalable double-ended queue for work-stealing. The owner thread pushes and pops tasks from its own deque in a wait-free manner. Thief threads steal from the other end in a lock-free manner. The design minimizes cache line contention between workers.

Platform support

  • 🐧 Linux (GCC, Clang)
  • 🪟 Windows (MSVC, MSYS2/MinGW)
  • 🍎 macOS (Apple Clang)

Quick start

cmake -B build
cmake --build build

Integrate into your project with CMake:

add_subdirectory(external/lace)
target_link_libraries(my_app PRIVATE lace::lace)

Or fetch automatically:

if(NOT TARGET lace::lace)
  find_package(lace 2.2.1 CONFIG QUIET)
  if(NOT lace_FOUND)
    include(FetchContent)
    FetchContent_Declare(lace
        GIT_REPOSITORY https://github.com/trolando/lace.git
        GIT_TAG        v2.2.1
        GIT_SHALLOW    TRUE
    )
    FetchContent_MakeAvailable(lace)
  endif()
endif()

See the documentation for CMake options, configuration recommendations, task variants, and the full API reference.

Academic publications

If you use Lace in your research, please cite:

T. van Dijk and J.C. van de Pol (2014) Lace: Non-blocking Split Deque for Work-Stealing. In: Euro-Par 2014: Parallel Processing Workshops. LNCS 8806, Springer.

T. van Dijk (2016) Sylvan: Multi-core Decision Diagrams. PhD Thesis, University of Twente.

License

Lace is licensed under the Apache 2.0 license.

About

Lace - implementation of work-stealing in C

Resources

License

Stars

Watchers

Forks

Packages