Advertisement
natsfr

072 split job python pool

Jan 11th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. import os
  2. import shutil
  3. import sys
  4. import subprocess
  5. import signal
  6. from multiprocessing import Pool
  7.  
  8. def start_vivado(blockID, start, stop):
  9.     print("Running instance :" + str(blockID))
  10.     subprocess.check_call(
  11.         "${XRAY_VIVADO} -mode batch -source $FUZDIR/job.tcl -tclargs " +
  12.         str(blockID) + " " + str(start) + " " + str(stop),
  13.         shell=True)
  14.  
  15. def get_nb_pips():
  16.     print("Fetching nb pips")
  17.     subprocess.check_call(
  18.         "${XRAY_VIVADO} -mode batch -source $FUZDIR/get_pipscount.tcl",
  19.         shell=True)
  20.     countfile = open("nb_pips.txt", "r")
  21.     return int(countfile.readline())
  22.  
  23. def main(argv):
  24.     nbBlocks = 64
  25.     nbParBlock = 4
  26.    
  27.     pipscount = get_nb_pips()
  28.     blocksize = pipscount / nbBlocks
  29.  
  30.     if not os.path.exists("wires"):
  31.         os.mkdir("wires")
  32.    
  33.     print(
  34.         "Pips Count: " + str(pipscount) + " - Number of blocks: " +
  35.         str(nbBlocks) + " - Parallel blocks: " + str(nbParBlock))
  36.  
  37.     blockId = range(0, nbBlocks)
  38.     startI = range(0, pipscount, blocksize)
  39.     stopI = range(blocksize, pipscount + 1, blocksize)
  40.  
  41.     with Pool(processes=nbParBlock) as pool:
  42.         pool.map(start_vivado, blockId, startI, stopI)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement