3636#include " utl/Logger.h"
3737
3838namespace mpl2 {
39+ using utl::MPL;
3940
4041// ////////////////////////////////////////////////////////////////
4142// Class SACoreHardMacro
@@ -92,8 +93,9 @@ SACoreHardMacro::SACoreHardMacro(
9293float SACoreHardMacro::calNormCost () const
9394{
9495 float cost = 0.0 ; // Initialize cost
96+ const float outline_area = outline_width_ * outline_height_;
9597 if (norm_area_penalty_ > 0.0 ) {
96- cost += area_weight_ * (width_ * height_) / norm_area_penalty_ ;
98+ cost += area_weight_ * (width_ * height_) / outline_area ;
9799 }
98100 if (norm_outline_penalty_ > 0.0 ) {
99101 cost += outline_weight_ * outline_penalty_ / norm_outline_penalty_;
@@ -234,6 +236,22 @@ void SACoreHardMacro::initialize()
234236 norm_wirelength_ = calAverage (wirelength_list);
235237 norm_guidance_penalty_ = calAverage (guidance_penalty_list);
236238 norm_fence_penalty_ = calAverage (fence_penalty_list);
239+
240+ if (norm_area_penalty_ <= 1e-4 )
241+ norm_area_penalty_ = 1.0 ;
242+
243+ if (norm_outline_penalty_ <= 1e-4 )
244+ norm_outline_penalty_ = 1.0 ;
245+
246+ if (norm_wirelength_ <= 1e-4 )
247+ norm_wirelength_ = 1.0 ;
248+
249+ if (norm_guidance_penalty_ <= 1e-4 )
250+ norm_guidance_penalty_ = 1.0 ;
251+
252+ if (norm_fence_penalty_ <= 1e-4 )
253+ norm_fence_penalty_ = 1.0 ;
254+
237255 // Calculate initial temperature
238256 std::vector<float > cost_list;
239257 for (int i = 0 ; i < outline_penalty_list.size (); i++) {
@@ -249,48 +267,78 @@ void SACoreHardMacro::initialize()
249267 for (int i = 1 ; i < cost_list.size (); i++) {
250268 delta_cost += std::abs (cost_list[i] - cost_list[i - 1 ]);
251269 }
252- init_temperature_
253- = (-1.0 ) * (delta_cost / (cost_list.size () - 1 )) / log (init_prob_);
270+ if (cost_list.size () > 1 && delta_cost > 0.0 ) {
271+ init_temperature_
272+ = (-1.0 ) * (delta_cost / (cost_list.size () - 1 )) / log (init_prob_);
273+ } else {
274+ init_temperature_ = 1.0 ;
275+ }
254276}
255277
256278void SACoreHardMacro::printResults ()
257279{
258- logger_->report (" SACoreHardMacro" );
259- logger_->report (" outline_penalty_ = {}" , outline_penalty_);
260- logger_->report (" wirelength_ = {}" , wirelength_);
261- for (auto & net : nets_) {
262- logger_->report (" net src = {} target = {} weight = {}" ,
263- net.terminals .first ,
264- net.terminals .second ,
265- net.weight );
280+ debugPrint (logger_, MPL, " macro_placement" , 1 , " SACoreHardMacro" );
281+ debugPrint (logger_,
282+ MPL,
283+ " macro_placement" ,
284+ 1 ,
285+ " number of macros : {}" ,
286+ macros_.size ());
287+ for (auto macro : macros_) {
288+ debugPrint (logger_,
289+ MPL,
290+ " macro_placement" ,
291+ 1 ,
292+ " lx = {}, ly = {}, width = {}, height = {}" ,
293+ macro.getX (),
294+ macro.getY (),
295+ macro.getWidth (),
296+ macro.getHeight ());
266297 }
267-
268- for (auto & macro : macros_) {
269- logger_->report (
270- " name : {} lx = {} ly = {} pin_x = {} pin_y = {} orientation = {}" ,
271- macro.getName (),
272- macro.getX (),
273- macro.getY (),
274- macro.getPinX (),
275- macro.getPinY (),
276- macro.getOrientation ());
277- }
278- // FlipMacro();
279- calPenalty ();
280- logger_->report (" wirelength_ = {}" , wirelength_);
281- for (auto & macro : macros_) {
282- logger_->report (
283- " name : {} lx = {} ly = {} pin_x = {} pin_y = {} orientation = {}" ,
284- macro.getName (),
285- macro.getX (),
286- macro.getY (),
287- macro.getPinX (),
288- macro.getPinY (),
289- macro.getOrientation ());
290- }
291-
292- logger_->report (" guidance_penalty_ = {}" , guidance_penalty_);
293- logger_->report (" fence_penalty_ = {}" , fence_penalty_);
298+ debugPrint (logger_,
299+ MPL,
300+ " macro_placement" ,
301+ 1 ,
302+ " width = {}, outline_width = {}" ,
303+ width_,
304+ outline_width_);
305+ debugPrint (logger_,
306+ MPL,
307+ " macro_placement" ,
308+ 1 ,
309+ " height = {}, outline_height = {}" ,
310+ height_,
311+ outline_height_);
312+ debugPrint (logger_,
313+ MPL,
314+ " macro_placement" ,
315+ 1 ,
316+ " outline_penalty = {}, norm_outline_penalty = {}" ,
317+ outline_penalty_,
318+ norm_outline_penalty_);
319+ debugPrint (logger_,
320+ MPL,
321+ " macro_placement" ,
322+ 1 ,
323+ " wirelength = {}, norm_wirelength = {}" ,
324+ wirelength_,
325+ norm_wirelength_);
326+ debugPrint (logger_,
327+ MPL,
328+ " macro_placement" ,
329+ 1 ,
330+ " guidance_penalty = {}, norm_guidance_penalty = {}" ,
331+ guidance_penalty_,
332+ norm_guidance_penalty_);
333+ debugPrint (logger_,
334+ MPL,
335+ " macro_placement" ,
336+ 1 ,
337+ " fence_penalty = {}, norm_fence_penalty = {}" ,
338+ fence_penalty_,
339+ norm_fence_penalty_);
340+ debugPrint (
341+ logger_, MPL, " macro_placement" , 1 , " final cost = {}" , getNormCost ());
294342}
295343
296344} // namespace mpl2
0 commit comments