Any good solutions for parallelism?

Hello. Can you point me in the right direction to look for good solution to my problem.
I want to paralellize some small tasks. I tried to look into concurrent/2 or /3, but it appears to create new threads upon each call. Thread creating is really expensive operation so it is not good to parallelise small tasks. Is there library than can do the same thing, but use Thread Pools instead to optimize things?

Ideally I’am looking for Prolog equivalent of PLINQ - Parallel LINQ from C# language.

I can not find concurrent/2 but do find concurrent/3.


Did you try concurrent_forall/3?

Here is an example usage:

IIRC concurrent_forall/3 uses a thread pool, check the code as the documentation may not reflect all of the details.

1 Like

Yeah, I’ve looked into the code, it appears to create new threads for each invocation. For my scenario it is too expensive. Maybe I’ll make modified version that uses thread pool.