From 84645e87936e97e5ecd8578ca87b466f6578f439 Mon Sep 17 00:00:00 2001 From: Mehdi Khairy Date: Fri, 11 Jan 2019 00:11:34 +0100 Subject: [PATCH] PR #489 Fix 072 Fuzzer by splitting jobs Signed-off-by: Mehdi Khairy --- fuzzers/072-ordered_wires/Makefile | 4 +- fuzzers/072-ordered_wires/generate.sh | 3 +- fuzzers/072-ordered_wires/generate.tcl | 19 ------ fuzzers/072-ordered_wires/get_pipscount.tcl | 11 ++++ fuzzers/072-ordered_wires/job.tcl | 31 +++++++++ fuzzers/072-ordered_wires/run_fuzzer.py | 71 +++++++++++++++++++++ 6 files changed, 117 insertions(+), 22 deletions(-) delete mode 100644 fuzzers/072-ordered_wires/generate.tcl create mode 100644 fuzzers/072-ordered_wires/get_pipscount.tcl create mode 100644 fuzzers/072-ordered_wires/job.tcl create mode 100644 fuzzers/072-ordered_wires/run_fuzzer.py diff --git a/fuzzers/072-ordered_wires/Makefile b/fuzzers/072-ordered_wires/Makefile index a46dd96e..b372a55f 100644 --- a/fuzzers/072-ordered_wires/Makefile +++ b/fuzzers/072-ordered_wires/Makefile @@ -1,6 +1,6 @@ N := 1 -SPECIMENS := $(addprefix specimen_,$(shell seq -f '%03.0f' $(N))) +SPECIMENS := $(addprefix build/specimen_,$(shell seq -f '%03.0f' $(N))) SPECIMENS_OK := $(addsuffix /OK,$(SPECIMENS)) database: $(SPECIMENS_OK) @@ -20,7 +20,7 @@ run: touch run.ok clean: - rm -rf specimen_[0-9][0-9][0-9]/ run.ok + rm -rf build run.ok .PHONY: database pushdb run clean diff --git a/fuzzers/072-ordered_wires/generate.sh b/fuzzers/072-ordered_wires/generate.sh index e86001fc..afac1456 100644 --- a/fuzzers/072-ordered_wires/generate.sh +++ b/fuzzers/072-ordered_wires/generate.sh @@ -2,4 +2,5 @@ source ${XRAY_GENHEADER} -${XRAY_VIVADO} -mode batch -source ../generate.tcl +python3 $FUZDIR/run_fuzzer.py + diff --git a/fuzzers/072-ordered_wires/generate.tcl b/fuzzers/072-ordered_wires/generate.tcl deleted file mode 100644 index ba33901e..00000000 --- a/fuzzers/072-ordered_wires/generate.tcl +++ /dev/null @@ -1,19 +0,0 @@ -create_project -force -part $::env(XRAY_PART) design design -set_property design_mode PinPlanning [current_fileset] -open_io_design -name io_1 - -set downhill_fp [open downhill_wires.txt w] -set uphill_fp [open uphill_wires.txt w] -#set_param tcl.collectionResultDisplayLimit 0 -foreach pip [get_pips] { - foreach downhill_node [get_nodes -downhill -of_object $pip] { - set ordered_downhill_wires [get_wires -from $pip -of_object $downhill_node] - puts $downhill_fp "$pip $downhill_node $ordered_downhill_wires" - } - foreach uphill_node [get_nodes -uphill -of_object $pip] { - set ordered_uphill_wires [get_wires -to $pip -of_object $uphill_node] - puts $uphill_fp "$pip $uphill_node $ordered_uphill_wires" - } -} -close $downhill_fp -close $uphill_fp diff --git a/fuzzers/072-ordered_wires/get_pipscount.tcl b/fuzzers/072-ordered_wires/get_pipscount.tcl new file mode 100644 index 00000000..0ec67ea4 --- /dev/null +++ b/fuzzers/072-ordered_wires/get_pipscount.tcl @@ -0,0 +1,11 @@ +create_project -force -part $::env(XRAY_PART) design design +set_property design_mode PinPlanning [current_fileset] +open_io_design -name io_1 + +#set_param tcl.collectionResultDisplayLimit 0 +set_param messaging.disableStorage 1 + +set nbpips_fp [open nb_pips.txt w] + +set pips [get_pips] +puts $nbpips_fp [llength $pips] diff --git a/fuzzers/072-ordered_wires/job.tcl b/fuzzers/072-ordered_wires/job.tcl new file mode 100644 index 00000000..a987bd78 --- /dev/null +++ b/fuzzers/072-ordered_wires/job.tcl @@ -0,0 +1,31 @@ +set blocknb [lindex $argv 0] +set start [expr int([lindex $argv 1])] +set stop [expr int([lindex $argv 2])] + +create_project -force -part $::env(XRAY_PART) $blocknb $blocknb +set_property design_mode PinPlanning [current_fileset] +open_io_design -name io_1 + +#set_param tcl.collectionResultDisplayLimit 0 +set_param messaging.disableStorage 1 + +set pips [get_pips] + +set dwnhill_fp [open "wires/downhill_wires_${blocknb}.txt" w] +set uphill_fp [open "wires/uphill_wires_${blocknb}.txt" w] + +for { set i $start } { $i < $stop } { incr i } { + set pip [lindex $pips $i] + foreach downhill_node [get_nodes -downhill -of_object $pip] { + set ordered_downhill_wires [get_wires -from $pip -of_object $downhill_node] + puts $dwnhill_fp "$pip $downhill_node $ordered_downhill_wires" + } + foreach uphill_node [get_nodes -uphill -of_object $pip] { + set ordered_uphill_wires [get_wires -to $pip -of_object $uphill_node] + puts $uphill_fp "$pip $uphill_node $ordered_uphill_wires" + } + +} + +close $dwnhill_fp +close $uphill_fp diff --git a/fuzzers/072-ordered_wires/run_fuzzer.py b/fuzzers/072-ordered_wires/run_fuzzer.py new file mode 100644 index 00000000..a88a220d --- /dev/null +++ b/fuzzers/072-ordered_wires/run_fuzzer.py @@ -0,0 +1,71 @@ +import os +import shutil +import sys +import subprocess +import signal +from multiprocessing import Pool + + +def start_vivado(argList): + print(argList) + blockID, start, stop = argList + print("Running instance :" + str(blockID)) + subprocess.check_call( + "${XRAY_VIVADO} -mode batch -source $FUZDIR/job.tcl -tclargs " + + str(blockID) + " " + str(start) + " " + str(stop), + shell=True) + + +def get_nb_pips(): + print("Fetching nb pips") + subprocess.check_call( + "${XRAY_VIVADO} -mode batch -source $FUZDIR/get_pipscount.tcl", + shell=True) + countfile = open("nb_pips.txt", "r") + return int(countfile.readline()) + + +def main(argv): + nbBlocks = 64 + nbParBlock = 4 + + pipscount = get_nb_pips() + blocksize = int(pipscount / nbBlocks) + + 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)) + + blockId = range(0, nbBlocks) + startI = range(0, pipscount, blocksize) + stopI = range(blocksize, pipscount + 1, blocksize) + + argList = zip(blockId, startI, stopI) + + with Pool(processes=nbParBlock) as pool: + pool.map(start_vivado, argList) + + print("Generating final files") + + with open("uphill_wires.txt", "w") as wfd: + for j in range(0, nbBlocks): + f = "wires/uphill_wires_" + str(j) + ".txt" + with open(f, "r") as fd: + shutil.copyfileobj(fd, wfd) + + with open("downhill_wires.txt", "w") as wed: + for j in range(0, nbBlocks): + e = "wires/downhill_wires_" + str(j) + ".txt" + with open(e, "r") as ed: + shutil.copyfileobj(ed, wed) + + print("Work done !") + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv))