vpr/src/pack/cluster.cpp
/* Add blk to list of feasible blocks sorted according to gain */
Add blk to list of feasible blocks sorted according to gain
Add blk to list of feasible blocks sorted according to gain
static void add_molecule_to_pb_stats_candidates(t_pack_molecule* molecule,
                                                std::map<AtomBlockId, float>& gain,
                                                t_pb* pb,
                                                int max_queue_size) {
    int i, j;
    for (i = 0; i < pb->pb_stats->num_feasible_blocks; i++) {
        if (pb->pb_stats->feasible_blocks[i] == molecule) {
            return; 
        }
    }
    if (pb->pb_stats->num_feasible_blocks >= max_queue_size - 1) {
        if (get_molecule_gain(molecule, gain) > get_molecule_gain(pb->pb_stats->feasible_blocks[0], gain)) {
            for (j = 0; j < pb->pb_stats->num_feasible_blocks - 1; j++) {
                if (get_molecule_gain(molecule, gain) <= get_molecule_gain(pb->pb_stats->feasible_blocks[j + 1], gain)) {
                    pb->pb_stats->feasible_blocks[j] = molecule;
                    break;
                } else {
                    pb->pb_stats->feasible_blocks[j] = pb->pb_stats->feasible_blocks[j + 1];
                }
            }
            if (j == pb->pb_stats->num_feasible_blocks - 1) {
                pb->pb_stats->feasible_blocks[j] = molecule;
            }
        }
    } else {
        for (j = pb->pb_stats->num_feasible_blocks - 1; j >= 0; j--) {
            if (get_molecule_gain(pb->pb_stats->feasible_blocks[j], gain) > get_molecule_gain(molecule, gain)) {
                pb->pb_stats->feasible_blocks[j + 1] = pb->pb_stats->feasible_blocks[j];
            } else {
                pb->pb_stats->feasible_blocks[j + 1] = molecule;
                break;
            }
        }
        if (j < 0) {
            pb->pb_stats->feasible_blocks[0] = molecule;
        }
        pb->pb_stats->num_feasible_blocks++;
    }
}
static void add_molecule_to_pb_stats_candidates ( t_pack_molecule * molecule , std :: map < AtomBlockId , float > & gain , t_pb * pb , int max_queue_size ) { int i , j ; for ( i = 0 ; i < pb -> pb_stats -> num_feasible_blocks ; i ++ ) { if ( pb -> pb_stats -> feasible_blocks [ i ] == molecule ) { return ; } } if ( pb -> pb_stats -> num_feasible_blocks >= max_queue_size - 1 ) { if ( get_molecule_gain ( molecule , gain ) > get_molecule_gain ( pb -> pb_stats -> feasible_blocks [ 0 ] , gain ) ) { for ( j = 0 ; j < pb -> pb_stats -> num_feasible_blocks - 1 ; j ++ ) { if ( get_molecule_gain ( molecule , gain ) <= get_molecule_gain ( pb -> pb_stats -> feasible_blocks [ j + 1 ] , gain ) ) { pb -> pb_stats -> feasible_blocks [ j ] = molecule ; break ; } else { pb -> pb_stats -> feasible_blocks [ j ] = pb -> pb_stats -> feasible_blocks [ j + 1 ] ; } } if ( j == pb -> pb_stats -> num_feasible_blocks - 1 ) { pb -> pb_stats -> feasible_blocks [ j ] = molecule ; } } } else { for ( j = pb -> pb_stats -> num_feasible_blocks - 1 ; j >= 0 ; j -- ) { if ( get_molecule_gain ( pb -> pb_stats -> feasible_blocks [ j ] , gain ) > get_molecule_gain ( molecule , gain ) ) { pb -> pb_stats -> feasible_blocks [ j + 1 ] = pb -> pb_stats -> feasible_blocks [ j ] ; } else { pb -> pb_stats -> feasible_blocks [ j + 1 ] = molecule ; break ; } } if ( j < 0 ) { pb -> pb_stats -> feasible_blocks [ 0 ] = molecule ; } pb -> pb_stats -> num_feasible_blocks ++ ; } }
Add blk to list of feasible blocks sorted according to gain
Add blk to list of feasible blocks sorted according to gain
/* already in queue, do nothing */ /* maximum size for array, remove smallest gain element and sort */ /* single loop insertion sort */ /* Expand array and single loop insertion sort */