Ruud H.G. van Tol on Fri, 20 Sep 2024 13:03:12 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: concurrent computation of a function



On 2024-09-19 16:40, Max Alekseyev wrote:
Suppose I have two functions func1(x) and func2(x) computing the same entity, where depending on the input one may be much faster than the other (or vice versa). For the same input x, I'd like to compute them in parallel and return the result as soon as one of them completes, and terminate execution of the other.
Is there a way to achieve this in PARI/GP?

PS. Here are possible solutions for SageMath/Python: https://ask.sagemath.org/question/59480/

In some cases you could effectively use a "stopfile", or some other global resource.

Each variant then has to check for its existence-or-state, at key points in its iterations, and can then stop gracefully.

-- Ruud