-
Notifications
You must be signed in to change notification settings - Fork 415
Providing Yosys Frontend with the Declaration of Custom Complex Blocks #2110
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
Conversation
…rchfpga, in order to output the Verilog black box module declaration of the architecture models into a Verilog file. Therefore the Yosys standalone frontend will be able to synthesis custom complex blocks, defnied in a VTR architecture file. Signed-off-by: Seyed Alireza Damghani <[email protected]>
…chfpga - Creating a directory in the VTR root, named ArchFPGA, holding the libarchfpga executable files so vtr scripts can have access to them Signed-off-by: Seyed Alireza Damghani <[email protected]>
…un command of 'write_arch_bb' to generate the declaration of complex blocks and reading them as black box by Yosys Signed-off-by: Seyed Alireza Damghani <[email protected]>
74650bb
to
0968118
Compare
Signed-off-by: Seyed Alireza Damghani <[email protected]>
…tend in HDLs Signed-off-by: Seyed Alireza Damghani <[email protected]>
The CI failure is due to a memory leak created from the new operator in libraries. See below:
==2335382==
==2335382== HEAP SUMMARY:
==2335382== in use at exit: 5,446 bytes in 14 blocks
==2335382== total heap usage: 201,367 allocs, 201,353 frees, 8,483,998 bytes allocated
==2335382==
==2335382== 12 bytes in 1 blocks are definitely lost in loss record 3 of 11
==2335382== at 0x4838DEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==2335382== by 0x498B859: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==2335382== by 0x498C625: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==2335382== by 0x14B426: ProcessDevice(pugi::xml_node, t_arch*, t_default_fc_spec&, pugiutil::loc_data const&) (read_xml_arch_file.cpp:2714)
==2335382== by 0x13575C: XmlReadArch (read_xml_arch_file.cpp:346)
==2335382== by 0x1146B9: main (write_arch_bb.cpp:47) code at 2711 //<connection_block> tag
2712 Cur = get_single_child(Node, "connection_block", loc_data);
2713 expect_only_attributes(Cur, {"input_switch_name"}, loc_data);
2714 arch->ipin_cblock_switch_name = get_attribute(Cur, "input_switch_name", loc_data).as_string();
2715
2716 //<switch_block> tag
2717 Cur = get_single_child(Node, "switch_block", loc_data); ==2335382== 194 (160 direct, 34 indirect) bytes in 1 blocks are definitely lost in loss record 9 of 11
==2335382== at 0x4838DEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==2335382== by 0x180BC9: __gnu_cxx::new_allocator<t_segment_inf>::allocate(unsigned long, void const*) (new_allocator.h:115)
==2335382== by 0x17C372: std::allocator_traits<std::allocator<t_segment_inf> >::allocate(std::allocator<t_segment_inf>&, unsigned long) (alloc_traits.h:460)
==2335382== by 0x1758B9: std::_Vector_base<t_segment_inf, std::allocator<t_segment_inf> >::_M_allocate(unsigned long) (stl_vector.h:346)
==2335382== by 0x16DAC6: std::vector<t_segment_inf, std::allocator<t_segment_inf> >::_M_default_append(unsigned long) (vector.tcc:635)
==2335382== by 0x166C1C: std::vector<t_segment_inf, std::allocator<t_segment_inf> >::resize(unsigned long) (stl_vector.h:940)
==2335382== by 0x153660: ProcessSegments(pugi::xml_node, std::vector<t_segment_inf, std::allocator<t_segment_inf> >&, t_arch_switch_inf const*, int, bool, bool, pugiutil::loc_data const&) (read_xml_arch_file.cpp:3543)
==2335382== by 0x1358F8: XmlReadArch (read_xml_arch_file.cpp:359)
==2335382== by 0x1146B9: main (write_arch_bb.cpp:47) code at 3541. /* Alloc segment list */
3542 if (NumSegs > 0) {
3543 Segs.resize(NumSegs);
3544 }
3545
3546 /* Load the segments. */
3547 Node = get_first_child(Parent, "segment", loc_data); ==2335382== 5,240 (80 direct, 5,160 indirect) bytes in 1 blocks are definitely lost in loss record 11 of 11
==2335382== at 0x4838DEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==2335382== by 0x17E685: __gnu_cxx::new_allocator<t_grid_def>::allocate(unsigned long, void const*) (new_allocator.h:115)
==2335382== by 0x1793DF: std::allocator_traits<std::allocator<t_grid_def> >::allocate(std::allocator<t_grid_def>&, unsigned long) (alloc_traits.h:460)
==2335382== by 0x171D07: std::_Vector_base<t_grid_def, std::allocator<t_grid_def> >::_M_allocate(unsigned long) (stl_vector.h:346)
==2335382== by 0x16A4A9: void std::vector<t_grid_def, std::allocator<t_grid_def> >::_M_realloc_insert<t_grid_def>(__gnu_cxx::__normal_iterator<t_grid_def*, std::vector<t_grid_def, std::allocator<t_grid_def> > >, t_grid_def&&) (vector.tcc:440)
==2335382== by 0x164D09: void std::vector<t_grid_def, std::allocator<t_grid_def> >::emplace_back<t_grid_def>(t_grid_def&&) (vector.tcc:121)
==2335382== by 0x14617C: ProcessLayout(pugi::xml_node, t_arch*, pugiutil::loc_data const&) (read_xml_arch_file.cpp:2399)
==2335382== by 0x1356C5: XmlReadArch (read_xml_arch_file.cpp:342)
==2335382== by 0x1146B9: main (write_arch_bb.cpp:47) code at 2394 VTR_ASSERT_MSG(auto_layout_cnt == 0 || auto_layout_cnt == 1, "<auto_layout> may appear at most once");
2395
2396 for (auto layout_type_tag : layout_tag.children()) {
2397 t_grid_def grid_def = ProcessGridLayout(&arch->strings, layout_type_tag, loc_data);
2398
2399 arch->grid_layouts.emplace_back(std::move(grid_def));
2400 } ==2335382== LEAK SUMMARY:
==2335382== definitely lost: 252 bytes in 3 blocks
==2335382== indirectly lost: 5,194 bytes in 11 blocks
==2335382== possibly lost: 0 bytes in 0 blocks
==2335382== still reachable: 0 bytes in 0 blocks
==2335382== suppressed: 0 bytes in 0 blocks
==2335382==
==2335382== For lists of detected and suppressed errors, rerun with: -s
==2335382== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) |
@vaughnbetz - there are a few weird memory leaks in the libarchfpga source code, which are caused by runtime memory allocation for expanding vector size or emplace back to it. Also, one of them is caused by a function call from |
@duck2 : do you knw the pugi xml code some? If you can give Seyed a hand that would be great. |
… and write_arch_bb to avoid memory leaks Signd-off-by: Seyed Alireza Damghani <[email protected]>
Thanks @vaughnbetz, for the suggestion. // previous approach, which led to memory leaks
t_arch* arch = (t_arch*)vtr::calloc(1, sizeof(t_arch));
free_arch(arch);
// new approach
t_arch arch;
free_arch(&arch); |
Description
This PR adds an ability to
libarchfpga
to generate a file that includes the declaration of non-vtr-primitive complex blocks (complex blocks that are defined by users, not adder, dual_port_ram, ...) in the Verilog format.With such a file, the Yosys standalone frontend can synthesize user-defined complex blocks as black boxes since it is provided with Verilog declarations of them.
Syntax to use
write_arch_bb
:The
write_arch_bb
executable is called by therun_vtr_flow.py
script before the Yosys frontend execution. This process generates a file namedarch_dsps.v
in the destination directory. Then this file is read by Yosys right after when Yosys reads the design files.Sample of the generated complex blocks declaration file for the
k6FracN10LB_mem20K_complexDSP_customSB_22nm
architecture:Currently, the vtr_flow/yosyslib/README.md explains how users should add and instantiate new complex blocks.
Related Issue
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: