Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve merge conflicts. #2591

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
3 changes: 0 additions & 3 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ bool vpr_flow(t_vpr_setup& vpr_setup, t_arch& arch) {
vpr_analysis_flow(router_net_list, vpr_setup, arch, route_status, is_flat);
}

// write out constratins
write_vpr_constraints(vpr_setup);

//close the graphics
vpr_close_graphics(vpr_setup);

Expand Down
18 changes: 18 additions & 0 deletions vpr/src/base/vpr_constraints.cpp_back
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "vpr_constraints.h"


UserPlaceConstraints& VprConstraints::mutable_place_constraints() {
return placement_constraints_;
}

UserRouteConstraints& VprConstraints::mutable_route_constraints() {
return route_constraints_;
}

const UserPlaceConstraints& VprConstraints::place_constraints() const {
return placement_constraints_;
}

const UserRouteConstraints& VprConstraints::route_constraints() const {
return route_constraints_;
}
6 changes: 3 additions & 3 deletions vpr/src/base/vpr_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ class VprConstraints {
*
* @param net_name the route constraint
*/
void add_route_constraint(RouteConstraint rc);
void add_route_constraint(UserRouteConstraints rc);

/**
* @brief returns route constraint by index
*
* @param index the constraint index
*/
const RouteConstraint get_route_constraint_by_idx(std::size_t index) const;
const UserRouteConstraints get_route_constraint_by_idx(std::size_t index) const;

/**
* @brief returns route constraint of a specific net
*
* @param net_name the net name
*/
const RouteConstraint get_route_constraint_by_net_name(std::string net_name);
const UserRouteConstraints get_route_constraint_by_net_name(std::string net_name);

/**
* @brief returns number of route constraints
Expand Down
49 changes: 12 additions & 37 deletions vpr/src/base/vpr_constraints_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,26 @@

#include <fstream>
#include "vpr_constraints_reader.h"
#include "vtr_token.h"

void load_vpr_constraints_file(const char* read_vpr_constraints_name) {
vtr::ScopedStartFinishTimer timer("Reading VPR constraints from " + std::string(read_vpr_constraints_name));

VprConstraintsSerializer reader;

// file name from arguments could be a serial of files, seperated by colon ":"
// at this point, caller has already checked that the required constraint file name is not emtpy
int num_tokens = 0, num_file_read = 0;
bool found_file = false;
t_token* tokens = GetTokensFromString(read_vpr_constraints_name, &num_tokens);
std::string in_tokens("");
for (int i = 0; i < num_tokens; i++) {
if ((tokens[i].type == TOKEN_COLON)) { // end of one input file
found_file = true;
} else if (i == num_tokens - 1) { // end of inputs, append token anyway
in_tokens += std::string(tokens[i].data);
found_file = true;
} else {
in_tokens += std::string(tokens[i].data);
}
if (found_file) {
const char* file_name = in_tokens.c_str();
if (vtr::check_file_name_extension(file_name, ".xml")) {
try {
std::ifstream file(file_name);
void* context;
uxsd::load_vpr_constraints_xml(reader, context, file_name, file);
} catch (pugiutil::XmlError& e) {
vpr_throw(VPR_ERROR_ROUTE, file_name, e.line(), "%s", e.what());
}
} else {
VTR_LOG_WARN(
"VPR constraints file '%s' may be in incorrect format. "
"Expecting .xml format. Not reading file.\n",
file_name);
}
in_tokens.clear();
num_file_read++;
found_file = false;
if (vtr::check_file_name_extension(read_vpr_constraints_name, ".xml")) {
try {
std::ifstream file(read_vpr_constraints_name);
void* context;
uxsd::load_vpr_constraints_xml(reader, context, read_vpr_constraints_name, file);
} catch (pugiutil::XmlError& e) {
vpr_throw(VPR_ERROR_ROUTE, read_vpr_constraints_name, e.line(), "%s", e.what());
}
} else {
VTR_LOG_WARN(
"VPR constraints file '%s' may be in incorrect format. "
"Expecting .xml format. Not reading file.\n",
read_vpr_constraints_name);
}
VTR_LOG("Read in '%d' constraint file(s) successfully.\n", num_file_read);
freeTokens(tokens, num_tokens);

//Update the floorplanning constraints in the floorplanning constraints context
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/vpr_constraints_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#ifndef VPR_CONSTRAINTS_READER_H_
#define VPR_CONSTRAINTS_READER_H_

void load_vpr_constraints_files(const char* read_vpr_constraints_name);
void load_vpr_constraints_file(const char* read_vpr_constraints_name);

#endif /* VPR_CONSTRAINTS_READER_H_ */
40 changes: 3 additions & 37 deletions vpr/src/base/vpr_constraints_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define VPR_CONSTRAINTS_SERIALIZER_H_

#include "region.h"
#include "route_constraint.h"
#include "vpr_constraints.h"
#include "partition.h"
#include "partition_region.h"
Expand Down Expand Up @@ -442,53 +441,21 @@ class VprConstraintsSerializer final : public uxsd::VprConstraintsBase<VprConstr
return temp_.c_str();
}

virtual inline void set_vpr_constraints_tool_name(const char* /*tool_name*/, void*& /*ctx*/) final {
}
virtual inline void set_vpr_constraints_tool_name(const char* /*tool_name*/, void*& /*ctx*/) final {}

virtual inline void set_vpr_constraints_constraints_comment(const char* /*constraints_comment*/, void*& /*ctx*/) final {}

virtual inline const char* get_vpr_constraints_constraints_comment(void*& /*ctx*/) final {
return temp_.c_str();
}

virtual inline void preallocate_vpr_constraints_partition_list(void*& /*ctx*/, size_t) final {
}

