init
This commit is contained in:
commit
7a9718930d
37
main.py
Normal file
37
main.py
Normal 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')
|
Loading…
Reference in New Issue
Block a user