maxitg / SetReplace

C++/Wolfram Language package for exploring set and graph rewriting systems
MIT License
219 stars 45 forks source link

Parallelize deterministic WolframModel on CPU #155

Open maxitg opened 4 years ago

maxitg commented 4 years ago

The problem

Currently, WolframModel and related functions are always running sequentially.

While it might be tricky to parallelize the symbolic code, it should be reasonably straightforward to parallelize the C++ code.

This issue specifically is for CPU parallelization for a specific "EventOrderingFunction", i.e., it should not change the output of WolframModel in any way. There is another issue (TODO: add issue) for parallelizing undefined-order evolution. There are also separate issues for GPU (TODO: add issue) and distributed (TODO: add issue) implementations.

Possible solution

As a first step, one can consider doing sub-event parallelization, i.e., indexing the last event outputs in multiple threads.

Additional context

Alternatively, for some "EventOrderingFunction"s one can pre-evaluate multiple matches at once, keep a queue of finished evaluations (including post-event indexing), and have a master process which would apply matches from that queue in the order specified by the ordering function (and discarding ones that happen to overlap). This might potentially waste computation, but will allow for much better parallelization in some systems. These two approaches could be combined, as they would work best for different kinds of systems.

Subtasks

justinjdickow commented 4 years ago

Any progress here? GPU support seems like a must have

maxitg commented 4 years ago

@justinjdickow, there is some progress in CPP_Multithread_Rules, which is WIP, but that only works for multi-rule case. This issue is going to be for CPU parallelization specifically, the issue for GPUs is #353.