vpr/src/base/SetupGrid.cpp
//Create the device grid based on dimensions
Create the device grid based on dimensions
Create the device grid based on dimensions
DeviceGrid create_device_grid(std::string layout_name, const std::vector<t_grid_def>& grid_layouts, size_t width, size_t height) {
    if (layout_name == "auto") {
        VTR_ASSERT(grid_layouts.size() > 0);
        if (grid_layouts[0].grid_type == GridDefType::AUTO) {
            return build_device_grid(grid_layouts[0], width, height);
        } else {
            std::vector<const t_grid_def*> grid_layouts_view;
            grid_layouts_view.reserve(grid_layouts.size());
            for (const auto& layout : grid_layouts) {
                grid_layouts_view.push_back(&layout);
            }
            auto sort_cmp = [](const t_grid_def* lhs, const t_grid_def* rhs) {
                return lhs->width < rhs->width || lhs->height < rhs->width;
            };
            std::stable_sort(grid_layouts_view.begin(), grid_layouts_view.end(), sort_cmp);
            auto find_cmp = [&](const t_grid_def* grid_def) {
                return grid_def->width >= int(width) && grid_def->height >= int(height);
            };
            auto iter = std::find_if(grid_layouts_view.begin(), grid_layouts_view.end(), find_cmp);
            if (iter == grid_layouts_view.end()) {
                VTR_LOG_WARN(
                    "Specified device dimensions (%zux%zu) exceed those of the largest fixed-size device."
                    " Using the largest fixed-size device\n",
                    width, height);
                --iter;
            }
            const t_grid_def* layout = *iter;
            return build_device_grid(*layout, layout->width, layout->height);
        }
    } else {
        auto cmp = [&](const t_grid_def& grid_def) {
            return grid_def.name == layout_name;
        };
        auto iter = std::find_if(grid_layouts.begin(), grid_layouts.end(), cmp);
        if (iter == grid_layouts.end()) {
            std::string valid_names;
            for (size_t i = 0; i < grid_layouts.size(); ++i) {
                if (i != 0) {
                    valid_names += ", ";
                }
                valid_names += "'" + grid_layouts[i].name + "'";
            }
            VPR_FATAL_ERROR(VPR_ERROR_ARCH, "Failed to find grid layout named '%s' (valid grid layouts: %s)\n", layout_name.c_str(), valid_names.c_str());
        }
        return build_device_grid(*iter, iter->width, iter->height);
    }
}
DeviceGrid create_device_grid ( std :: string layout_name , const std :: vector < t_grid_def > & grid_layouts , size_t width , size_t height ) { if ( layout_name == " " ) { VTR_ASSERT ( grid_layouts . size ( ) > 0 ) ; if ( grid_layouts [ 0 ] . grid_type == GridDefType :: AUTO ) { return build_device_grid ( grid_layouts [ 0 ] , width , height ) ; } else { std :: vector < const t_grid_def * > grid_layouts_view ; grid_layouts_view . reserve ( grid_layouts . size ( ) ) ; for ( const auto & layout : grid_layouts ) { grid_layouts_view . push_back ( & layout ) ; } auto sort_cmp = [ ] ( const t_grid_def * lhs , const t_grid_def * rhs ) { return lhs -> width < rhs -> width || lhs -> height < rhs -> width ; } ; std :: stable_sort ( grid_layouts_view . begin ( ) , grid_layouts_view . end ( ) , sort_cmp ) ; auto find_cmp = [ & ] ( const t_grid_def * grid_def ) { return grid_def -> width >= int ( width ) && grid_def -> height >= int ( height ) ; } ; auto iter = std :: find_if ( grid_layouts_view . begin ( ) , grid_layouts_view . end ( ) , find_cmp ) ; if ( iter == grid_layouts_view . end ( ) ) { VTR_LOG_WARN ( " " " \n " , width , height ) ; -- iter ; } const t_grid_def * layout = * iter ; return build_device_grid ( * layout , layout -> width , layout -> height ) ; } } else { auto cmp = [ & ] ( const t_grid_def & grid_def ) { return grid_def . name == layout_name ; } ; auto iter = std :: find_if ( grid_layouts . begin ( ) , grid_layouts . end ( ) , cmp ) ; if ( iter == grid_layouts . end ( ) ) { std :: string valid_names ; for ( size_t i = 0 ; i < grid_layouts . size ( ) ; ++ i ) { if ( i != 0 ) { valid_names += " " ; } valid_names += " " + grid_layouts [ i ] . name + " " ; } VPR_FATAL_ERROR ( VPR_ERROR_ARCH , " \n " , layout_name . c_str ( ) , valid_names . c_str ( ) ) ; } return build_device_grid ( * iter , iter -> width , iter -> height ) ; } }
Create the device grid based on dimensions
Create the device grid based on dimensions
//Auto-size //Auto layout of the specified dimensions //Find the fixed layout close to the target size //No device larger than specified width/height, so choose largest possible //Use the specified device //Not found