verilog-to-routing / vtr-verilog-to-routing

Verilog to Routing -- Open Source CAD Flow for FPGA Research
https://verilogtorouting.org
Other
979 stars 378 forks source link

Remove Uses of std::iterator from VTR Libraries #2557

Open AlexandreSinger opened 1 month ago

AlexandreSinger commented 1 month ago

The std::iterator class will be deprecated in C++17:

In CI, the GCC 12 and CLANG 14 build show the deprecation warnings. There are other warnings in these builds, but the std::iterator warnings are blocking most of them.

This is fine right now since the CI is currently on Ubuntu 22.04, which comes with GCC 11.4 built-in; however, in the near future we should upgrade the CI to Ubuntu 24.04, which comes with GCC 13.3 built-in. GCC 13 is not even being tested by CI yet, but it will have the same deprecation warnings (if not these features will actually be deprecated).

We should begin to transition the use of std::iterator into their own classes. The process seems to be pretty standard, it would just require some work since some of the uses of std::iterator are in external libraries.

The current users of std::iterator in VTR are:

There may be more, but these were the ones I could find with grep. Once we clear most of these, some other may become more clear from the CI.

AlexandreSinger commented 1 month ago

This resource provides a good description of how to define a custom iterator in modern C++:

Their description of the different properties expected to be implemented is quite good:

image image

As well as a description of why adding these arguments are important:

image
AlexandreSinger commented 1 month ago

libvtrutil/src/vtr_array_view.h and libvtrutil/src/vtr_vector.h, beyond just having obviously duplicated code, have this strange comment and style of declaring something called "my_iter". I find this very strange, and I am not sure how to proceed in this case since it appears to rely on the fact that we are using std::iterator here; but I do not think this is necessary.

vaughnbetz commented 1 month ago

Thanks @AlexandreSinger . No strong preference on how you fix this, but I agree it is good to update. Pushing back to libtatum/upstreaming should be easy. capnproto won't be so easy; maybe the latest version of capnproto gets rid of this?

AlexandreSinger commented 1 month ago

@vaughnbetz Looks like you were correct. Capnproto fixed this issue 2 years ago:

Screenshot from 2024-05-27 14-03-07

This means that we may need to upgrade our version of capnproto if we want to 100% remove these warnings. Once the other uses of std::iterator are removed we can decide what to do from there. Based on the git history, we are currently on capnproto v0.9.1

In order to resolve this, we would need to rebase ourselves onto capnproto v1.0.0 at least. (v1.0.2 is the latest). I think we should update to the most recent release version (v1.0.2).

vaughnbetz commented 1 month ago

Thanks @AlexandreSinger . Yes, rebasing onto the latest seems like the best approach. Of course, we should change one thing at a time, so sorting the other iterators before trying the upgrade makes sense!

AlexandreSinger commented 1 month ago

Through looking through the CI logs, it looks like there were uses of std::iterator in Yosys as well that I did not originally see (blocked by too many warnings).

Currently we are on yosys-0.32. The developers of Yosys fixed this issue in yosys-0.37 (yosys-0.41 is the latest). Looks like we may need to upgrade Yosys as well.

@vaughnbetz I agree, we should change one thing at a time. Hopefully these upgrades go smoothly.

vaughnbetz commented 1 month ago

Sounds good. Upgrading to the latest yosys makes sense. Good topics for the vtr meeting Thursday. We should probably make a table (or slide deck) of planned upgrades and try to assign owners and a sequence.