vpr/src/pack/output_clustering.cpp
/* Prints out one cluster (clb).  Both the external pins and the *
 * internal connections are printed out.                         */
Prints out one cluster (clb).  Both the external pins and the
internal connections are printed out.
Prints out one cluster ( clb ) . Both the external pins and the internal connections are printed out .
static void print_stats() {
    int ipin;
    unsigned int itype;
    int total_nets_absorbed;
    std::unordered_map<AtomNetId, bool> nets_absorbed;
    int *num_clb_types, *num_clb_inputs_used, *num_clb_outputs_used;
    auto& device_ctx = g_vpr_ctx.device();
    auto& atom_ctx = g_vpr_ctx.atom();
    auto& cluster_ctx = g_vpr_ctx.clustering();
    num_clb_types = num_clb_inputs_used = num_clb_outputs_used = nullptr;
    num_clb_types = (int*)vtr::calloc(device_ctx.logical_block_types.size(), sizeof(int));
    num_clb_inputs_used = (int*)vtr::calloc(device_ctx.logical_block_types.size(), sizeof(int));
    num_clb_outputs_used = (int*)vtr::calloc(device_ctx.logical_block_types.size(), sizeof(int));
    for (auto net_id : atom_ctx.nlist.nets()) {
        nets_absorbed[net_id] = true;
    }
    for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
        auto logical_block = cluster_ctx.clb_nlist.block_type(blk_id);
        auto physical_tile = pick_best_physical_type(logical_block);
        for (ipin = 0; ipin < logical_block->pb_type->num_pins; ipin++) {
            int physical_pin = get_physical_pin(physical_tile, logical_block, ipin);
            auto pin_class = physical_tile->pin_class[physical_pin];
            auto pin_class_inf = physical_tile->class_inf[pin_class];
            if (cluster_ctx.clb_nlist.block_pb(blk_id)->pb_route.empty()) {
                ClusterNetId clb_net_id = cluster_ctx.clb_nlist.block_net(blk_id, ipin);
                if (clb_net_id != ClusterNetId::INVALID()) {
                    auto net_id = atom_ctx.lookup.atom_net(clb_net_id);
                    VTR_ASSERT(net_id);
                    nets_absorbed[net_id] = false;
                    if (pin_class_inf.type == RECEIVER) {
                        num_clb_inputs_used[logical_block->index]++;
                    } else if (pin_class_inf.type == DRIVER) {
                        num_clb_outputs_used[logical_block->index]++;
                    }
                }
            } else {
                int pb_graph_pin_id = get_pb_graph_node_pin_from_block_pin(blk_id, ipin)->pin_count_in_cluster;
                const t_pb* pb = cluster_ctx.clb_nlist.block_pb(blk_id);
                if (pb->pb_route.count(pb_graph_pin_id)) {
                    auto atom_net_id = pb->pb_route[pb_graph_pin_id].atom_net_id;
                    if (atom_net_id) {
                        nets_absorbed[atom_net_id] = false;
                        if (pin_class_inf.type == RECEIVER) {
                            num_clb_inputs_used[logical_block->index]++;
                        } else if (pin_class_inf.type == DRIVER) {
                            num_clb_outputs_used[logical_block->index]++;
                        }
                    }
                }
            }
        }
        num_clb_types[logical_block->index]++;
    }
    for (itype = 0; itype < device_ctx.logical_block_types.size(); itype++) {
        if (num_clb_types[itype] == 0) {
            VTR_LOG("\t%s: # blocks: %d, average # input + clock pins used: %g, average # output pins used: %g\n",
                    device_ctx.logical_block_types[itype].name, num_clb_types[itype], 0.0, 0.0);
        } else {
            VTR_LOG("\t%s: # blocks: %d, average # input + clock pins used: %g, average # output pins used: %g\n",
                    device_ctx.logical_block_types[itype].name, num_clb_types[itype],
                    (float)num_clb_inputs_used[itype] / (float)num_clb_types[itype],
                    (float)num_clb_outputs_used[itype] / (float)num_clb_types[itype]);
        }
    }
    total_nets_absorbed = 0;
    for (auto net_id : atom_ctx.nlist.nets()) {
        if (nets_absorbed[net_id] == true) {
            total_nets_absorbed++;
        }
    }
    VTR_LOG("Absorbed logical nets %d out of %d nets, %d nets not absorbed.\n",
            total_nets_absorbed, (int)atom_ctx.nlist.nets().size(), (int)atom_ctx.nlist.nets().size() - total_nets_absorbed);
    free(num_clb_types);
    free(num_clb_inputs_used);
    free(num_clb_outputs_used);
}
static void print_stats ( ) { int ipin ; unsigned int itype ; int total_nets_absorbed ; std :: unordered_map < AtomNetId , bool > nets_absorbed ; int * num_clb_types , * num_clb_inputs_used , * num_clb_outputs_used ; auto & device_ctx = g_vpr_ctx . device ( ) ; auto & atom_ctx = g_vpr_ctx . atom ( ) ; auto & cluster_ctx = g_vpr_ctx . clustering ( ) ; num_clb_types = num_clb_inputs_used = num_clb_outputs_used = nullptr ; num_clb_types = ( int * ) vtr :: calloc ( device_ctx . logical_block_types . size ( ) , sizeof ( int ) ) ; num_clb_inputs_used = ( int * ) vtr :: calloc ( device_ctx . logical_block_types . size ( ) , sizeof ( int ) ) ; num_clb_outputs_used = ( int * ) vtr :: calloc ( device_ctx . logical_block_types . size ( ) , sizeof ( int ) ) ; for ( auto net_id : atom_ctx . nlist . nets ( ) ) { nets_absorbed [ net_id ] = true ; } for ( auto blk_id : cluster_ctx . clb_nlist . blocks ( ) ) { auto logical_block = cluster_ctx . clb_nlist . block_type ( blk_id ) ; auto physical_tile = pick_best_physical_type ( logical_block ) ; for ( ipin = 0 ; ipin < logical_block -> pb_type -> num_pins ; ipin ++ ) { int physical_pin = get_physical_pin ( physical_tile , logical_block , ipin ) ; auto pin_class = physical_tile -> pin_class [ physical_pin ] ; auto pin_class_inf = physical_tile -> class_inf [ pin_class ] ; if ( cluster_ctx . clb_nlist . block_pb ( blk_id ) -> pb_route . empty ( ) ) { ClusterNetId clb_net_id = cluster_ctx . clb_nlist . block_net ( blk_id , ipin ) ; if ( clb_net_id != ClusterNetId :: INVALID ( ) ) { auto net_id = atom_ctx . lookup . atom_net ( clb_net_id ) ; VTR_ASSERT ( net_id ) ; nets_absorbed [ net_id ] = false ; if ( pin_class_inf . type == RECEIVER ) { num_clb_inputs_used [ logical_block -> index ] ++ ; } else if ( pin_class_inf . type == DRIVER ) { num_clb_outputs_used [ logical_block -> index ] ++ ; } } } else { int pb_graph_pin_id = get_pb_graph_node_pin_from_block_pin ( blk_id , ipin ) -> pin_count_in_cluster ; const t_pb * pb = cluster_ctx . clb_nlist . block_pb ( blk_id ) ; if ( pb -> pb_route . count ( pb_graph_pin_id ) ) { auto atom_net_id = pb -> pb_route [ pb_graph_pin_id ] . atom_net_id ; if ( atom_net_id ) { nets_absorbed [ atom_net_id ] = false ; if ( pin_class_inf . type == RECEIVER ) { num_clb_inputs_used [ logical_block -> index ] ++ ; } else if ( pin_class_inf . type == DRIVER ) { num_clb_outputs_used [ logical_block -> index ] ++ ; } } } } } num_clb_types [ logical_block -> index ] ++ ; } for ( itype = 0 ; itype < device_ctx . logical_block_types . size ( ) ; itype ++ ) { if ( num_clb_types [ itype ] == 0 ) { VTR_LOG ( " \t \n " , device_ctx . logical_block_types [ itype ] . name , num_clb_types [ itype ] , 0.0 , 0.0 ) ; } else { VTR_LOG ( " \t \n " , device_ctx . logical_block_types [ itype ] . name , num_clb_types [ itype ] , ( float ) num_clb_inputs_used [ itype ] / ( float ) num_clb_types [ itype ] , ( float ) num_clb_outputs_used [ itype ] / ( float ) num_clb_types [ itype ] ) ; } } total_nets_absorbed = 0 ; for ( auto net_id : atom_ctx . nlist . nets ( ) ) { if ( nets_absorbed [ net_id ] == true ) { total_nets_absorbed ++ ; } } VTR_LOG ( " \n " , total_nets_absorbed , ( int ) atom_ctx . nlist . nets ( ) . size ( ) , ( int ) atom_ctx . nlist . nets ( ) . size ( ) - total_nets_absorbed ) ; free ( num_clb_types ) ; free ( num_clb_inputs_used ) ; free ( num_clb_outputs_used ) ; }
Prints out one cluster (clb).
Prints out one cluster ( clb ) .
/* Counters used only for statistics purposes. */ //Pin used /* TODO: print more stats */