36 lines
770 B
Python
36 lines
770 B
Python
#!/usr/bin/env python3
|
|
from multiprocessing import cpu_count
|
|
import urllib.request
|
|
import json
|
|
import subprocess
|
|
import time
|
|
import sys
|
|
|
|
|
|
cores = cpu_count()
|
|
bracket = 280 # needs 36 processes
|
|
START = int(sys.argv[1])
|
|
sigma = int(sys.argv[2])
|
|
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')
|