diff --git a/docs/user/InstructionsForAutoTuner.md b/docs/user/InstructionsForAutoTuner.md index 2cbd5bf339..6088e3e070 100644 --- a/docs/user/InstructionsForAutoTuner.md +++ b/docs/user/InstructionsForAutoTuner.md @@ -122,27 +122,28 @@ The order of the parameters matter. Arguments `--design`, `--platform` and The following commands should be run from `./tools/AutoTuner`. ``` -#### Tune only - -* AutoTuner: `openroad_autotuner tune -h` +#### Tune only Example: ```shell -openroad_autotuner --design gcd --platform sky130hd \ - --config ../../flow/designs/sky130hd/gcd/autotuner.json \ - tune --samples 5 +python3 -m autotuner.distributed \ + --design gcd \ + --platform sky130hd \ + --config ../../flow/designs/sky130hd/gcd/autotuner.json \ + tune --samples 5 ``` -#### Sweep only -* Parameter sweeping: `openroad_autotuner sweep -h` +#### Sweep only Example: ```shell -openroad_autotuner --design gcd --platform sky130hd \ - --config src/autotuner/distributed-sweep-example.json \ - sweep +python3 -m autotuner.distributed \ + --design gcd \ + --platform sky130hd \ + --config src/autotuner/distributed-sweep-example.json \ + sweep ``` #### Plot images @@ -159,6 +160,19 @@ The graph will show the progression of one metric (see list below) over the exec python3 utils/plot.py --results_dir ``` +#### Work Directory + +Use `--work-dir` to specify a writable directory for outputs. This is passed to ORFS as `WORK_HOME`. + +```shell +python3 -m autotuner.distributed \ + --design gcd \ + --platform sky130hd \ + --config ../../flow/designs/sky130hd/gcd/autotuner.json \ + --work-dir /tmp/autotuner123 \ + tune --samples 5 +``` + ### Google Cloud Platform (GCP) distribution with Ray GCP Setup Tutorial coming soon. @@ -171,6 +185,7 @@ GCP Setup Tutorial coming soon. | `--platform` | Name of the platform for Autotuning. || | `--config` | Configuration file that sets which knobs to use for Autotuning. || | `--experiment` | Experiment name. This parameter is used to prefix the FLOW_VARIANT and to set the Ray log destination.| test | +| `--work-dir` | Work directory for outputs (passed to ORFS as WORK_HOME). | Installation directory | | `--git_clean` | Clean binaries and build files. **WARNING**: may lose previous data. || | `--git_clone` | Force new git clone. **WARNING**: may lose previous data. || | `--git_clone_args` | Additional git clone arguments. || diff --git a/tools/AutoTuner/src/autotuner/distributed.py b/tools/AutoTuner/src/autotuner/distributed.py index 6a4adecac5..ecf7286035 100644 --- a/tools/AutoTuner/src/autotuner/distributed.py +++ b/tools/AutoTuner/src/autotuner/distributed.py @@ -105,6 +105,8 @@ ORFS_FLOW_DIR = os.path.abspath( os.path.join(os.path.dirname(__file__), "../../../../flow") ) +# Path to the WORK_HOME directory +WORK_HOME = None # Global variable for args args = None @@ -409,6 +411,13 @@ def parse_arguments(): default=10001, help="The port of Ray server to connect.", ) + parser.add_argument( + "--work-dir", + type=str, + metavar="", + default=None, + help="Work directory for outputs (passed to ORFS as WORK_HOME).", + ) parser.add_argument( "-v", @@ -612,9 +621,14 @@ def sweep(): def main(): - global args, SDC_ORIGINAL, FR_ORIGINAL, LOCAL_DIR, INSTALL_PATH, ORFS_FLOW_DIR, config_dict, reference, best_params + global args, SDC_ORIGINAL, FR_ORIGINAL, LOCAL_DIR, INSTALL_PATH, ORFS_FLOW_DIR, WORK_HOME, config_dict, reference, best_params args = parse_arguments() + # Set WORK_HOME from --work-dir argument + WORK_HOME = args.work_dir + if WORK_HOME: + print(f"[INFO TUN-0040] Work directory (WORK_HOME): {WORK_HOME}") + # Read config and original files before handling where to run in case we # need to upload the files. config_dict, SDC_ORIGINAL, FR_ORIGINAL = read_config( diff --git a/tools/AutoTuner/src/autotuner/utils.py b/tools/AutoTuner/src/autotuner/utils.py index 1aad0a489c..7c2304b6ec 100644 --- a/tools/AutoTuner/src/autotuner/utils.py +++ b/tools/AutoTuner/src/autotuner/utils.py @@ -361,6 +361,9 @@ def openroad( make_command += f"make -C {base_dir}/flow DESIGN_CONFIG=designs/" make_command += f"{args.platform}/{args.design}/config.mk" make_command += f" PLATFORM={args.platform}" + work_home = getattr(args, "work_dir", None) + if work_home is not None: + make_command += f" WORK_HOME={work_home}" make_command += f" FLOW_VARIANT={flow_variant} {parameters}" make_command += " EQUIVALENCE_CHECK=0" make_command += f" NUM_CORES={args.openroad_threads} SHELL=bash"