Skip to content

Commit

Permalink
memory: adjust paths
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Czarnecki <[email protected]>
  • Loading branch information
lpawelcz committed Apr 24, 2024
1 parent 9ecf745 commit 50ef22e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
8 changes: 8 additions & 0 deletions docker_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ then
export MOCK_AREA_TCL_PREFIXED=$PATH_PREFIX/$MOCK_AREA_TCL
fi

if [[ -n "${MEMORY_DUMP_TCL}" ]]
then
export MEMORY_DUMP_TCL_PREFIXED=$PATH_PREFIX/$MEMORY_DUMP_TCL
export MEMORY_DUMP_PY_PREFIXED=$PATH_PREFIX/$MEMORY_DUMP_PY
fi

# Configs are always generated in execroot because they are generated in
# the repository that uses bazel-orfs as dependency or in bazel-orfs itself
export DESIGN_CONFIG_PREFIXED=$WORKSPACE_EXECROOT/$DESIGN_CONFIG
Expand Down Expand Up @@ -83,6 +89,8 @@ docker run --name "bazel-orfs-$uuid" --rm \
-e STAGE_CONFIG=$STAGE_CONFIG_PREFIXED \
-e MAKE_PATTERN=$MAKE_PATTERN_PREFIXED \
-e MOCK_AREA_TCL=$MOCK_AREA_TCL_PREFIXED \
-e MEMORY_DUMP_TCL=$MEMORY_DUMP_TCL_PREFIXED \
-e MEMORY_DUMP_PY=$MEMORY_DUMP_PY_PREFIXED \
-e WORK_HOME=$WORKSPACE_EXECROOT/$RULEDIR \
-v $WORKSPACE_ROOT:$WORKSPACE_ROOT \
-v $WORKSPACE_ORIGIN:$WORKSPACE_ORIGIN \
Expand Down
4 changes: 2 additions & 2 deletions memory-bazel.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: memory
memory: $(RESULTS_DIR)/mem.json
python3 scripts/mem_dump.py $(RESULTS_DIR)/mem.json
python3 $(MEMORY_DUMP_PY) $(RESULTS_DIR)/mem.json

