From bae00b060b55d74010722ad806307eb569908865 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 1 Dec 2025 14:32:22 -0800 Subject: [PATCH 01/11] [lib][rr_graph] add schema_file_id to rr graph attributes --- libs/librrgraph/src/io/rr_graph.xsd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/librrgraph/src/io/rr_graph.xsd b/libs/librrgraph/src/io/rr_graph.xsd index 52dc079fb2..e44cef3cec 100644 --- a/libs/librrgraph/src/io/rr_graph.xsd +++ b/libs/librrgraph/src/io/rr_graph.xsd @@ -37,6 +37,7 @@ attribute should be the name of a xs:simpleType that defines an xs:restriction / xs:enumeration. This will be demonstrated later. --> + @@ -375,6 +376,8 @@ + + From 5a8e5727e168f4faa31274449c159255521830d8 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 1 Dec 2025 14:33:23 -0800 Subject: [PATCH 02/11] [lib][rr_graph] update generated file for rrgraph io --- libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h | 46 +++++++++++++++++-- .../src/io/gen/rr_graph_uxsdcxx_capnp.h | 9 ++-- .../src/io/gen/rr_graph_uxsdcxx_interface.h | 9 ++-- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h b/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h index 0dd0969e66..15b13ed88e 100644 --- a/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h +++ b/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h @@ -4,9 +4,9 @@ * https://github.com/duck2/uxsdcxx * Modify only if your build process doesn't involve regenerating this file. * - * Cmdline: uxsdcxx/uxsdcxx.py /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd - * Input file: /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd - * md5sum of input file: 040903603053940a1b24392c38663b59 + * Cmdline: uxsdcxx/uxsdcxx.py /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd + * Input file: /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd + * md5sum of input file: e14523c72a5db9cc83592d3baaf45780 */ #include @@ -188,6 +188,8 @@ template inline void write_rr_graph_xml(T &in, Context &context, std::ostream &os){ in.start_write(); os << ".").c_str()); @@ -2251,6 +2276,14 @@ inline enum_loc_side lex_enum_loc_side(const char *in, bool throw_on_invalid, co /* Internal loading functions, which validate and load a PugiXML DOM tree into memory. */ +inline unsigned long load_unsigned_long(const char *in, const std::function * report_error){ + unsigned long out; + out = std::strtoull(in, NULL, 10); + if(errno != 0) + noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a unsigned long.").c_str()); + return out; +} + inline int load_int(const char *in, const std::function * report_error){ int out; out = std::strtol(in, NULL, 10); @@ -3879,6 +3912,9 @@ inline void load_rr_graph(const pugi::xml_node &root, T &out, Context &context, for(pugi::xml_attribute attr = root.first_attribute(); attr; attr = attr.next_attribute()){ atok_t_rr_graph in = lex_attr_t_rr_graph(attr.name(), report_error); switch(in){ + case atok_t_rr_graph::SCHEMA_FILE_ID: + out.set_rr_graph_schema_file_id(load_unsigned_long(attr.value(), report_error), context); + break; case atok_t_rr_graph::TOOL_COMMENT: out.set_rr_graph_tool_comment(attr.value(), context); break; diff --git a/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_capnp.h b/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_capnp.h index c6d1c7eba2..de659d5645 100644 --- a/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_capnp.h +++ b/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_capnp.h @@ -4,9 +4,9 @@ * https://github.com/duck2/uxsdcxx * Modify only if your build process doesn't involve regenerating this file. * - * Cmdline: uxsdcxx/uxsdcap.py /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd - * Input file: /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd - * md5sum of input file: 040903603053940a1b24392c38663b59 + * Cmdline: uxsdcxx/uxsdcap.py /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd + * Input file: /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd + * md5sum of input file: e14523c72a5db9cc83592d3baaf45780 */ #include @@ -434,6 +434,8 @@ inline void load_rr_graph_capnp(T &out, kj::ArrayPtr data, template inline void write_rr_graph_capnp(T &in, Context &context, ucap::RrGraph::Builder &root) { in.start_write(); + if((bool)in.get_rr_graph_schema_file_id(context)) + root.setSchemaFileId(in.get_rr_graph_schema_file_id(context)); if((bool)in.get_rr_graph_tool_comment(context)) root.setToolComment(in.get_rr_graph_tool_comment(context)); if((bool)in.get_rr_graph_tool_name(context)) @@ -946,6 +948,7 @@ inline void load_rr_graph_capnp_type(const ucap::RrGraph::Reader &root, T &out, (void)report_error; (void)stack; + out.set_rr_graph_schema_file_id(root.getSchemaFileId(), context); out.set_rr_graph_tool_comment(root.getToolComment().cStr(), context); out.set_rr_graph_tool_name(root.getToolName().cStr(), context); out.set_rr_graph_tool_version(root.getToolVersion().cStr(), context); diff --git a/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_interface.h b/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_interface.h index bbaae2e5e5..743636237a 100644 --- a/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_interface.h +++ b/libs/librrgraph/src/io/gen/rr_graph_uxsdcxx_interface.h @@ -4,9 +4,9 @@ * https://github.com/duck2/uxsdcxx * Modify only if your build process doesn't involve regenerating this file. * - * Cmdline: uxsdcxx/uxsdcxx.py /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd - * Input file: /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd - * md5sum of input file: 040903603053940a1b24392c38663b59 + * Cmdline: uxsdcxx/uxsdcxx.py /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd + * Input file: /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd + * md5sum of input file: e14523c72a5db9cc83592d3baaf45780 */ #include @@ -536,8 +536,11 @@ class RrGraphBase { * * * + * * */ + virtual inline unsigned long get_rr_graph_schema_file_id(typename ContextTypes::RrGraphReadContext &ctx) = 0; + virtual inline void set_rr_graph_schema_file_id(unsigned long schema_file_id, typename ContextTypes::RrGraphWriteContext &ctx) = 0; virtual inline const char * get_rr_graph_tool_comment(typename ContextTypes::RrGraphReadContext &ctx) = 0; virtual inline void set_rr_graph_tool_comment(const char * tool_comment, typename ContextTypes::RrGraphWriteContext &ctx) = 0; virtual inline const char * get_rr_graph_tool_name(typename ContextTypes::RrGraphReadContext &ctx) = 0; From aa358f83821b812486e7415e3dee53465c975987 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 1 Dec 2025 14:34:07 -0800 Subject: [PATCH 03/11] [lib][rr_graph] update API calls for rr graph io --- libs/librrgraph/src/io/rr_graph_reader.cpp | 7 +++++++ .../src/io/rr_graph_uxsdcxx_serializer.h | 14 ++++++++++++++ libs/librrgraph/src/io/rr_graph_writer.cpp | 9 ++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index 108cad1231..4030937a52 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -13,6 +13,8 @@ * are overwritten by the rr graph file if one is specified. If an optional * identifier such as capacitance is not specified, it is set to 0 */ + +#include #include "rr_graph_reader.h" #include "rr_graph_uxsdcxx_serializer.h" @@ -85,6 +87,10 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, rr_graph_builder->set_tileable(true); } + ::capnp::Schema schema = ::capnp::Schema::from(); + unsigned long schema_file_id = schema.getProto().getScopeId(); + VTR_LOG("Schema file ID: 0x%016lx\n", schema_file_id); + RrGraphSerializer reader( graph_type, base_cost_type, @@ -108,6 +114,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, &rr_graph_builder->rr_node_metadata(), &rr_graph_builder->rr_edge_metadata(), &arch->strings, + schema_file_id, is_flat); if (vtr::check_file_name_extension(read_rr_graph_name, ".xml")) { diff --git a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h index 4ad8e5df5e..41b5262ee7 100644 --- a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h +++ b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h @@ -294,6 +294,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { MetadataStorage* rr_node_metadata, MetadataStorage>* rr_edge_metadata, vtr::string_internment* strings, + unsigned long schema_file_id, bool is_flat) : chan_width_(chan_width) , rr_nodes_(rr_nodes) @@ -319,6 +320,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { , strings_(strings) , empty_(strings_->intern_string("")) , report_error_(nullptr) + , schema_file_id_(schema_file_id) , is_flat_(is_flat) { // Initialize internal data init_side_map(); @@ -1727,6 +1729,13 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { * * */ + inline void set_rr_graph_schema_file_id(unsigned long schema_file_id, void*& /*ctx*/) final { + if (schema_file_id != schema_file_id_) { + report_error( + "Schema file ID mismatch: Expected ID 0x%016lx, but got ID 0x%016lx", + schema_file_id_, schema_file_id); + } + } inline void set_rr_graph_tool_comment(const char* tool_comment, void*& /*ctx*/) final { std::string correct_string = "Generated from arch file "; correct_string += get_arch_file_name(); @@ -1748,6 +1757,10 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { } } + inline unsigned long get_rr_graph_schema_file_id(void*& /*ctx*/) final { + return schema_file_id_; + } + inline const char* get_rr_graph_tool_comment(void*& /*ctx*/) final { temp_string_.assign("Generated from arch file "); temp_string_ += get_arch_file_name(); @@ -2181,6 +2194,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { vtr::string_internment* strings_; vtr::interned_string empty_; const std::function* report_error_; + unsigned long schema_file_id_; bool is_flat_; // Temporary data to check grid block types diff --git a/libs/librrgraph/src/io/rr_graph_writer.cpp b/libs/librrgraph/src/io/rr_graph_writer.cpp index 8cad15b6bd..32da959ccd 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.cpp +++ b/libs/librrgraph/src/io/rr_graph_writer.cpp @@ -5,7 +5,9 @@ * children tags such as timing, location, or some general * details. Each tag has attributes to describe them */ -#include "rr_graph_writer.h" + +#include + #include "rr_graph_writer.h" #include #include @@ -39,6 +41,10 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, const char* echo_file_name, bool is_flat) { + ::capnp::Schema schema = ::capnp::Schema::from(); + unsigned long schema_file_id = schema.getProto().getScopeId(); + VTR_LOG("Schema file ID: 0x%016lx\n", schema_file_id); + RrGraphSerializer reader( /*graph_type=*/e_graph_type(), /*base_cost_type=*/e_base_cost_type(), @@ -62,6 +68,7 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, &rr_graph_builder->rr_node_metadata(), &rr_graph_builder->rr_edge_metadata(), &arch->strings, + schema_file_id, is_flat); if (vtr::check_file_name_extension(file_name, ".xml")) { From 7bbc7151e56ab7ebdf49011b1bd52983fa484638 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Mon, 1 Dec 2025 14:34:31 -0800 Subject: [PATCH 04/11] [lib][rr_graph] udate capnp for rr graph --- .../gen/rr_graph_uxsdcxx.capnp | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/libs/libvtrcapnproto/gen/rr_graph_uxsdcxx.capnp b/libs/libvtrcapnproto/gen/rr_graph_uxsdcxx.capnp index d43f873838..c2400b228e 100644 --- a/libs/libvtrcapnproto/gen/rr_graph_uxsdcxx.capnp +++ b/libs/libvtrcapnproto/gen/rr_graph_uxsdcxx.capnp @@ -2,11 +2,11 @@ # https://github.com/duck2/uxsdcxx # Modify only if your build process doesn't involve regenerating this file. # -# Cmdline: uxsdcxx/uxsdcap.py /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd -# Input file: /home/soheil/vtr/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd -# md5sum of input file: 040903603053940a1b24392c38663b59 +# Cmdline: uxsdcxx/uxsdcap.py /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd +# Input file: /dsoft/amohaghegh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd +# md5sum of input file: e14523c72a5db9cc83592d3baaf45780 -@0xe7650575a8718aa2; +@0xef4b0a4204785218; using Cxx = import "/capnp/c++.capnp"; $Cxx.namespace("ucap"); @@ -235,14 +235,15 @@ struct RrEdges { } struct RrGraph { - toolComment @0 :Text; - toolName @1 :Text; - toolVersion @2 :Text; - channels @3 :Channels; - switches @4 :Switches; - segments @5 :Segments; - blockTypes @6 :BlockTypes; - grid @7 :GridLocs; - rrNodes @8 :RrNodes; - rrEdges @9 :RrEdges; + schemaFileId @0 :UInt64; + toolComment @1 :Text; + toolName @2 :Text; + toolVersion @3 :Text; + channels @4 :Channels; + switches @5 :Switches; + segments @6 :Segments; + blockTypes @7 :BlockTypes; + grid @8 :GridLocs; + rrNodes @9 :RrNodes; + rrEdges @10 :RrEdges; } From 4e96b4ba0f6938b335e8844a32d1147efcebc468 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Tue, 2 Dec 2025 06:50:49 -0800 Subject: [PATCH 05/11] [lib][rr_graph] check schema id if capnp is enabled --- libs/librrgraph/src/io/rr_graph_reader.cpp | 8 +++++--- libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h | 12 ++++++++---- libs/librrgraph/src/io/rr_graph_writer.cpp | 10 ++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index 4030937a52..09d7e414ad 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -13,8 +13,6 @@ * are overwritten by the rr graph file if one is specified. If an optional * identifier such as capacitance is not specified, it is set to 0 */ - -#include #include "rr_graph_reader.h" #include "rr_graph_uxsdcxx_serializer.h" @@ -28,6 +26,7 @@ #include "pugixml_util.hpp" #ifdef VTR_ENABLE_CAPNPROTO +# include # include "rr_graph_uxsdcxx_capnp.h" # include "mmap_file.h" #endif @@ -87,9 +86,12 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, rr_graph_builder->set_tileable(true); } + unsigned long schema_file_id = 0; +#ifdef VTR_ENABLE_CAPNPROTO ::capnp::Schema schema = ::capnp::Schema::from(); - unsigned long schema_file_id = schema.getProto().getScopeId(); + schema_file_id = schema.getProto().getScopeId(); VTR_LOG("Schema file ID: 0x%016lx\n", schema_file_id); +#endif RrGraphSerializer reader( graph_type, diff --git a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h index 41b5262ee7..7a730f9ae6 100644 --- a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h +++ b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h @@ -1730,10 +1730,14 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { * */ inline void set_rr_graph_schema_file_id(unsigned long schema_file_id, void*& /*ctx*/) final { - if (schema_file_id != schema_file_id_) { - report_error( - "Schema file ID mismatch: Expected ID 0x%016lx, but got ID 0x%016lx", - schema_file_id_, schema_file_id); + // Only check if the schema file ID is not 0. If it is 0, it means capnproto is not enabled. + // Thus, we cannot check the schema file ID mismatch. + if (schema_file_id_ != 0) { + if (schema_file_id != schema_file_id_) { + report_error( + "Schema file ID mismatch: Expected ID 0x%016lx, but got ID 0x%016lx", + schema_file_id_, schema_file_id); + } } } inline void set_rr_graph_tool_comment(const char* tool_comment, void*& /*ctx*/) final { diff --git a/libs/librrgraph/src/io/rr_graph_writer.cpp b/libs/librrgraph/src/io/rr_graph_writer.cpp index 32da959ccd..d095129512 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.cpp +++ b/libs/librrgraph/src/io/rr_graph_writer.cpp @@ -5,9 +5,7 @@ * children tags such as timing, location, or some general * details. Each tag has attributes to describe them */ - -#include - #include "rr_graph_writer.h" +#include "rr_graph_writer.h" #include #include @@ -15,6 +13,7 @@ #include "rr_graph_uxsdcxx_serializer.h" #include "rr_graph_uxsdcxx.h" #ifdef VTR_ENABLE_CAPNPROTO +# include # include "serdes_utils.h" # include "rr_graph_uxsdcxx_capnp.h" #endif @@ -41,9 +40,12 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, const char* echo_file_name, bool is_flat) { + unsigned long schema_file_id = 0; +#ifdef VTR_ENABLE_CAPNPROTO ::capnp::Schema schema = ::capnp::Schema::from(); - unsigned long schema_file_id = schema.getProto().getScopeId(); + schema_file_id = schema.getProto().getScopeId(); VTR_LOG("Schema file ID: 0x%016lx\n", schema_file_id); +#endif RrGraphSerializer reader( /*graph_type=*/e_graph_type(), From 8bf390300a3f0ba98885e3ab5bc97a82ea94cc71 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Wed, 3 Dec 2025 15:43:56 -0800 Subject: [PATCH 06/11] fix a typo --- libs/librrgraph/src/io/rr_graph.xsd | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/librrgraph/src/io/rr_graph.xsd b/libs/librrgraph/src/io/rr_graph.xsd index e44cef3cec..ac81554e0c 100644 --- a/libs/librrgraph/src/io/rr_graph.xsd +++ b/libs/librrgraph/src/io/rr_graph.xsd @@ -37,7 +37,6 @@ attribute should be the name of a xs:simpleType that defines an xs:restriction / xs:enumeration. This will be demonstrated later. --> - From 618fceebe2af20d6af90b05c58727191555e0aa3 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Thu, 4 Dec 2025 06:28:40 -0800 Subject: [PATCH 07/11] [route][rr_graph] add route_verbosity to load_rr_file --- libs/librrgraph/src/io/rr_graph_reader.cpp | 3 ++- libs/librrgraph/src/io/rr_graph_reader.h | 1 + vpr/src/route/rr_graph_generation/rr_graph.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index 09d7e414ad..f177c25057 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -73,6 +73,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, bool do_check_rr_graph, bool echo_enabled, const char* echo_file_name, + const int route_verbosity, bool is_flat) { vtr::ScopedStartFinishTimer timer("Loading routing resource graph"); @@ -90,7 +91,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, #ifdef VTR_ENABLE_CAPNPROTO ::capnp::Schema schema = ::capnp::Schema::from(); schema_file_id = schema.getProto().getScopeId(); - VTR_LOG("Schema file ID: 0x%016lx\n", schema_file_id); + VTR_LOGV(route_verbosity > 1, "Schema file ID: 0x%016lx\n", schema_file_id); #endif RrGraphSerializer reader( diff --git a/libs/librrgraph/src/io/rr_graph_reader.h b/libs/librrgraph/src/io/rr_graph_reader.h index 824270c4e3..c582dac1d6 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.h +++ b/libs/librrgraph/src/io/rr_graph_reader.h @@ -29,6 +29,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, bool do_check_rr_graph, bool echo_enabled, const char* echo_file_name, + const int route_verbosity, bool is_flat); /** diff --git a/vpr/src/route/rr_graph_generation/rr_graph.cpp b/vpr/src/route/rr_graph_generation/rr_graph.cpp index 506a35aa97..414bd1309b 100644 --- a/vpr/src/route/rr_graph_generation/rr_graph.cpp +++ b/vpr/src/route/rr_graph_generation/rr_graph.cpp @@ -460,6 +460,7 @@ void create_rr_graph(e_graph_type graph_type, router_opts.do_check_rr_graph, echo_enabled, echo_file_name, + router_opts.route_verbosity, is_flat); if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) { mutable_device_ctx.rr_graph_builder.reorder_nodes(router_opts.reorder_rr_graph_nodes_algorithm, From 95e5f3563a4cd088ce7077ee79babff9bc31d570 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Thu, 4 Dec 2025 07:25:37 -0800 Subject: [PATCH 08/11] [vpr][rr_graph] pass route verbosity to rr_graph writer --- libs/librrgraph/src/io/rr_graph_writer.cpp | 3 ++- libs/librrgraph/src/io/rr_graph_writer.h | 1 + utils/fasm/test/test_fasm.cpp | 1 + vpr/src/route/rr_graph_generation/rr_graph.cpp | 1 + vpr/test/test_vpr.cpp | 3 +++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/librrgraph/src/io/rr_graph_writer.cpp b/libs/librrgraph/src/io/rr_graph_writer.cpp index d095129512..6422caf8e2 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.cpp +++ b/libs/librrgraph/src/io/rr_graph_writer.cpp @@ -38,13 +38,14 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, const char* file_name, bool echo_enabled, const char* echo_file_name, + const int route_verbosity, bool is_flat) { unsigned long schema_file_id = 0; #ifdef VTR_ENABLE_CAPNPROTO ::capnp::Schema schema = ::capnp::Schema::from(); schema_file_id = schema.getProto().getScopeId(); - VTR_LOG("Schema file ID: 0x%016lx\n", schema_file_id); + VTR_LOGV(route_verbosity > 1, "Schema file ID: 0x%016lx\n", schema_file_id); #endif RrGraphSerializer reader( diff --git a/libs/librrgraph/src/io/rr_graph_writer.h b/libs/librrgraph/src/io/rr_graph_writer.h index d4abbd1697..f0348ad5f6 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.h +++ b/libs/librrgraph/src/io/rr_graph_writer.h @@ -23,4 +23,5 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, const char* file_name, bool echo_enabled, const char* echo_file_name, + const int route_verbosity, bool is_flat); diff --git a/utils/fasm/test/test_fasm.cpp b/utils/fasm/test/test_fasm.cpp index a44040d645..4d4316ea96 100644 --- a/utils/fasm/test/test_fasm.cpp +++ b/utils/fasm/test/test_fasm.cpp @@ -295,6 +295,7 @@ TEST_CASE("fasm_integration_test", "[fasm]") { kRrGraphFile, echo_enabled, echo_file_name, + vpr_setup.RouterOpts.route_verbosity, is_flat); vpr_free_all(arch, vpr_setup); } diff --git a/vpr/src/route/rr_graph_generation/rr_graph.cpp b/vpr/src/route/rr_graph_generation/rr_graph.cpp index 414bd1309b..6a1b012da5 100644 --- a/vpr/src/route/rr_graph_generation/rr_graph.cpp +++ b/vpr/src/route/rr_graph_generation/rr_graph.cpp @@ -587,6 +587,7 @@ void create_rr_graph(e_graph_type graph_type, det_routing_arch.write_rr_graph_filename.c_str(), echo_enabled, echo_file_name, + router_opts.route_verbosity, is_flat); } } diff --git a/vpr/test/test_vpr.cpp b/vpr/test/test_vpr.cpp index 8ed11f809b..f2585647e1 100644 --- a/vpr/test/test_vpr.cpp +++ b/vpr/test/test_vpr.cpp @@ -168,6 +168,7 @@ TEST_CASE("read_rr_graph_metadata", "[vpr]") { kRrGraphFile, echo_enabled, echo_file_name, + vpr_setup.RouterOpts.route_verbosity, false); vpr_free_all(arch, vpr_setup); } @@ -290,6 +291,7 @@ TEST_CASE("read_rr_edge_override", "[vpr]") { rr_graph_filename.c_str(), echo_enabled, echo_file_name, + vpr_setup.RouterOpts.route_verbosity, false); vpr_free_all(arch, vpr_setup); @@ -334,6 +336,7 @@ TEST_CASE("read_rr_edge_override", "[vpr]") { overridden_rr_graph_filename.c_str(), echo_enabled, echo_file_name, + vpr_setup.RouterOpts.route_verbosity, false); vpr_free_all(arch, vpr_setup); From 974af1f4ff5c07f907a877aceaefa48813b6086c Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Thu, 4 Dec 2025 07:35:09 -0800 Subject: [PATCH 09/11] add comment --- libs/librrgraph/src/io/rr_graph_reader.cpp | 4 ++++ libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h | 7 +++++-- libs/librrgraph/src/io/rr_graph_writer.cpp | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index f177c25057..e500e73eb6 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -87,6 +87,10 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, rr_graph_builder->set_tileable(true); } + // If Cap'n Proto is enabled, a unique ID is assigned to the schema used to serialize the RR graph. + // This ID is used to verify that the schema used to serialize the RR graph matches the + // schema being used to deserialize it. + // If Cap'n Proto is not enabled, the schema ID is 0 and no schema ID check is performed. unsigned long schema_file_id = 0; #ifdef VTR_ENABLE_CAPNPROTO ::capnp::Schema schema = ::capnp::Schema::from(); diff --git a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h index 7a730f9ae6..8619faf137 100644 --- a/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h +++ b/libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h @@ -1730,8 +1730,11 @@ class RrGraphSerializer final : public uxsd::RrGraphBase { * */ inline void set_rr_graph_schema_file_id(unsigned long schema_file_id, void*& /*ctx*/) final { - // Only check if the schema file ID is not 0. If it is 0, it means capnproto is not enabled. - // Thus, we cannot check the schema file ID mismatch. + // Only check if schema_file_id_ (set when initializing the class) is not 0. + // If it is 0, it means Cap'n Proto is not enabled, so we cannot check for a schema file ID mismatch. + // This function is only called when the RR graph file being read contains a schema file ID. + // If it does not, this function is not called, and the RR graph can be read without performing + // the schema file ID check. if (schema_file_id_ != 0) { if (schema_file_id != schema_file_id_) { report_error( diff --git a/libs/librrgraph/src/io/rr_graph_writer.cpp b/libs/librrgraph/src/io/rr_graph_writer.cpp index 6422caf8e2..ad2b8ea945 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.cpp +++ b/libs/librrgraph/src/io/rr_graph_writer.cpp @@ -41,6 +41,10 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, const int route_verbosity, bool is_flat) { + // If Cap'n Proto is enabled, a unique ID is assigned to the schema used to serialize the RR graph. + // This ID is used to verify that the schema used to serialize the RR graph matches the + // schema being used to deserialize it. + // If Cap'n Proto is not enabled, the schema ID is 0 and no schema ID check is performed. unsigned long schema_file_id = 0; #ifdef VTR_ENABLE_CAPNPROTO ::capnp::Schema schema = ::capnp::Schema::from(); From 4faf21fac7b35fe1c61672e6ecad6d1255a23cb7 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Thu, 4 Dec 2025 07:48:33 -0800 Subject: [PATCH 10/11] [lib][rr_graph] add ifdef guard around route_verbosity --- libs/librrgraph/src/io/rr_graph_reader.cpp | 4 ++++ libs/librrgraph/src/io/rr_graph_writer.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index e500e73eb6..bd2ebb20b2 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -73,7 +73,11 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, bool do_check_rr_graph, bool echo_enabled, const char* echo_file_name, +#ifdef VTR_ENABLE_CAPNPROTO const int route_verbosity, +#else + bool /*route_verbosity*/, +#endif bool is_flat) { vtr::ScopedStartFinishTimer timer("Loading routing resource graph"); diff --git a/libs/librrgraph/src/io/rr_graph_writer.cpp b/libs/librrgraph/src/io/rr_graph_writer.cpp index ad2b8ea945..120fcc4880 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.cpp +++ b/libs/librrgraph/src/io/rr_graph_writer.cpp @@ -38,7 +38,11 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, const char* file_name, bool echo_enabled, const char* echo_file_name, +#ifdef VTR_ENABLE_CAPNPROTO const int route_verbosity, +#else + bool /*route_verbosity*/, +#endif bool is_flat) { // If Cap'n Proto is enabled, a unique ID is assigned to the schema used to serialize the RR graph. From 623deab3baa2c4634f317b0048ca14de535ec4d3 Mon Sep 17 00:00:00 2001 From: Amin Mohaghegh Date: Thu, 4 Dec 2025 08:16:49 -0800 Subject: [PATCH 11/11] [lib][rr_graph] void casting undused parameter --- libs/librrgraph/src/io/rr_graph_reader.cpp | 7 +++---- libs/librrgraph/src/io/rr_graph_writer.cpp | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libs/librrgraph/src/io/rr_graph_reader.cpp b/libs/librrgraph/src/io/rr_graph_reader.cpp index bd2ebb20b2..419d23669f 100644 --- a/libs/librrgraph/src/io/rr_graph_reader.cpp +++ b/libs/librrgraph/src/io/rr_graph_reader.cpp @@ -73,11 +73,7 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, bool do_check_rr_graph, bool echo_enabled, const char* echo_file_name, -#ifdef VTR_ENABLE_CAPNPROTO const int route_verbosity, -#else - bool /*route_verbosity*/, -#endif bool is_flat) { vtr::ScopedStartFinishTimer timer("Loading routing resource graph"); @@ -100,6 +96,9 @@ void load_rr_file(RRGraphBuilder* rr_graph_builder, ::capnp::Schema schema = ::capnp::Schema::from(); schema_file_id = schema.getProto().getScopeId(); VTR_LOGV(route_verbosity > 1, "Schema file ID: 0x%016lx\n", schema_file_id); +#else + // Suppress the warning about unused variable 'route_verbosity' + (void)route_verbosity; #endif RrGraphSerializer reader( diff --git a/libs/librrgraph/src/io/rr_graph_writer.cpp b/libs/librrgraph/src/io/rr_graph_writer.cpp index 120fcc4880..7e35b2eeb2 100644 --- a/libs/librrgraph/src/io/rr_graph_writer.cpp +++ b/libs/librrgraph/src/io/rr_graph_writer.cpp @@ -38,11 +38,7 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, const char* file_name, bool echo_enabled, const char* echo_file_name, -#ifdef VTR_ENABLE_CAPNPROTO const int route_verbosity, -#else - bool /*route_verbosity*/, -#endif bool is_flat) { // If Cap'n Proto is enabled, a unique ID is assigned to the schema used to serialize the RR graph. @@ -54,6 +50,9 @@ void write_rr_graph(RRGraphBuilder* rr_graph_builder, ::capnp::Schema schema = ::capnp::Schema::from(); schema_file_id = schema.getProto().getScopeId(); VTR_LOGV(route_verbosity > 1, "Schema file ID: 0x%016lx\n", schema_file_id); +#else + // Suppress the warning about unused variable 'route_verbosity' + (void)route_verbosity; #endif RrGraphSerializer reader(