Skip to content

Commit 195e64c

Browse files
authored
Merge pull request #3862 from luarss/topic/at-work-writable
[Autotuner] Enable writing to a directory
2 parents 333fee3 + ac2933e commit 195e64c

3 files changed

Lines changed: 44 additions & 12 deletions

File tree

docs/user/InstructionsForAutoTuner.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,28 @@ The order of the parameters matter. Arguments `--design`, `--platform` and
122122
The following commands should be run from `./tools/AutoTuner`.
123123
```
124124

125-
#### Tune only
126-
127-
* AutoTuner: `openroad_autotuner tune -h`
125+
#### Tune only
128126

129127
Example:
130128

131129
```shell
132-
openroad_autotuner --design gcd --platform sky130hd \
133-
--config ../../flow/designs/sky130hd/gcd/autotuner.json \
134-
tune --samples 5
130+
python3 -m autotuner.distributed \
131+
--design gcd \
132+
--platform sky130hd \
133+
--config ../../flow/designs/sky130hd/gcd/autotuner.json \
134+
tune --samples 5
135135
```
136-
#### Sweep only
137136

138-
* Parameter sweeping: `openroad_autotuner sweep -h`
137+
#### Sweep only
139138

140139
Example:
141140

142141
```shell
143-
openroad_autotuner --design gcd --platform sky130hd \
144-
--config src/autotuner/distributed-sweep-example.json \
145-
sweep
142+
python3 -m autotuner.distributed \
143+
--design gcd \
144+
--platform sky130hd \
145+
--config src/autotuner/distributed-sweep-example.json \
146+
sweep
146147
```
147148

148149
#### Plot images
@@ -159,6 +160,19 @@ The graph will show the progression of one metric (see list below) over the exec
159160
python3 utils/plot.py --results_dir <your-autotuner-result-path>
160161
```
161162

163+
#### Work Directory
164+
165+
Use `--work-dir` to specify a writable directory for outputs. This is passed to ORFS as `WORK_HOME`.
166+
167+
```shell
168+
python3 -m autotuner.distributed \
169+
--design gcd \
170+
--platform sky130hd \
171+
--config ../../flow/designs/sky130hd/gcd/autotuner.json \
172+
--work-dir /tmp/autotuner123 \
173+
tune --samples 5
174+
```
175+
162176
### Google Cloud Platform (GCP) distribution with Ray
163177

164178
GCP Setup Tutorial coming soon.
@@ -171,6 +185,7 @@ GCP Setup Tutorial coming soon.
171185
| `--platform` | Name of the platform for Autotuning. ||
172186
| `--config` | Configuration file that sets which knobs to use for Autotuning. ||
173187
| `--experiment` | Experiment name. This parameter is used to prefix the FLOW_VARIANT and to set the Ray log destination.| test |
188+
| `--work-dir` | Work directory for outputs (passed to ORFS as WORK_HOME). | Installation directory |
174189
| `--git_clean` | Clean binaries and build files. **WARNING**: may lose previous data. ||
175190
| `--git_clone` | Force new git clone. **WARNING**: may lose previous data. ||
176191
| `--git_clone_args` | Additional git clone arguments. ||

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@
105105
ORFS_FLOW_DIR = os.path.abspath(
106106
os.path.join(os.path.dirname(__file__), "../../../../flow")
107107
)
108+
# Path to the WORK_HOME directory
109+
WORK_HOME = None
108110
# Global variable for args
109111
args = None
110112

@@ -409,6 +411,13 @@ def parse_arguments():
409411
default=10001,
410412
help="The port of Ray server to connect.",
411413
)
414+
parser.add_argument(
415+
"--work-dir",
416+
type=str,
417+
metavar="<path>",
418+
default=None,
419+
help="Work directory for outputs (passed to ORFS as WORK_HOME).",
420+
)
412421

413422
parser.add_argument(
414423
"-v",
@@ -612,9 +621,14 @@ def sweep():
612621

613622

614623
def main():
615-
global args, SDC_ORIGINAL, FR_ORIGINAL, LOCAL_DIR, INSTALL_PATH, ORFS_FLOW_DIR, config_dict, reference, best_params
624+
global args, SDC_ORIGINAL, FR_ORIGINAL, LOCAL_DIR, INSTALL_PATH, ORFS_FLOW_DIR, WORK_HOME, config_dict, reference, best_params
616625
args = parse_arguments()
617626

627+
# Set WORK_HOME from --work-dir argument
628+
WORK_HOME = args.work_dir
629+
if WORK_HOME:
630+
print(f"[INFO TUN-0040] Work directory (WORK_HOME): {WORK_HOME}")
631+
618632
# Read config and original files before handling where to run in case we
619633
# need to upload the files.
620634
config_dict, SDC_ORIGINAL, FR_ORIGINAL = read_config(

tools/AutoTuner/src/autotuner/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ def openroad(
361361
make_command += f"make -C {base_dir}/flow DESIGN_CONFIG=designs/"
362362
make_command += f"{args.platform}/{args.design}/config.mk"
363363
make_command += f" PLATFORM={args.platform}"
364+
work_home = getattr(args, "work_dir", None)
365+
if work_home is not None:
366+
make_command += f" WORK_HOME={work_home}"
364367
make_command += f" FLOW_VARIANT={flow_variant} {parameters}"
365368
make_command += " EQUIVALENCE_CHECK=0"
366369
make_command += f" NUM_CORES={args.openroad_threads} SHELL=bash"

0 commit comments

Comments
 (0)