# Parallelizing goal matching

**URL:** <https://swi-prolog.discourse.group/t/parallelizing-goal-matching/409>\
**Category:** Help!\
**Created:** [March 17, 2019, 5:08am UTC](https://swi-prolog.discourse.group/t/parallelizing-goal-matching/409 "2019-03-17T05:08:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [March 17, 2019, 5:08am UTC](https://swi-prolog.discourse.group/t/parallelizing-goal-matching/409/1 "2019-03-17T05:08:17Z")

</div>

Hello,

Is it possible to parallelize the backtracking over several goals with one deterministic answer only, to have each tested in a different thread – in the hope of a speedup of the test.

Only one would succeed

For example:

g(X, case1) :-  
test1(X), !.

g(X, case2)  
test2(X), !.

g(X, casen) :-  
testn(X), !.

thank you,

Dan

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 17, 2019, 8:16am UTC](https://swi-prolog.discourse.group/t/parallelizing-goal-matching/409/2 "2019-03-17T08:16:20Z")

</div>

Maybe this [http://www.swi-prolog.org/pldoc/doc\_for?object=thread%3Afirst\_solution/3](http://www.swi-prolog.org/pldoc/doc_for?object=thread%3Afirst_solution/3)

---

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [March 17, 2019, 10:43am UTC](https://swi-prolog.discourse.group/t/parallelizing-goal-matching/409/3 "2019-03-17T10:43:50Z")

</div>

Thank you.

This could work – I guess, I would need to create distinct goals for each case …

Dan
