PasMP

PasMP is a cross-platform parallel-processing/multi-processing library for Object Pascal for Delphi and FreePascal

GitHub project page:

https://github.com/BeRo1985/pasmp

License:

zlib

Why:

Because System.Threading and OmniThreadLibrary are Delphi-only libraries and MTProcs has also his own problems (FreePascal-only, inefficient lock-based work-stealing, etc.) and at least System.Threading from Delphi XE7 has also a bit more inefficient work-stealing implementation.

Features:

  • Low-level-based design with optional high-level-based constructs
  • Designed for fully-strict fork-join model in mind (because it's less error-prone to work with it than with terminally-strict fork-join for my taste), but it can be also abused for more flexible models, the only important thing is, that you're releasing the jobs again as soon as they are completed (the simplest weay would be by calling TPasMP.Reset per workload-frame), otherwise you'll have memory leaks, or just use the PasMPJobFlagReleaseOnFinish flag.
  • It can be used a job scheduler for multithreaded game engines and so on
  • Work-first lock-free work-stealing dynamic-sized Chase-Lev queue/deque (where only the resizing code part of it isn't lock-free, so that on the other hand it is garbage-collector-free)
  • Lock-free job memory allocator (al least lock-free on x86-32 and x86-64 targets)
  • Parallel-for pattern
  • Parallel intro sort (direct and indirect)
  • Parellel merge sort (direct and indirect)
  • Optional strict singleton usage option per global PasMPUseAsStrictSingletonInstance define (besides the option of usage of multiple PasMP instances)
  • Compatible with FreePascal >= 2.6.x and Delphi >= 7
  • Cross platform (Windows, Linux, etc.)