From a085850a2c2b3f690828e1277a673df335dec72c Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 17 Sep 2019 11:18:04 +0100 Subject: [PATCH] amicable.sage: add --sequential option. Signed-off-by: Daira Hopwood --- amicable.sage | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/amicable.sage b/amicable.sage index b74e9d9..9b3cd71 100644 --- a/amicable.sage +++ b/amicable.sage @@ -5,9 +5,6 @@ from traceback import print_exc from math import ceil from itertools import combinations -#PROCESSES = 1 -PROCESSES = None # auto-detect - # Let Ep/Fp : y^2 = x^3 + bp # Let Eq/Fq : y^2 = x^3 + bq @@ -153,18 +150,19 @@ def format_weight(x, detail=True): def main(): - strategy = near_powerof2_order if "--nearpowerof2" in sys.argv[1:] else low_hamming_order - args = [arg for arg in sys.argv[1:] if not arg.startswith("--")] + args = sys.argv[1:] + strategy = near_powerof2_order if "--nearpowerof2" in args else low_hamming_order + processes = 1 if "--sequential" in args else cpu_count() + args = [arg for arg in args if not arg.startswith("--")] if len(args) < 1: - print("Usage: sage amicable.sage [--nearpowerof2] [ [ [ [ 1 else DEFAULT_TWOADICITY stretch = int(args[2]) if len(args) > 2 else DEFAULT_STRETCH - processes = PROCESSES or cpu_count() print("Using %d processes." % (processes,)) pool = Pool(processes=processes)