示例#1
0
extern void improve_capa_critical_path(lofig_list* lofig, int optim_level)
{
   ptype_list* ptype, *ptype2;
   loins_list* loins;
   locon_list* locon;
   chain_list *lofigchain;
   losig_list* losig;
   ptype_list* long_path;
   int change=1;

   
   /*relaxation algorithm*/
   while (change) {
      change=0;
      long_path=critical_path(lofig);
      long_path=sort_capa(long_path);
      
      /* on all signals of the critical path, improve capa*/
      for (ptype=long_path; ptype; ptype=ptype->NEXT) {
         losig=(losig_list*) ptype->DATA;
         if (!losig->NAMECHAIN) {
            fprintf(stderr,"improve_capa_critical_path: no name on signal\n");
            autexit(1);
         }
         /*seek latest driver*/
         ptype2=getptype(losig->USER,LOFIGCHAIN);
         if (!ptype2) {
            fprintf(stderr,
            "improve_capa_critical_path: no lofigchain on losig '%s'\n",
            (char*) losig->NAMECHAIN->DATA);
            autexit(1);
         }
         loins=NULL;
         for (lofigchain=ptype2->DATA; lofigchain; lofigchain=lofigchain->NEXT){
            locon= (locon_list*) lofigchain->DATA;
            if (locon->DIRECTION==UNKNOWN) {
               fprintf(stderr,"BEH: 'linkage %s' isn't accepted\n",
               locon->NAME);
               autexit(1);
            }
            if (locon->TYPE==EXTERNAL || locon->DIRECTION==IN) continue;
            loins=locon->ROOT;
            if (loins_delay(loins,losig->NAMECHAIN->DATA)>ptype->TYPE) break;
         }

         /*instance has changed, re-evaluate critical path*/
         if (loins && change_instance(loins, losig, lofig, optim_level)) {
            change=1;
            break;
         }   
      }

      freeptype(long_path);
   }

}
int main (void)
{
    int test, result_idx;
    int result[101];
    long result_total[101];
    for (result_idx = 0; result_idx <= 100; result_idx++) {
        result_total[result_idx] = 0;
    }
    for (test = 0; test < NUMTEST; test ++) {
        for (result_idx = 0; result_idx <= 100; result_idx++) {
            result[result_idx] = 0;
        }
        printf("test %d started\n", test);
        node_t* p_node = testnode; /*节点指针 pointer to a vertex (node)*/
        /*初始化阶段*/
        /*Initialization stage*/
        node_init (p_node); /*节点的初始化 Initialization on nodes*/
        dag_init (); /*DAG图邻接矩阵的初始化 init on adjacent matrix of DAG*/ 
        epower_init (); /*DAG图边权值矩阵的初始化 init on edges' power matrix of DAG*/
        core_init ();	/*处理器模型的初始化 init on the processor model */

        /*随机数生成阶段*/
        /*Stage of random number generation*/
        p_node = testnode;
        empower_node (p_node);/*随机生成节点权值 Randomly generates the power of nodes*/
        dag_create ();/*DAG图邻接矩阵的随机生成 Randomly generates the adjacent matrix of the DAG.*/ 
        empower_epower ();/*DAG图边权值的随机生成 Randomly generates the power of edges.*/
        dag_makeup (); /*将DAG补全成AOE网络 Convert the DAG to Activity-on-Edge network*/
        //dag_print ();

        /*调度算法实施阶段*/
        /*Stage of implementing scheduling algorithm.*/
        for (var = 0; var <= 100; var++) {
            MIU = (float)var / 100.0;
            core_init ();
            node_recover ();
            list_init ();
            convert_dag (); /*DAG图权值的变换 Transfer the power from vertices to edges*/
            createadjlist ();
            critical_path ();  /*AOE关键路径的求解 Solving the critical path.*/
            result[var] = algorithm ();
            result_total[var] += result[var];
        }
        for (result_idx = 0; result_idx <= 100; result_idx++) {
            printf("MIU %d' total time is %d\n", result_idx, result_total[result_idx]);
        }
    }
    return 0;
}