ses_step_topo.c
authoryu.dongliang <18588496441@163.com>
Sun, 12 Nov 2023 09:28:20 +0000 (17:28 +0800)
committeryu.dongliang <18588496441@163.com>
Sun, 12 Nov 2023 09:28:20 +0000 (17:28 +0800)
ses_step_topo.c

index 58f0da359bec8fe9a9cdd91fcef0f85a739cf2f2..e979266109dce832d4c457d12bb91f01e42a0358 100644 (file)
@@ -297,29 +297,39 @@ static int __topo_path_xchg(ses_path_t* path0, int k0, ses_path_t* path1, int k1
 
        int i;
 
+       scf_logi("path0: %d, k0: %d ... path1: %d, k1: %d\n", path0->pins->size, k0, path1->pins->size, k1);
+
        for (i = 0; i + k0 < path0->pins->size && i + k1 < path1->pins->size; i++)
                SCF_XCHG(path0->pins->data[i + k0], path1->pins->data[i + k1]);
 
-       while (i + k0 < path0->pins->size) {
-               p         = path0->pins->data[i + k0];
+       scf_logi("path0: %d, k0: %d ... path1: %d, k1: %d, i: %d\n", path0->pins->size, k0, path1->pins->size, k1, i);
 
-               if (scf_vector_del(path0->pins, p) < 0)
-                       return -1;
+       if (i + k0 < path0->pins->size) {
 
-               if (scf_vector_add(path1->pins, p) < 0)
-                       return -ENOMEM;
-       }
+               while (i + k0 < path0->pins->size) {
+                       p         = path0->pins->data[i + k0];
 
-       while (i + k1 < path1->pins->size) {
-               p         = path1->pins->data[i + k1];
+                       if (scf_vector_del(path0->pins, p) < 0)
+                               return -1;
 
-               if (scf_vector_del(path1->pins, p) < 0)
-                       return -1;
+                       if (scf_vector_add(path1->pins, p) < 0)
+                               return -ENOMEM;
+               }
 
-               if (scf_vector_add(path0->pins, p) < 0)
-                       return -ENOMEM;
+       } else if (i + k1 < path1->pins->size) {
+
+               while (i + k1 < path1->pins->size) {
+                       p         = path1->pins->data[i + k1];
+
+                       if (scf_vector_del(path1->pins, p) < 0)
+                               return -1;
+
+                       if (scf_vector_add(path0->pins, p) < 0)
+                               return -ENOMEM;
+               }
        }
 
+       scf_logi("path0: %d, k0: %d ... path1: %d, k1: %d, i: %d\n", path0->pins->size, k0, path1->pins->size, k1, i);
        return 0;
 }
 
@@ -362,6 +372,10 @@ static int _topo_path_completes(ScfEfunction* f, scf_vector_t* paths)
                        if (path1 == path0)
                                continue;
 
+                       scf_loge("i: %d, j: %d, path1: %p\n", i, j, path1);
+                       scf_loge("i: %d, j: %d, path1->pins: %p\n", i, j, path1->pins);
+                       scf_loge("i: %d, j: %d, path1->pins->size: %d\n\n", i, j, path1->pins->size);
+
                        p2 = path1->pins->data[0];
                        p3 = path1->pins->data[path1->pins->size - 1];
 
@@ -383,12 +397,18 @@ static int _topo_path_completes(ScfEfunction* f, scf_vector_t* paths)
                                                p2->cid, p2->id, p->cid,  p->id,
                                                p0->cid, p0->id, p1->cid, p1->id);
 
+                               scf_logi("path size: %d ... %d\n", path0->pins->size, path1->pins->size);
                                int ret = __topo_path_xchg(path0, 0, path1, k + 1);
                                if (ret < 0)
                                        return ret;
+                               scf_logw("path size: %d ... %d\n", path0->pins->size, path1->pins->size);
 
                                if (path0->pins->size <= 0) {
                                        scf_loge("free path0: %d\n", path0->index);
+
+                                       if (scf_vector_del(paths, path0) < 0)
+                                               return -1;
+
                                        ses_path_free(path0);
                                        path0 = NULL;
                                }
@@ -407,12 +427,19 @@ static int _topo_path_completes(ScfEfunction* f, scf_vector_t* paths)
                                                p2->cid, p2->id, p3->cid, p3->id,
                                                p ->cid, p ->id, p1->cid, p1->id);
 
+                               scf_logi("path size: %d ... %d, k: %d\n", path0->pins->size, path1->pins->size, k);
+
                                int ret = __topo_path_xchg(path0, k, path1, path1->pins->size);
                                if (ret < 0)
                                        return ret;
+                               scf_logw("path size: %d ... %d, k: %d\n\n", path0->pins->size, path1->pins->size, k);
 
                                if (path0->pins->size <= 0) {
                                        scf_loge("free path0: %d\n", path0->index);
+
+                                       if (scf_vector_del(paths, path0) < 0)
+                                               return -1;
+
                                        ses_path_free(path0);
                                        path0 = NULL;
                                }