Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CMakeLists.txt to adapte new CUDA version #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Wrap xplace placement function
  • Loading branch information
ZhuYanzhen1 committed Sep 21, 2024
commit afa5f2a3b130ee90aa55e0a4d3a3e74d09a3f4cc
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -14,4 +14,6 @@ result*
data/cad
data/raw
misc
.venv/
.venv/
.idea

2 changes: 1 addition & 1 deletion src/core/macro_legalization.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
pulp_logger.setLevel(logging.INFO)
use_numba_parallel = False

@nb.jit(cache=True, parallel=use_numba_parallel)
@nb.jit(nopython=True, cache=True, parallel=use_numba_parallel)
def check_macro_legality(macro_pos, macro_size, macro_fixed, die_info, check_all=True):
num_macros = macro_pos.shape[0]
# overlap = np.zeros((num_macros, num_macros), dtype=np.bool8)
8 changes: 7 additions & 1 deletion src/database.py
Original file line number Diff line number Diff line change
@@ -5,9 +5,15 @@
from utils import *


def load_dataset(args, logger, params):
def load_dataset(args, logger):
rawdb, gpdb = None, None
parser = IOParser()
params = {
'benchmark': args.dataset,
'bookshelf_variety': args.bookshelf_variety,
'aux': args.aux,
'design_name': args.design_name
}
if args.load_from_raw:
logger.info("loading from original benchmark...")
rawdb, gpdb = parser.read(
33 changes: 1 addition & 32 deletions src/run_placement.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
from utils import *
from src import run_placement_main_nesterov


def run_placement_single(args, logger):
def run_placement_main(args, logger):
logger.info("=================")
assert torch.cuda.is_available()
torch.cuda.synchronize("cuda:{}".format(args.gpu))
set_random_seed(args)
res = run_placement_main_nesterov(args, logger)
return res


def run_placement_all(args, logger):
logger.info("Run all designs in dataset %s." % args.dataset)
place_df = pd.DataFrame(columns=["design", "dp_hpwl", "gp_hpwl", "top5overflow", "overflow", "gp_time", "lg+dp_time", "gp_per_iter", "place_time"])
route_df = pd.DataFrame(columns=["design", "#OvflNets", "GR WL", "GR #Vias", "GR EstShort", "RC Hor", "RC Ver"])
mul_params = sorted(
get_multiple_design_params(args.dataset_root, args.dataset), key=lambda params: params["design_name"]
)
for i, params in enumerate(mul_params):
cur_args = copy.deepcopy(args)
cur_args.design_name = params["design_name"]
place_metrics, route_metrics = run_placement_single(cur_args, logger)
place_df.loc[i] = [cur_args.design_name, *place_metrics]
if route_metrics is not None:
route_df.loc[i] = [cur_args.design_name, *route_metrics]
place_csv_path = os.path.join(args.result_dir, args.exp_id, args.log_dir, "run_all.csv")
place_df.to_csv(place_csv_path)
print(place_df)
if len(route_df) > 0:
route_csv_path = os.path.join(args.result_dir, args.exp_id, args.log_dir, "route.csv")
route_df.to_csv(route_csv_path)
print(route_df)


def run_placement_main(args, logger):
if args.run_all:
run_placement_all(args, logger)
else:
run_placement_single(args, logger)
38 changes: 36 additions & 2 deletions src/run_placement_nesterov.py
Original file line number Diff line number Diff line change
@@ -390,11 +390,45 @@ def calc_route_force(mov_node_pos, mov_node_size, expand_ratio, constraint_fn):

return node_pos, iteration, gp_hpwl, overflow, gp_time, gp_per_iter

def set_dataset_args(args):
if args.design_name in ["adaptec1", "bigblue1"]:
args.num_bin_x = args.num_bin_y = 512
args.target_density = 1.0
elif args.design_name in ["adaptec2", "adaptec3", "adaptec4", "bigblue2"]:
args.num_bin_x = args.num_bin_y = 1024
args.target_density = 1.0
elif args.design_name in ["bigblue3", "bigblue4"]:
args.num_bin_x = args.num_bin_y = 2048
args.target_density = 1.0
elif args.design_name in ["adaptec5"]:
args.target_density = 0.5
args.num_bin_x = args.num_bin_y = 1024
elif args.design_name in ["newblue1"]:
args.target_density = 0.8
args.num_bin_x = args.num_bin_y = 512
elif args.design_name in ["newblue2"]:
args.target_density = 0.9
args.num_bin_x = args.num_bin_y = 1024
elif args.design_name in ["newblue3"]:
args.target_density = 0.8
args.num_bin_x = args.num_bin_y = 2048
elif args.design_name in ["newblue4"]:
args.target_density = 0.5
args.num_bin_x = args.num_bin_y = 1024
elif args.design_name in ["newblue5"]:
args.target_density = 0.5
args.num_bin_x = args.num_bin_y = 1024
elif args.design_name in ["newblue6"]:
args.target_density = 0.8
args.num_bin_x = args.num_bin_y = 2048
elif args.design_name in ["newblue7"]:
args.target_density = 0.8
args.num_bin_x = args.num_bin_y = 2048

def run_placement_main_nesterov(args, logger):
total_start = time.time()
params = find_design_params(args, logger)
data, rawdb, gpdb = load_dataset(args, logger, params)
set_dataset_args(args)
data, rawdb, gpdb = load_dataset(args, logger)
device = torch.device(
"cuda:{}".format(args.gpu) if torch.cuda.is_available() else "cpu"
)
6 changes: 3 additions & 3 deletions utils/logger.py
Original file line number Diff line number Diff line change
@@ -52,12 +52,12 @@ def setup_logger(args, sys_argv) -> logging.Logger:
logger.setLevel(logging.DEBUG)
logger.addHandler(file_handler)
logger.addHandler(screen_handler)

logger.info("Command line: python " + " ".join(sys_argv))
logger.info("log file at {}".format(log_file_path))

logger.info("")
for arg in vars(args):
logger.info("{}: {}".format(arg, getattr(args, arg)))
for attr_name, attr_value in vars(args).items():
logger.info("{}: {}".format(attr_name, attr_value))
logger.info("")

logging.getLogger("matplotlib.font_manager").disabled = True
78 changes: 78 additions & 0 deletions xplace_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from utils import *
from src import run_placement_main, Flute

def set_option():
args = type('ARGS', (), {})()
args.bookshelf_variety = 'ispd2005'
args.aux = '../../testcase/mms/adaptec1/adaptec1.aux'
args.dataset = "mms"
args.design_name = "adaptec1"
args.custom_path = ""
args.custom_json = ""
args.given_solution = ""
args.load_from_raw = True
args.run_all = False
args.seed = 0
args.gpu = 0
args.num_threads = 16
args.deterministic = True
args.global_placement = True
args.lr = 0.01
args.inner_iter = 10000
args.wa_coeff = 4.0
args.num_bin_x = 512
args.num_bin_y = 512
args.density_weight = 8e-05
args.density_weight_coef = 1.05
args.target_density = 1.0
args.use_filler = True
args.noise_ratio = 0.025
args.ignore_net_degree = 100
args.use_eplace_nesterov = True
args.clamp_node = True
args.use_precond = True
args.stop_overflow = 0.07
args.enable_skip_update = True
args.enable_sample_force = True
args.mixed_size = True
args.use_cell_inflate = False
args.min_area_inc = 0.01
args.use_route_force = False
args.route_freq = 1000
args.num_route_iter = 400
args.route_weight = 0
args.congest_weight = 0
args.pseudo_weight = 0
args.visualize_cgmap = False
args.legalization = True
args.detail_placement = True
args.dp_engine = "default"
args.eval_by_external = False
args.eval_engine = "ntuplace4dr"
args.final_route_eval = False
args.log_freq = 100
args.verbose_cpp_log = False
args.cpp_log_level = 2
args.result_dir = "result"
args.exp_id = ""
args.log_dir = "log"
args.log_name = "log.txt"
args.eval_dir = "eval"
args.draw_placement = True
args.write_placement = True
args.write_global_placement = False
args.output_dir = "output"
args.output_prefix = "placement"
args.exp_id = datetime.datetime.now().strftime('%Y-%m-%d-%H:%M:%S') + args.exp_id
return args

def run_xplace(aux_filepath, design_name):
args = set_option()
args.aux = aux_filepath
args.design_name = design_name
logger = setup_logger(args, sys.argv)
set_random_seed(args)
Flute.register(args.num_threads)
run_placement_main(args, logger)

run_xplace('../../testcase/mms/adaptec1/adaptec1.aux', 'adaptec1')