@@ -571,91 +571,25 @@ def read_tune_pbt(name, this):
571571 return config , sdc_file , fr_file
572572
573573
574- def clone (args , path ):
575- """
576- Clone base repo in the remote machine. Only used for Kubernetes at GCP.
577- """
578- if args .git_clone :
579- run_command (args , f"rm -rf { path } " )
580- if not os .path .isdir (f"{ path } /.git" ):
581- git_command = "git clone --depth 1 --recursive --single-branch"
582- git_command += f" { args .git_clone_args } "
583- git_command += f" --branch { args .git_orfs_branch } "
584- git_command += f" { args .git_url } { path } "
585- run_command (args , git_command )
586-
587-
588- def build (args , base , install ):
589- """
590- Build OpenROAD, Yosys and other dependencies.
591- """
592- build_command = f'cd "{ base } "'
593- if args .git_clean :
594- build_command += " && git clean -xdf tools"
595- build_command += " && git submodule foreach --recursive git clean -xdf"
596- if (
597- args .git_clean
598- or not os .path .isfile (f"{ install } /OpenROAD/bin/openroad" )
599- or not os .path .isfile (f"{ install } /yosys/bin/yosys" )
600- ):
601- build_command += ' && bash -ic "./build_openroad.sh'
602- # Some GCP machines have 200+ cores. Let's be reasonable...
603- build_command += f" --local --nice --threads { min (32 , cpu_count ())} "
604- if args .git_latest :
605- build_command += " --latest"
606- build_command += f' { args .build_args } "'
607- run_command (args , build_command )
608-
609-
610- @ray .remote
611- def setup_repo (args , base ):
612- """
613- Clone ORFS repository and compile binaries.
614- """
615- print (f"[INFO TUN-0000] Remote folder: { base } " )
616- install = f"{ base } /tools/install"
617- if args .server is not None :
618- clone (base )
619- build (base , install )
620- return install
621-
622-
623574def prepare_ray_server (args ):
624575 """
625576 Prepares Ray server and returns basic directories.
626577 """
627578 # Connect to remote Ray server if any, otherwise will run locally
628579 if args .server is not None :
629- # At GCP we have a NFS folder that is present for all worker nodes.
630- # This allows to build required binaries once. We clone, build and
631- # store intermediate files at LOCAL_DIR.
632- with open (args .config ) as config_file :
633- local_dir = "/shared-data/autotuner"
634- local_dir += f"-orfs-{ args .git_orfs_branch } "
635- if args .git_or_branch != "" :
636- local_dir += f"-or-{ args .git_or_branch } "
637- if args .git_latest :
638- local_dir += "-or-latest"
639580 # Connect to ray server before first remote execution.
640581 ray .init (f"ray://{ args .server } :{ args .port } " )
641- # Remote functions return a task id and are non-blocking. Since we
642- # need the setup repo before continuing, we call ray.get() to wait
643- # for its completion.
644- install_path = ray .get (setup_repo .remote (local_dir ))
645- orfs_flow_dir = os .path .join (local_dir , "flow" )
646- local_dir += f"/flow/logs/{ args .platform } /{ args .design } "
647- print ("[INFO TUN-0001] NFS setup completed." )
648- else :
649- orfs_dir = getattr (args , "orfs" , None )
650- # For local runs, use the same folder as other ORFS utilities.
651- orfs_flow_dir = os .path .abspath (
652- os .path .join (orfs_dir , "flow" )
653- if orfs_dir
654- else os .path .join (os .path .dirname (__file__ ), "../../../../flow" )
655- )
656- local_dir = f"logs/{ args .platform } /{ args .design } "
657- local_dir = os .path .join (orfs_flow_dir , local_dir )
658- install_path = os .path .abspath (os .path .join (orfs_flow_dir , "../tools/install" ))
582+ print ("[INFO TUN-0001] Connected to Ray server." )
583+ # Common variables used for local and remote runs.
584+ orfs_dir = getattr (args , "orfs" , None )
585+ orfs_flow_dir = os .path .abspath (
586+ os .path .join (orfs_dir , "flow" )
587+ if orfs_dir
588+ else os .path .join (os .path .dirname (__file__ ), "../../../../flow" )
589+ )
590+ local_dir = f"logs/{ args .platform } /{ args .design } "
591+ local_dir = os .path .join (orfs_flow_dir , local_dir )
592+ install_path = os .path .abspath (os .path .join (orfs_flow_dir , "../tools/install" ))
659593 return local_dir , orfs_flow_dir , install_path
660594
661595
0 commit comments