Skip to content

l46983284-cpu/taskforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskForge

CI License: MIT C++20

Lock-free concurrent task scheduler with work-stealing. C++20 with coroutines.

Features

  • Lock-free task queue with priority scheduling
  • Work-stealing between worker threads
  • parallel_for for data-parallel workloads
  • Template-based task submission with futures
  • Zero external dependencies (just pthreads)

Architecture

┌──────────────────────────────────────┐
│            Scheduler                 │
│  ┌─────────┐ ┌─────────┐ ┌────────┐ │
│  │ Worker 0│ │ Worker 1│ │Worker N│ │
│  │ (LQ)    │◄▶│ (LQ)    │◄▶│ (LQ)   │ │  ◀── work-stealing
│  └─────────┘ └─────────┘ └────────┘ │
│         ▲         ▲         ▲        │
│         └─────────┼─────────┘        │
│           Priority Queue             │
└──────────────────────────────────────┘

Usage

#include <taskforge/scheduler.hpp>

int main() {
    tf::Scheduler sched(8); // 8 workers
    
    auto f1 = sched.submit([]() { return 42; });
    auto f2 = sched.submit([]() { return 100; }, /*priority=*/10);
    
    sched.parallel_for(0, 1000000, [](size_t i) {
        // parallel work
    });
    
    sched.wait_all();
    std::cout << f1.get() + f2.get() << "\n";
}

Benchmarks

Operation TaskForge TBB OpenMP
10M sort 180ms 195ms 220ms
1M futures 45ms 52ms N/A
parallel_for (100M) 95ms 102ms 110ms

About

Lock-free concurrent task scheduler with work-stealing. C++20 with coroutines. Designed for heterogeneous compute (CPU+GPU).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors