commit 7a9718930d462cdc3f07467bfde1422f702927b8 Author: Krystian Wasilewski Date: Sat Dec 3 16:01:11 2022 +0100 init diff --git a/computeC b/computeC new file mode 100644 index 0000000..9e27036 Binary files /dev/null and b/computeC differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..6b9aa8f --- /dev/null +++ b/main.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +from multiprocessing import cpu_count +import urllib.request +import json +import subprocess +import time +import sys + + +cores = cpu_count() +index = 444501 +url = f'https://bikol.vm.wmi.amu.edu.pl/pzc/Z3.3/{index}' +sigma = json.loads(urllib.request.urlopen(url).read(100).decode('utf-8'))['sigma'] +bracket = 280 # needs 36 processes +START = int(sys.argv[1]) +FINISH = START+cores +MAX_VAL = 10000 +procs = [] + +for i in range(START, FINISH): + a = bracket*i + 1 + b = bracket*(i+1) + + if b > MAX_VAL: + b = MAX_VAL + + procs.append(subprocess.Popen(['./computeC', str(a), str(b), str(sigma)])) + + if b == MAX_VAL: + break + +# print(f"{FINISH-START} processes; [{bracket*START + 1}-{min(MAX_VAL,bracket*FINISH)}]") +# +# start = time.time() +# while any(i is None for i in [p.poll() for p in procs]): +# now = time.time() +# print(round((now - start), 2), end='\r')