SetReplace
SetReplace copied to clipboard
Parallelize nondeterministic WolframModel on CPU
Requires #351.
The problem
The other CPU issue #155 attempts to parallelize WolframModel
without changing functionality. However, this limits our ability to parallelize because one has to make sure to evaluate the events in a certain order. In this issue, we drop that requirement and parallelize it with the goal of obtaining the result for any ordering. The output can even change each time we run WolframModel
.
Note, this is not as bad as it sounds because once we have #146 and if the system we are running is a local multiway or a causal invariant system, the evaluation order does not matter.
Possible solution
Each thread could simply:
- Pick a match from the queue.
- Compute the outputs and index them for new matches.
One needs to be careful here to ensure matches are not lost/computed incorrectly because some edges got deleted/added simultaneously in a different thread.
Additional context
This issue is for CPU parallelization specifically. There is a similar one for GPUs (TODO: add issue) and distributed systems (TODO: add issue).