From e359ab6f39ee2a3eb7327283ec033fb117dde023 Mon Sep 17 00:00:00 2001 From: Mehdi Khairy Date: Sat, 12 Jan 2019 03:02:42 +0100 Subject: [PATCH 1/2] Fixing Fuzzer 072: supporting all pips count Signed-off-by: Mehdi Khairy --- fuzzers/072-ordered_wires/run_fuzzer.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/fuzzers/072-ordered_wires/run_fuzzer.py b/fuzzers/072-ordered_wires/run_fuzzer.py index a88a220d..7d04cbb8 100644 --- a/fuzzers/072-ordered_wires/run_fuzzer.py +++ b/fuzzers/072-ordered_wires/run_fuzzer.py @@ -32,13 +32,20 @@ def main(argv): pipscount = get_nb_pips() blocksize = int(pipscount / nbBlocks) + # We handle the case of not integer multiple of pips + lastRun = False + modBlocks = pipscount % nbBlocks + if modBlocks != 0: + lastRun = True + if not os.path.exists("wires"): os.mkdir("wires") print( "Pips Count: " + str(pipscount) + " - Number of blocks: " + str(nbBlocks) + " - Parallel blocks: " + str(nbParBlock) + - " - Blocksize: " + str(blocksize)) + " - Blocksize: " + str(blocksize) + " - Modulo Blocks: " + + str(modBlocks)) blockId = range(0, nbBlocks) startI = range(0, pipscount, blocksize) @@ -49,6 +56,14 @@ def main(argv): with Pool(processes=nbParBlock) as pool: 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") with open("uphill_wires.txt", "w") as wfd: From 0906e734b91cd4e003cf0a3e557b6b008a284b00 Mon Sep 17 00:00:00 2001 From: Mehdi Khairy Date: Sat, 12 Jan 2019 12:27:35 +0100 Subject: [PATCH 2/2] Fix PR #507: Merged last run in the pool Signed-off-by: Mehdi Khairy --- fuzzers/072-ordered_wires/run_fuzzer.py | 34 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/fuzzers/072-ordered_wires/run_fuzzer.py b/fuzzers/072-ordered_wires/run_fuzzer.py index 7d04cbb8..5c5393af 100644 --- a/fuzzers/072-ordered_wires/run_fuzzer.py +++ b/fuzzers/072-ordered_wires/run_fuzzer.py @@ -4,10 +4,19 @@ import sys import subprocess import signal 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): - print(argList) blockID, start, stop = argList print("Running instance :" + str(blockID)) subprocess.check_call( @@ -16,8 +25,9 @@ def start_vivado(argList): shell=True) +# Function called once to get the total numbers of pips to list def get_nb_pips(): - print("Fetching nb pips") + print("Fetching total number of pips") subprocess.check_call( "${XRAY_VIVADO} -mode batch -source $FUZDIR/get_pipscount.tcl", shell=True) @@ -31,12 +41,14 @@ def main(argv): pipscount = get_nb_pips() blocksize = int(pipscount / nbBlocks) + intPipsCount = blocksize * nbBlocks # We handle the case of not integer multiple of pips lastRun = False modBlocks = pipscount % nbBlocks if modBlocks != 0: lastRun = True + nbBlocks = nbBlocks + 1 if not os.path.exists("wires"): os.mkdir("wires") @@ -48,22 +60,20 @@ def main(argv): str(modBlocks)) blockId = range(0, nbBlocks) - startI = range(0, pipscount, blocksize) - stopI = range(blocksize, pipscount + 1, blocksize) + startI = range(0, intPipsCount, 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) with Pool(processes=nbParBlock) as pool: 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") with open("uphill_wires.txt", "w") as wfd: