mirror of https://github.com/openXC7/prjxray.git
Fix PR #507: Merged last run in the pool
Signed-off-by: Mehdi Khairy <mehdi.khairy@more-magic.org>
This commit is contained in:
parent
0168578b5a
commit
0906e734b9
|
|
@ -4,10 +4,19 @@ import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
|
# Can be used to redirect vivado tons of output
|
||||||
|
# stdout=DEVNULL in subprocess.check_call
|
||||||
|
#try:
|
||||||
|
# from subprocess import DEVNULL
|
||||||
|
#except ImportError:
|
||||||
|
# import os
|
||||||
|
# DEVNULL = open(os.devnull, 'wb')
|
||||||
|
|
||||||
|
|
||||||
|
# Worker function called from threads
|
||||||
def start_vivado(argList):
|
def start_vivado(argList):
|
||||||
print(argList)
|
|
||||||
blockID, start, stop = argList
|
blockID, start, stop = argList
|
||||||
print("Running instance :" + str(blockID))
|
print("Running instance :" + str(blockID))
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
|
|
@ -16,8 +25,9 @@ def start_vivado(argList):
|
||||||
shell=True)
|
shell=True)
|
||||||
|
|
||||||
|
|
||||||
|
# Function called once to get the total numbers of pips to list
|
||||||
def get_nb_pips():
|
def get_nb_pips():
|
||||||
print("Fetching nb pips")
|
print("Fetching total number of pips")
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
"${XRAY_VIVADO} -mode batch -source $FUZDIR/get_pipscount.tcl",
|
"${XRAY_VIVADO} -mode batch -source $FUZDIR/get_pipscount.tcl",
|
||||||
shell=True)
|
shell=True)
|
||||||
|
|
@ -31,12 +41,14 @@ def main(argv):
|
||||||
|
|
||||||
pipscount = get_nb_pips()
|
pipscount = get_nb_pips()
|
||||||
blocksize = int(pipscount / nbBlocks)
|
blocksize = int(pipscount / nbBlocks)
|
||||||
|
intPipsCount = blocksize * nbBlocks
|
||||||
|
|
||||||
# We handle the case of not integer multiple of pips
|
# We handle the case of not integer multiple of pips
|
||||||
lastRun = False
|
lastRun = False
|
||||||
modBlocks = pipscount % nbBlocks
|
modBlocks = pipscount % nbBlocks
|
||||||
if modBlocks != 0:
|
if modBlocks != 0:
|
||||||
lastRun = True
|
lastRun = True
|
||||||
|
nbBlocks = nbBlocks + 1
|
||||||
|
|
||||||
if not os.path.exists("wires"):
|
if not os.path.exists("wires"):
|
||||||
os.mkdir("wires")
|
os.mkdir("wires")
|
||||||
|
|
@ -48,22 +60,20 @@ def main(argv):
|
||||||
str(modBlocks))
|
str(modBlocks))
|
||||||
|
|
||||||
blockId = range(0, nbBlocks)
|
blockId = range(0, nbBlocks)
|
||||||
startI = range(0, pipscount, blocksize)
|
startI = range(0, intPipsCount, blocksize)
|
||||||
stopI = range(blocksize, pipscount + 1, blocksize)
|
stopI = range(blocksize, intPipsCount + 1, blocksize)
|
||||||
|
|
||||||
|
# In case we have a last incomplete block we add it as a last
|
||||||
|
# element in the arguments list
|
||||||
|
if lastRun == True:
|
||||||
|
startI = chain(startI, [intPipsCount])
|
||||||
|
stopI = chain(stopI, [pipscount])
|
||||||
|
|
||||||
argList = zip(blockId, startI, stopI)
|
argList = zip(blockId, startI, stopI)
|
||||||
|
|
||||||
with Pool(processes=nbParBlock) as pool:
|
with Pool(processes=nbParBlock) as pool:
|
||||||
pool.map(start_vivado, argList)
|
pool.map(start_vivado, argList)
|
||||||
|
|
||||||
if modBlocks != 0:
|
|
||||||
print("Caculate extra block")
|
|
||||||
start = nbBlocks * blocksize
|
|
||||||
stop = pipscount
|
|
||||||
bID = nbBlocks
|
|
||||||
start_vivado((bID, start, stop))
|
|
||||||
nbBlocks = nbBlocks + 1
|
|
||||||
|
|
||||||
print("Generating final files")
|
print("Generating final files")
|
||||||
|
|
||||||
with open("uphill_wires.txt", "w") as wfd:
|
with open("uphill_wires.txt", "w") as wfd:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue