Skip to content

Commit 9962595

Browse files
committed
break create_jobs function in task.py
1 parent 4426a58 commit 9962595

File tree

1 file changed

+121
-105
lines changed
  • vtr_flow/scripts/python_libs/vtr

1 file changed

+121
-105
lines changed

vtr_flow/scripts/python_libs/vtr/task.py

Lines changed: 121 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,123 @@ def find_longest_task_description(configs):
325325
return longest
326326

327327

328+
def get_work_dir_addr(arch, circuit, noc_traffic):
329+
work_dir = None
330+
if noc_traffic:
331+
work_dir = str(PurePath(arch).joinpath(circuit).joinpath(noc_traffic))
332+
else:
333+
work_dir = str(PurePath(arch).joinpath(circuit))
334+
335+
return work_dir
336+
337+
338+
def create_cmd(abs_circuit_filepath, abs_arch_filepath, config, args, circuit, noc_traffic):
339+
# Collect any extra script params from the config file
340+
cmd = [abs_circuit_filepath, abs_arch_filepath]
341+
342+
343+
# Resolve and collect all include paths in the config file
344+
# as -include ["include1", "include2", ..]
345+
includes = []
346+
if config.includes:
347+
cmd += ["-include"]
348+
for include in config.includes:
349+
abs_include_filepath = resolve_vtr_source_file(
350+
config, include, config.include_dir
351+
)
352+
includes.append(abs_include_filepath)
353+
354+
cmd += includes
355+
356+
# Check if additional architectural data files are present
357+
if config.additional_files_list_add:
358+
for additional_file in config.additional_files_list_add:
359+
flag, file_name = additional_file.split(",")
360+
361+
cmd += [flag]
362+
cmd += [resolve_vtr_source_file(config, file_name, config.arch_dir)]
363+
364+
if hasattr(args, "show_failures") and args.show_failures:
365+
cmd += ["-show_failures"]
366+
cmd += config.script_params if config.script_params else []
367+
cmd += config.script_params_common if config.script_params_common else []
368+
cmd += (
369+
args.shared_script_params
370+
if hasattr(args, "shared_script_params") and args.shared_script_params
371+
else []
372+
)
373+
374+
# Apply any special config based parameters
375+
if config.cmos_tech_behavior:
376+
cmd += [
377+
"-cmos_tech",
378+
resolve_vtr_source_file(config, config.cmos_tech_behavior, "tech"),
379+
]
380+
381+
cmd += (
382+
["--fix_pins", resolve_vtr_source_file(config, config.pad_file)]
383+
if config.pad_file
384+
else []
385+
)
386+
387+
if config.sdc_dir:
388+
sdc_name = "{}.sdc".format(Path(circuit).stem)
389+
sdc_file = resolve_vtr_source_file(config, sdc_name, config.sdc_dir)
390+
391+
cmd += ["-sdc_file", "{}".format(sdc_file)]
392+
393+
if config.place_constr_dir:
394+
place_constr_name = "{}.place".format(Path(circuit).stem)
395+
place_constr_file = resolve_vtr_source_file(
396+
config, place_constr_name, config.place_constr_dir
397+
)
398+
399+
cmd += ["--fix_clusters", "{}".format(place_constr_file)]
400+
401+
parse_cmd = None
402+
second_parse_cmd = None
403+
qor_parse_command = None
404+
if config.parse_file:
405+
parse_cmd = [
406+
resolve_vtr_source_file(
407+
config,
408+
config.parse_file,
409+
str(PurePath("parse").joinpath("parse_config")),
410+
)
411+
]
412+
413+
if config.second_parse_file:
414+
second_parse_cmd = [
415+
resolve_vtr_source_file(
416+
config,
417+
config.second_parse_file,
418+
str(PurePath("parse").joinpath("parse_config")),
419+
)
420+
]
421+
422+
if config.qor_parse_file:
423+
qor_parse_command = [
424+
resolve_vtr_source_file(
425+
config,
426+
config.qor_parse_file,
427+
str(PurePath("parse").joinpath("qor_config")),
428+
)
429+
]
430+
# We specify less verbosity to the sub-script
431+
# This keeps the amount of output reasonable
432+
if hasattr(args, "verbosity") and max(0, args.verbosity - 1):
433+
cmd += ["-verbose"]
434+
435+
if noc_traffic:
436+
cmd += [
437+
"--noc_flows_file",
438+
resolve_vtr_source_file(config, noc_traffic, config.noc_traffic_dir),
439+
]
440+
441+
return includes, parse_cmd, second_parse_cmd, qor_parse_command, cmd
442+
443+
444+
328445
# pylint: disable=too-many-branches
329446
def create_jobs(args, configs, after_run=False):
330447
"""
@@ -344,11 +461,7 @@ def create_jobs(args, configs, after_run=False):
344461
)
345462
abs_arch_filepath = resolve_vtr_source_file(config, arch, config.arch_dir)
346463
abs_circuit_filepath = resolve_vtr_source_file(config, circuit, config.circuit_dir)
347-
work_dir = None
348-
if noc_traffic:
349-
work_dir = str(PurePath(arch).joinpath(circuit).joinpath(noc_traffic))
350-
else:
351-
work_dir = str(PurePath(arch).joinpath(circuit))
464+
work_dir = get_work_dir_addr(arch, circuit, noc_traffic)
352465

353466
run_dir = (
354467
str(
@@ -361,106 +474,9 @@ def create_jobs(args, configs, after_run=False):
361474
)
362475
)
363476

364-
# Collect any extra script params from the config file
365-
cmd = [abs_circuit_filepath, abs_arch_filepath]
366-
367-
# Resolve and collect all include paths in the config file
368-
# as -include ["include1", "include2", ..]
369-
includes = []
370-
if config.includes:
371-
cmd += ["-include"]
372-
for include in config.includes:
373-
abs_include_filepath = resolve_vtr_source_file(
374-
config, include, config.include_dir
375-
)
376-
includes.append(abs_include_filepath)
377-
378-
cmd += includes
379-
380-
# Check if additional architectural data files are present
381-
if config.additional_files_list_add:
382-
for additional_file in config.additional_files_list_add:
383-
flag, file_name = additional_file.split(",")
384-
385-
cmd += [flag]
386-
cmd += [resolve_vtr_source_file(config, file_name, config.arch_dir)]
387-
388-
if hasattr(args, "show_failures") and args.show_failures:
389-
cmd += ["-show_failures"]
390-
cmd += config.script_params if config.script_params else []
391-
cmd += config.script_params_common if config.script_params_common else []
392-
cmd += (
393-
args.shared_script_params
394-
if hasattr(args, "shared_script_params") and args.shared_script_params
395-
else []
396-
)
397-
398-
# Apply any special config based parameters
399-
if config.cmos_tech_behavior:
400-
cmd += [
401-
"-cmos_tech",
402-
resolve_vtr_source_file(config, config.cmos_tech_behavior, "tech"),
403-
]
404-
405-
cmd += (
406-
["--fix_pins", resolve_vtr_source_file(config, config.pad_file)]
407-
if config.pad_file
408-
else []
409-
)
410-
411-
if config.sdc_dir:
412-
sdc_name = "{}.sdc".format(Path(circuit).stem)
413-
sdc_file = resolve_vtr_source_file(config, sdc_name, config.sdc_dir)
414-
415-
cmd += ["-sdc_file", "{}".format(sdc_file)]
416-
417-
if config.place_constr_dir:
418-
place_constr_name = "{}.place".format(Path(circuit).stem)
419-
place_constr_file = resolve_vtr_source_file(
420-
config, place_constr_name, config.place_constr_dir
421-
)
422-
423-
cmd += ["--fix_clusters", "{}".format(place_constr_file)]
424-
425-
parse_cmd = None
426-
second_parse_cmd = None
427-
qor_parse_command = None
428-
if config.parse_file:
429-
parse_cmd = [
430-
resolve_vtr_source_file(
431-
config,
432-
config.parse_file,
433-
str(PurePath("parse").joinpath("parse_config")),
434-
)
435-
]
436-
437-
if config.second_parse_file:
438-
second_parse_cmd = [
439-
resolve_vtr_source_file(
440-
config,
441-
config.second_parse_file,
442-
str(PurePath("parse").joinpath("parse_config")),
443-
)
444-
]
445-
446-
if config.qor_parse_file:
447-
qor_parse_command = [
448-
resolve_vtr_source_file(
449-
config,
450-
config.qor_parse_file,
451-
str(PurePath("parse").joinpath("qor_config")),
452-
)
453-
]
454-
# We specify less verbosity to the sub-script
455-
# This keeps the amount of output reasonable
456-
if hasattr(args, "verbosity") and max(0, args.verbosity - 1):
457-
cmd += ["-verbose"]
458-
459-
if noc_traffic:
460-
cmd += [
461-
"--noc_flows_file",
462-
resolve_vtr_source_file(config, noc_traffic, config.noc_traffic_dir),
463-
]
477+
includes, parse_cmd, second_parse_cmd, qor_parse_command, cmd = create_cmd(abs_circuit_filepath,
478+
abs_arch_filepath, config,
479+
args, circuit, noc_traffic)
464480

465481
if config.script_params_list_add:
466482
for value in config.script_params_list_add:

0 commit comments

Comments
 (0)