Skip to content

Support std::list iteration & modification #2370

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ax3l
Copy link
Contributor

@ax3l ax3l commented Jul 2, 2025

Add support for iterating & modifying elements in std::list. Close #2369

  • implement insertion/removal logic
  • add simple list examples
  • add insertion/removal examples

Add support for inserting elements in `std::list`.
Close EnzymeAD#2369
@ax3l ax3l force-pushed the topic-std-list-insertion branch 3 times, most recently from 48f2dfa to fc8d65e Compare July 2, 2025 05:57
@ax3l ax3l force-pushed the topic-std-list-insertion branch from fc8d65e to cd6640d Compare July 2, 2025 06:31
@ax3l
Copy link
Contributor Author

ax3l commented Jul 2, 2025

@wsmoses there seem to be issues with iterators for the reverse pass (std::list::begin()/end()).

Should iterators work by default, especially since they just work on references and && here, or do they need extra treatment in Enzyme? :)

@wsmoses
Copy link
Member

wsmoses commented Jul 3, 2025

it should work perfectly fine, sorry can you point me to the small snippet which fails?

@ax3l ax3l changed the title Support std::list insertion Support std::list better Jul 7, 2025
@ax3l ax3l changed the title Support std::list better Support std::list iteration Jul 7, 2025
Reverse Mode has incorrect result.
@ax3l ax3l force-pushed the topic-std-list-insertion branch from 81908f0 to 9b1793a Compare July 7, 2025 19:34
@ax3l ax3l force-pushed the topic-std-list-insertion branch from 7941ef5 to c14abdc Compare July 7, 2025 19:36
Currently fails.
@ax3l ax3l force-pushed the topic-std-list-insertion branch from ba5111c to e063006 Compare July 7, 2025 19:49
@ax3l
Copy link
Contributor Author

ax3l commented Jul 7, 2025

Skipping -O0 for now to go to more important functionality.

I added a test test_modify_list that modifies a value in an existing list, which should mark the modified value in the list as active variable and track it. The runtime result is wrong, as the test still treats the list values as constants.
https://fwd.gymni.ch/gLdXSO

I think we need a special treatment for .front()?

@ax3l ax3l force-pushed the topic-std-list-insertion branch 5 times, most recently from f092368 to a74da5d Compare July 9, 2025 18:25
@ax3l ax3l force-pushed the topic-std-list-insertion branch from a74da5d to 32e6481 Compare July 9, 2025 22:23
@ax3l ax3l changed the title Support std::list iteration Support std::list iteration & modification Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] std::list Insertion
2 participants