DEV Community

Lucian Green
Lucian Green

Posted on

Piglog2 Concurrent Benchmarks

Necessary concurrency is faster

GitHub logo luciangreen / piglog2

Inserts concurrent where possible in Prolog

Piglog 2

Piglog 2 is a SWI-Prolog source-to-source converter that analyses ordinary Prolog code, estimates runtime costs at conversion time, and inserts direct SWI-Prolog concurrency constructs (concurrent/3, concurrent_maplist/2,3) into sufficiently expensive independent clause sections.

The generated code contains no runtime scheduler and no heuristics — concurrency decisions are made once, at conversion time, based on static analysis and user-supplied cost declarations.


Quick Start

?- use_module(piglog2).

% Print converted code for a file
?- piglog_output(file('my_program.pl')).

% Write converted code to a new file
?- piglog_write(file('my_program.pl'), 'my_program_concurrent.pl').

% Convert and immediately run
?- piglog_run(file('my_program.pl'), top_level_goal).
Enter fullscreen mode Exit fullscreen mode

Installation

Requires SWI-Prolog 8.0 or later (threaded build).

git clone https://github.com/luciangreen/piglog2.git
cd piglog2
swipl -g "use_module(piglog2), halt"   # verify it loads
Enter fullscreen mode Exit fullscreen mode

Usage

REPL Commands

Predicate Description
piglog_output(+Source) Print converted code to stdout
piglog_output(+Source, +Options) As above with options
piglog_output_file(+InputFile) Convert a .pl file and print
piglog_output_file(+InputFile, +OutputFile) Convert to a new file

Top comments (0)