072-ordered_wires: increased parallel jobs.

This changes also the way the ordered wires final files are generated.
In fact, now, with the help of a Lock, all the suprocesses directly
access the final files, updating them. Once the write completes, the
temporary file is deleted.

This saves up disk space.

Signed-off-by: Alessandro Comodi <acomodi@antmicro.com>
This commit is contained in:
Alessandro Comodi 2020-01-15 16:46:48 +01:00
parent c5a33cb161
commit 63bb8337f8
2 changed files with 22 additions and 17 deletions

View File

@ -2,8 +2,8 @@
N := 1
SPECIMENS := $(addprefix build/specimen_,$(shell seq -f '%03.0f' $(N)))
SPECIMENS_OK := $(addsuffix /OK,$(SPECIMENS))
MAX_VIVADO_PROCESS ?= 4
MAX_PIPS_INSTANCE ?= 340000
MAX_VIVADO_PROCESS ?= 8
MAX_PIPS_INSTANCE ?= 680000
database: $(SPECIMENS_OK)
true

View File

@ -3,13 +3,14 @@ import shutil
import sys
import subprocess
import signal
from multiprocessing import Pool
from multiprocessing import Pool, Lock
from itertools import chain
import argparse
# Can be used to redirect vivado tons of output
# stdout=DEVNULL in subprocess.check_call
MP_LOCK = Lock()
# Worker function called from threads
def start_pips(argList):
@ -20,6 +21,24 @@ def start_pips(argList):
str(blockID) + " " + str(start) + " " + str(stop),
shell=True)
uphill_wires = "wires/uphill_wires_{}.txt".format(blockID)
downhill_wires = "wires/downhill_wires_{}.txt".format(blockID)
# Locking to write on final file and remove the temporary one
MP_LOCK.acquire()
with open("uphill_wires.txt", "a") as wfd:
f = uphill_wires
with open(f, "r") as fd:
shutil.copyfileobj(fd, wfd)
with open("downhill_wires.txt", "a") as wfd:
f = downhill_wires
with open(f, "r") as fd:
shutil.copyfileobj(fd, wfd)
MP_LOCK.release()
os.remove(uphill_wires)
os.remove(downhill_wires)
# Function called once to get the total numbers of pips to list
def get_nb_pips():
@ -116,20 +135,6 @@ def main(argv):
pipsFileCount = run_pool(
pipscount, nbPipsBlock, blockPipsSize, nbParBlock, start_pips)
print("Generating final files")
with open("uphill_wires.txt", "w") as wfd:
for j in range(0, pipsFileCount):
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, pipsFileCount):
e = "wires/downhill_wires_" + str(j) + ".txt"
with open(e, "r") as ed:
shutil.copyfileobj(ed, wed)
print("Work done !")
return 0