Suggestion to stop long operations
Décio Luiz Gazzoni Filho
decio at decpp.net
Sat Nov 19 15:28:09 UTC 2016
> On Nov 18, 2016, at 8:19 PM, Pierre Chatelier <pierre at chachatelier.fr> wrote:
> While playing with mpz_probab_prime_p(), I noticed that comptation times could be very long for serious numbers (like 6917!-1, which is a "small" prime in some sense, regarding https://primes.utm.edu/largest.html)
> I think it could be valuable to be able to stop such computations if it takes too long.
> By just adding a volatile member to the mpz_t struct, it could be possible to signal a stop request from another thread. That field could be inspected and taken in account by the expensive algorithms, in some loop iterations.
> This approach would not break existing code and API, and would only require the expensive functions to monitor that field. Other functions could just ignore it.
> What do you think ? would it be a problem to change the size of mpz_t ?
My opinion is that it would be very poor software engineering practice, as regards separation of concerns.
If such a feature is important to you, just realize that you’re free to reimplement your own version of mpz_probab_prime_p() that works this way. Using mpz_powm(), it would probably take less than one hour to design, code and test.
More information about the gmp-discuss