#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "place_qpsolver.h"
Go to the source code of this file.
◆ QPS_DEC_CHANGE
| #define QPS_DEC_CHANGE 0.01 |
◆ QPS_EPS
◆ QPS_LOOP_TOL
| #define QPS_LOOP_TOL 1.0e-3 |
◆ QPS_MAX_ITER
◆ QPS_MAX_TOL
◆ QPS_MINSTEP
| #define QPS_MINSTEP 1.0e-6 |
◆ QPS_PRECON
◆ QPS_PRECON_EPS
| #define QPS_PRECON_EPS 1.0e-9 |
◆ QPS_RELAX_ITER
| #define QPS_RELAX_ITER 180 |
◆ QPS_STEPSIZE_RETRIES
| #define QPS_STEPSIZE_RETRIES 2 |
◆ QPS_TOL
◆ qps_clean()
Definition at line 1259 of file place_qpsolver.c.
1260{
1267
1268#if defined(QPS_DEBUG)
1270#endif
1271}
◆ qps_init()
Definition at line 542 of file place_qpsolver.c.
543{
544 int i, j;
545 int pr, pw;
546
547#if defined(QPS_DEBUG)
548 p->priv_fp = fopen(QPS_DEBUG_FILE,
"a");
550#endif
551
552#if (QPS_DEBUG > 5)
553 fprintf(
p->priv_fp,
"### n=%d gn=%d ln=%d\n",
p->num_cells,
p->cog_num,
555 pr = 0;
556 fprintf(
p->priv_fp,
"### (c w) values\n");
557 for (i = 0; i <
p->num_cells; i++) {
558 fprintf(
p->priv_fp,
"net %d: ", i);
559 while (
p->connect[pr] >= 0) {
560 fprintf(
p->priv_fp,
"(%d %f) ",
p->connect[pr],
p->edge_weight[pr]);
561 pr++;
562 }
563 fprintf(
p->priv_fp,
"(-1 -1.0)\n");
564 pr++;
565 }
566 fprintf(
p->priv_fp,
"### (x y f) values\n");
567 for (i = 0; i <
p->num_cells; i++) {
568 fprintf(
p->priv_fp,
"cell %d: (%f %f %d)\n", i,
p->x[i],
p->y[i],
570 }
571#if 0
573 fprintf(
p->priv_fp,
"### ga values\n");
574 for (i = 0; i <
p->num_cells; i++) {
575 fprintf(
p->priv_fp,
"cell %d: (%f)\n", i,
p->area[i]);
576 }
577 }
578 pr = 0;
579 fprintf(
p->priv_fp,
"### gl values\n");
580 for (i = 0; i <
p->cog_num; i++) {
581 fprintf(
p->priv_fp,
"cog %d: ", i);
582 while (
p->cog_list[pr] >= 0) {
583 fprintf(
p->priv_fp,
"%d ",
p->cog_list[pr]);
584 pr++;
585 }
586 fprintf(
p->priv_fp,
"-1\n");
587 pr++;
588 }
589 fprintf(
p->priv_fp,
"### (gx gy) values\n");
590 for (i = 0; i <
p->cog_num; i++) {
591 fprintf(
p->priv_fp,
"cog %d: (%f %f)\n", i,
p->cog_x[i],
p->cog_y[i]);
592 }
593#endif
594#endif
595
596 p->priv_ii = (
int *)
malloc(
p->num_cells *
sizeof(
int));
598
600
602
603
604 pr = pw = 0;
605 for (i = 0; i <
p->num_cells; i++) {
606 while ((j =
p->connect[pr]) >= 0) {
607 if (j > i) {
608 pw++;
609 }
610 pr++;
611 }
612 pw++;
613 pr++;
614 }
615 p->priv_cc = (
int *)
malloc(pw *
sizeof(
int));
617 p->priv_cr = (
int *)
malloc(
p->num_cells *
sizeof(
int));
624 pr = pw = 0;
625 for (i = 0; i <
p->num_cells; i++) {
627 while ((j =
p->connect[pr]) >= 0) {
628 if (j > i) {
629 p->priv_cc[pw] =
p->connect[pr];
630 p->priv_ct[pw] =
p->edge_weight[pr];
631 pw++;
632 }
633 pr++;
634 }
636 p->priv_ct[pw] = -1.0;
637 pw++;
638 pr++;
639 }
641
642
645 p->priv_tp2 =
p->priv_tp + 2 *
p->num_cells;
646}
ABC_NAMESPACE_HEADER_START typedef float qps_float_t
◆ qps_solve()
Definition at line 981 of file place_qpsolver.c.
982{
983 int i, j;
984 int pr, pw;
986 int tk;
987
988#if defined(QPS_PRECON)
989 int c;
991#endif
992
993#if defined(QPS_HOIST)
994 int k;
995 int st;
996 int m1, m2;
997#endif
998
1003 p->priv_mxh =
p->priv_mxl +
p->num_cells;
1004 p->priv_myl =
p->priv_mxl + 2 *
p->num_cells;
1005 p->priv_myh =
p->priv_mxl + 3 *
p->num_cells;
1006 for (i = 4 *
p->num_cells; i--;) {
1007 p->priv_mxl[i] = 0.0;
1008 }
1009 }
1010
1011
1012 for (i =
p->num_cells; i--;) {
1013 p->priv_ii[i] = (
p->fixed[i]) ? (-1) : (0);
1014 }
1015
1016
1018 p->priv_gt = (
int *)
malloc(
p->cog_num *
sizeof(
int));
1022 pr = 0;
1023 for (i = 0; i <
p->cog_num; i++) {
1024 tk = -1;
1025 bk = -1.0;
1026 pw = pr;
1027 while ((j =
p->cog_list[pr++]) >= 0) {
1029
1030 if (
p->area[j] > bk) {
1031 tk = j;
1033 }
1034 }
1035 }
1037
1038 p->priv_ii[tk] = -2 - i;
1041 }
1044 pr = 0;
1045 for (i = 0; i <
p->cog_num; i++) {
1046 while ((j =
p->cog_list[pr]) >= 0) {
1047 p->priv_gw[pr] =
p->area[j] /
p->priv_gm[i];
1048 pr++;
1049 }
1050 p->priv_gw[pr] = -1.0;
1051 pr++;
1052 }
1053 }
1054
1055
1057 for (i =
p->num_cells; i--;) {
1058 if (!
p->priv_ii[i]) {
1059 p->priv_ii[i] = 2 * (
p->priv_n++);
1060 }
1061 }
1063
1064#if (QPS_DEBUG > 5)
1065 for (i = 0; i <
p->num_cells; i++) {
1066 fprintf(
p->priv_fp,
"### ii %d %d\n", i,
p->priv_ii[i]);
1067 }
1068#endif
1069
1070#if defined(QPS_PRECON)
1075 for (i =
p->num_cells; i--;) {
1076 p->priv_pcg[i] = 0.0;
1077 }
1078 pr = 0;
1079 for (i = 0; i <
p->num_cells; i++) {
1080 while ((c =
p->priv_cc[pr]) >= 0) {
1082 p->priv_pcg[i] += t;
1083 p->priv_pcg[c] += t;
1084 pr++;
1085 }
1086 pr++;
1087 }
1088 pr = 0;
1089 for (i = 0; i <
p->loop_num; i++) {
1090 t = 2.0 *
p->loop_penalty[i];
1091 while ((c =
p->loop_list[pr++]) >= 0) {
1092 p->priv_pcg[c] += t;
1093 }
1094 pr++;
1095 }
1096#if (QPS_DEBUG > 6)
1097 for (i =
p->num_cells; i--;) {
1098 fprintf(
p->priv_fp,
"### precon %d %.2e\n", i,
p->priv_pcg[i]);
1099 }
1100#endif
1101 for (i =
p->priv_n; i--;) {
1102 p->priv_pcgt[i] = 0.0;
1103 }
1104 for (i = 0; i <
p->num_cells; i++) {
1106 if (c >= 0) {
1108 p->priv_pcgt[c] += t;
1109 p->priv_pcgt[c + 1] += t;
1110 }
1111#if 0
1112 else if (c < -1) {
1113 pr =
p->priv_gt[-(c+2)];
1114 while ((j =
p->cog_list[pr++]) >= 0) {
1116 if (ji >= 0) {
1117 w =
p->area[j] /
p->area[i];
1118 t = w * w *
p->priv_pcg[i];
1119 p->priv_pcgt[ji] += t;
1120 p->priv_pcgt[ji + 1] += t;
1121 }
1122 }
1123 }
1124#endif
1125 }
1126 for (i = 0; i <
p->priv_n; i++) {
1127 t =
p->priv_pcgt[i];
1129 p->priv_pcgt[i] = 1.0;
1130 }
1131 else {
1132 p->priv_pcgt[i] = 1.0 /
p->priv_pcgt[i];
1133 }
1134 }
1135#endif
1136
1137
1140
1141
1142 p->priv_g =
p->priv_cp +
p->priv_n;
1143 p->priv_h =
p->priv_cp + 2 *
p->priv_n;
1144 p->priv_xi =
p->priv_cp + 3 *
p->priv_n;
1145
1146
1147 for (i =
p->num_cells; i--;) {
1148 if (
p->priv_ii[i] >= 0) {
1149 p->priv_cp[
p->priv_ii[i]] =
p->x[i];
1150 p->priv_cp[
p->priv_ii[i] + 1] =
p->y[i];
1151 }
1152 }
1153
1157#if defined(QPS_HOIST)
1158 pr = 0;
1159 for (i=
p->loop_num; i--;) {
1160 while (
p->loop_list[pr++] >= 0) {
1161 }
1162 pr++;
1163 }
1165 p->priv_la = (
int *)
malloc(pr *
sizeof(
int));
1167 pr = 0;
1168 for (i = 0; i <
p->loop_num; i++) {
1169 j = st =
p->loop_list[pr++];
1170 while ((k =
p->loop_list[pr]) >= 0) {
1171 if (j > k) {
1172 m1 = k;
1173 m2 = j;
1174 }
1175 else {
1177 m1 = j;
1178 m2 = k;
1179 }
1180 pw =
p->priv_cr[m1];
1181 while (
p->priv_cc[pw] != m2) {
1182
1183 if (
p->priv_cc[pw] < 0) {
1184 pw = -2;
1185 break;
1186 }
1187 pw++;
1188 }
1189 p->priv_la[pr-1] = pw;
1190 j = k;
1191 pr++;
1192 }
1193 if (j > st) {
1194 m1 = st;
1195 m2 = j;
1196 }
1197 else {
1199 m1 = j;
1200 m2 = st;
1201 }
1202 pw =
p->priv_cr[m1];
1203 while (
p->priv_cc[pw] != m2) {
1204
1205 if (
p->priv_cc[pw] < 0) {
1206 pw = -2;
1207 break;
1208 }
1209 pw++;
1210 }
1211 p->priv_la[pr-1] = pw;
1212 p->priv_la[pr] = -1;
1213 pr++;
1214 }
1215#endif
1216 }
1217
1218 do {
1220 }
while (!
p->loop_done || !
p->max_done);
1221
1222
1223
1224 for (i =
p->num_cells; i--;) {
1225 p->x[i] =
p->priv_tp[i * 2];
1226 p->y[i] =
p->priv_tp[i * 2 + 1];
1227 }
1228#if (QPS_DEBUG > 5)
1229 for (i =
p->num_cells; i--;) {
1230 fprintf(
p->priv_fp,
"### cloc %d %f %f\n", i,
p->x[i],
p->y[i]);
1231 }
1232#endif
1233
1235 if (
p->max_enable) {
1237 }
1242 }
1245#if defined(QPS_HOIST)
1247#endif
1248 }
1249
1250#if defined(QPS_PRECON)
1253#endif
1254}