virtual inline void* add_vpr_constraints_partition_list(void*& /*ctx*/) final {
virtual inline void* init_vpr_constraints_partition_list(void*& /*ctx*/) final {
return nullptr;
}

virtual inline void finish_vpr_constraints_partition_list(void*& /*ctx*/) final {
return;
}

virtual inline size_t num_vpr_constraints_partition_list(void*& /*ctx*/) final {
// only one or zero partion list is supported
if (constraints_.get_num_partitions()) {
return 1;
}
return 0;
}

virtual inline void* get_vpr_constraints_partition_list(int, void*& /*ctx*/) final {
return nullptr;
}

virtual inline void preallocate_vpr_constraints_global_route_constraints(void*& /*ctx*/, size_t) final {
}

virtual inline void* add_vpr_constraints_global_route_constraints(void*& /*ctx*/) final {
return nullptr;
}

virtual inline void finish_vpr_constraints_global_route_constraints(void*& /*ctx*/) final {
return;
}
virtual inline size_t num_vpr_constraints_global_route_constraints(void*& /*ctx*/) final {
return constraints_.get_route_constraint_num();
}

virtual inline void* get_vpr_constraints_global_route_constraints(int, void*& /*cts*/) final {
virtual inline void* get_vpr_constraints_partition_list(void*& /*ctx*/) final {
return nullptr;
}

Expand All @@ -499,7 +466,6 @@ class VprConstraintsSerializer final : public uxsd::VprConstraintsBase<VprConstr
return false;
}
virtual void finish_load() final {
return;
}

//temp data for writes
Expand Down
44 changes: 0 additions & 44 deletions vpr/src/base/vpr_constraints_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,6 @@
#include "region.h"
#include "re_cluster_util.h"

void write_vpr_constraints(t_vpr_setup& vpr_setup) {
auto& filename_opts = vpr_setup.FileNameOpts;
if (!filename_opts.write_vpr_constraints_file.empty()) {
std::string file_name = filename_opts.write_vpr_constraints_file;
if (vtr::check_file_name_extension(file_name.c_str(), ".xml")) {
VprConstraints constraints;

// update constraints with place info
// this is to align to original place/partion constraint behavior
const auto& placer_opts = vpr_setup.PlacerOpts;
int horizontal_partitions = placer_opts.floorplan_num_horizontal_partitions, vertical_partitions = placer_opts.floorplan_num_vertical_partitions;
if (horizontal_partitions != 0 && vertical_partitions != 0) {
setup_vpr_floorplan_constraints_cutpoints(constraints, horizontal_partitions, vertical_partitions);
} else {
setup_vpr_floorplan_constraints_one_loc(constraints, placer_opts.place_constraint_expand, placer_opts.place_constraint_subtile);
}

// update route constraints
for (int i = 0; i < g_vpr_ctx.routing().constraints.get_route_constraint_num(); i++) {
RouteConstraint rc = g_vpr_ctx.routing().constraints.get_route_constraint_by_idx(i);
// note: route constraints with regexpr in input constraint file
// is now replaced with the real net name and will not be written
// into output file
if (rc.is_valid()) {
constraints.add_route_constraint(rc);
}
}

// VprConstraintsSerializer writer(g_vpr_ctx.routing().constraints);
VprConstraintsSerializer writer(constraints);
std::fstream fp;
fp.open(file_name.c_str(), std::fstream::out | std::fstream::trunc);
fp.precision(std::numeric_limits<float>::max_digits10);
void* context;
uxsd::write_vpr_constraints_xml(writer, context, fp);
} else {
VPR_FATAL_ERROR(VPR_ERROR_ROUTE,
"Unknown extension on output %s",
file_name.c_str());
}
}
return;
}

void write_vpr_floorplan_constraints(const char* file_name, int expand, bool subtile, int horizontal_partitions, int vertical_partitions) {
VprConstraints constraints;

Expand Down
2 changes: 1 addition & 1 deletion vpr/src/tileable_rr_graph/tileable_rr_graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void build_tileable_unidir_rr_graph(const std::vector<t_physical_tile_type>& typ
}

/* No clock network support yet; Does not support flatten rr_graph yet */
check_rr_graph(device_ctx.rr_graph, types, device_ctx.rr_indexed_data, grids, device_ctx.chan_width, GRAPH_UNIDIR, OPEN, false);
check_rr_graph(device_ctx.rr_graph, types, device_ctx.rr_indexed_data, grids, device_ctx.chan_width, GRAPH_UNIDIR, false);

/************************************************************************
* Free all temp stucts
Expand Down
16 changes: 0 additions & 16 deletions vpr/src/util/vpr_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2289,22 +2289,6 @@ bool is_inter_cluster_node(const RRGraphView& rr_graph_view,
}
}

void apply_route_constraints(VprConstraints& vpr_constraint) {
ClusteringContext& mutable_cluster_ctx = g_vpr_ctx.mutable_clustering();
for (auto net_id : mutable_cluster_ctx.clb_nlist.nets()) {
std::string net_name = mutable_cluster_ctx.clb_nlist.net_name(net_id);
const RouteConstraint rc = vpr_constraint.get_route_constraint_by_net_name(net_name);
if (rc.is_valid()) {
mutable_cluster_ctx.clb_nlist.set_net_is_global(net_id, true);
if (rc.route_model() == "route") {
mutable_cluster_ctx.clb_nlist.set_net_is_ignored(net_id, false);
} else {
mutable_cluster_ctx.clb_nlist.set_net_is_ignored(net_id, true);
}
}
}
}

int get_rr_node_max_ptc(const RRGraphView& rr_graph_view,
RRNodeId node_id,
bool is_flat) {
Expand Down
Loading