This commit is contained in:
Krystian Wasilewski 2022-12-03 16:01:11 +01:00
commit 7a9718930d
2 changed files with 37 additions and 0 deletions

BIN
computeC Normal file

Binary file not shown.

37
main.py Normal file
View File

@ -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')