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

Implement multi-context memory #377

Merged
merged 5 commits into from
Sep 20, 2022
Merged

Implement multi-context memory #377

merged 5 commits into from
Sep 20, 2022

Conversation

bobbinth
Copy link
Contributor

@bobbinth bobbinth commented Aug 29, 2022

This PR adds support for multiple memory contexts. Specifically:

  • Add context column to the system trace.
  • Update memory chiplet to enable multiple contexts (not just context with ID 0).
  • Update decoder to switch between contexts when call block is entered/exited.

This PR does not yet include:

  • Stack depth manipulations when CALL operation is executed.
  • Inclusion of ctx, fmtp and stack depth into block stack table.
  • Documentation updates.

These will be addressed in future PRs.

Copy link
Contributor

@grjte grjte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just a couple small things inline

assembly/src/parsers/io_ops/mem_ops.rs Outdated Show resolved Hide resolved
processor/src/chiplets/memory/segment.rs Show resolved Hide resolved
Comment on lines +317 to +325
pub fn from_ints(ctx: u32, addr: Felt, clk: u32, old_word: Word, new_word: Word) -> Self {
Self {
ctx: Felt::from(ctx),
addr,
clk: Felt::from(clk),
old_word,
new_word,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It's a bit strange that the type of addr is Felt here when the function name is from_ints (though I understand it, given the source is essentially the io_ops functions). However, it prompted me to look at things a bit more, and the types we use for addr throughout the memory module seem to be kind of inconsistent. For example, in the segment we use u64 for the map and for the get_value methods, but it seems like we always call as_int when passing the input for any calls that aren't coming from tests. In fact, it seems like those get_value methods are exclusively used for tests, with the one exception of get_old_value (this includes methods all the way up the chain, from segment to memory to processor). I don't really have a particular suggestion or change request, but something bothers me a bit here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is that when requests come from the stack, address is a Felt - but we can't use Felt's ask keys in the map since they don't implement the required traits. So, we need to convert Felt's to u64. We could change the interface to always take u64 and then the conversion would happen on the stack side - but I'd like to put more thought in whether this is the best option.

I made a couple of minor changes to make the interfaces a bit more consistent - but this does not fix the underlying issue.

Copy link
Contributor

@grjte grjte Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this makes sense. However, I think the point still stands about the get_value method and all the methods that reference it (except get_old_value). I think we have a bunch of methods that could possibly be compiled for tests only (#[cfg(test)]). There may be a restriction on this due to the integration tests. I'm not sure. But it seems wasteful to be including things if they're only used by tests

processor/src/chiplets/memory/segment.rs Outdated Show resolved Hide resolved
processor/src/chiplets/memory/tests.rs Outdated Show resolved Hide resolved
processor/src/decoder/mod.rs Outdated Show resolved Hide resolved
processor/src/decoder/tests.rs Outdated Show resolved Hide resolved
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.

2 participants