$(RESULTS_DIR)/mem.json: yosys-dependencies
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR)
$(TIME_CMD) $(YOSYS_CMD) $(YOSYS_FLAGS) -c scripts/mem_dump.tcl 2>&1 | tee $(LOG_DIR)/1_0_mem.log
$(TIME_CMD) $(YOSYS_CMD) $(YOSYS_FLAGS) -c $(MEMORY_DUMP_TCL) 2>&1 | tee $(LOG_DIR)/1_0_mem.log
23 changes: 14 additions & 9 deletions openroad.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ def get_entrypoint_cmd(
use_docker_flow = True,
make_targets = None,
docker_image = None,
mock_area = False):
mock_area = False,
memory = False):
"""
Prepare command line for running docker_shell utility
Expand All @@ -248,6 +249,7 @@ def get_entrypoint_cmd(
use_docker_flow: flag to distinguish whether the command should run docker flow or local flow
docker_image: name of the docker image used for running ORFS flow
mock_area: flag describing whether pass additional env var for mock_area target execution
memory: flag describing whether pass additional env var for memory target execution
Returns:
string with command line for running ORFS flow in docker container
Expand All @@ -270,6 +272,9 @@ def get_entrypoint_cmd(
cmd += " MAKE_PATTERN=" + path_constructor(make_pattern)
if (mock_area):
cmd += " MOCK_AREA_TCL=" + path_constructor(Label("//:mock_area.tcl"))
if (memory):
cmd += " MEMORY_DUMP_TCL=" + path_constructor(Label("//scripts:mem_dump.tcl"))
cmd += " MEMORY_DUMP_PY=" + path_constructor(Label("//scripts:mem_dump.py"))
cmd += " RULEDIR=$(RULEDIR)"
if not use_docker_flow:
cmd += " \\\\\n"
Expand Down Expand Up @@ -361,7 +366,7 @@ def mock_area_stages(
([name + "_" + stage, Label("//:mock_area.tcl")] if stage == "floorplan" else []) +
([name + "_" + previous + "_mock_area"] if stage != "clock_period" else []) +
([name + "_synth_mock_area"] if stage == "floorplan" else []),
cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, True, make_targets, docker_image = docker_image, mock_area = (stage == "floorplan")),
cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, True, make_targets, docker_image = docker_image, mock_area = (stage == "floorplan"), memory = False),
outs = [s.replace("/" + variant + "/", "/mock_area/") for s in outs.get(stage, [])],
tags = ["supports-graceful-termination"],
)
Expand Down Expand Up @@ -635,7 +640,7 @@ def build_openroad(
make_pattern = Label("//:" + stage + "-bazel.mk")
stage_config = Label("@@//:" + target_name + "_" + stage + "_config.mk")
make_targets = get_make_targets(stage, False, mock_area)
entrypoint_cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, False)
entrypoint_cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, False, memory = False)

native.genrule(
name = target_name + "_" + stage + "_make_script",
Expand Down Expand Up @@ -671,25 +676,25 @@ def build_openroad(
)
make_pattern = Label("//:memory-bazel.mk")
stage_config = Label("@@//:" + target_name + "_memory_config.mk")
entrypoint_cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, False)
entrypoint_cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, False, memory = True)
native.genrule(
name = target_name + "_memory_make_script",
tools = [Label("//:orfs")],
srcs = [make_script_template, design_config, stage_config, make_pattern],
srcs = [make_script_template, design_config, stage_config, make_pattern, Label("//scripts:mem_dump.tcl"), Label("//scripts:mem_dump.py")],
cmd = "cat <<EOF > $@ \n`cat $(location " + str(make_script_template) + ")`\n" + entrypoint_cmd + " \\$$@",
outs = ["logs/%s/%s/%s/make_script_memory.sh" % (platform, out_dir, variant)],
)
native.sh_binary(
name = target_name + "_memory_make",
srcs = ["//:" + target_name + "_memory_make_script"],
data = [Label("//:orfs"), design_config, stage_config, make_pattern],
data = [Label("//:orfs"), design_config, stage_config, make_pattern, Label("//scripts:mem_dump.tcl"), Label("//scripts:mem_dump.py")],
deps = ["@bazel_tools//tools/bash/runfiles"],
)
native.genrule(
name = target_name + "_memory",
tools = [Label("//:docker_shell")],
srcs = [Label("//:scripts/mem_dump.py"), Label("//:scripts/mem_dump.tcl"), target_name + "_clock_period", design_config, stage_config, make_pattern],
cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, True, "memory", docker_image = docker_image),
srcs = [Label("//scripts:mem_dump.py"), Label("//scripts:mem_dump.tcl"), target_name + "_clock_period", design_config, stage_config, make_pattern],
cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, True, "memory", docker_image = docker_image, memory = True),
outs = outs["memory"],
tags = ["supports-graceful-termination"],
)
Expand Down Expand Up @@ -719,7 +724,7 @@ def build_openroad(
tools = [Label("//:docker_shell")],
srcs = [make_pattern, design_config, stage_config] + stage_sources[stage] + ([name + target_ext + "_" + previous] if stage not in ("clock_period", "synth_sdc") else []) +
([name + target_ext + "_generate_abstract_mock_area"] if mock_area != None and stage == "generate_abstract" else []),
cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, True, make_targets, docker_image = docker_image),
cmd = get_entrypoint_cmd(make_pattern, design_config, stage_config, True, make_targets, docker_image = docker_image, memory = False),
outs = outs.get(stage, []),
tags = ["supports-graceful-termination"],
)

0 comments on commit 50ef22e

Please sign in to comment.