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

MmioPatterns optimisation #1607

Open
wants to merge 10 commits into
base: arith-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,18 @@ public static Bytes16 excision(

public static void updateTemporaryTargetRam(
MmuData mmuData, final long targetLimbOffsetToUpdate, final Bytes16 newLimb) {
final Bytes bytesPreLimb =
Bytes.repeat(
(byte) 0,
(int)
(LLARGE
* targetLimbOffsetToUpdate)); // We won't access the preLimb again, so we don't
// care
// of its value
final Bytes bytesPostLimb =
mmuData.targetRamBytes().slice((int) ((targetLimbOffsetToUpdate + 1) * LLARGE));

mmuData.targetRamBytes(Bytes.concatenate(bytesPreLimb, newLimb, bytesPostLimb));

int limbStart = (int) (LLARGE * targetLimbOffsetToUpdate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we could add a simple unit test to validate the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, @letypequividelespoubelles, I will need some help on creating a unit test as we don't have one before. I don't visualize yet the real use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe @OlivierBBB, as Francois is OOO currently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is needed when a (target) limb is updated in two times by a MMU instructions. It's the case for example for MMU instructions generating *TwoTarget MMIO instructions.
We already have some memory tests that triggers those MMIO inst.

Maybe this is the failing unit tests (not much network at the hospital, can't open the test output), but I guess it's MMIO.ram_excision or MMIO.*_to_ram_two_targets constraints that are failing.

int limbEnd = limbStart + LLARGE;
byte[] originalRam = mmuData.targetRamBytes().toArray();
int sliceSize = Math.max(0, originalRam.length - limbEnd);

int size = limbStart + newLimb.size() + sliceSize;
byte[] updatedRam = new byte[size];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here the updated ram size should be the same as the original one ram

Copy link
Collaborator

Choose a reason for hiding this comment

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

What's this method you're modifying is doing : you just want to modify a 16 bytes limb the midldle of your memory so :

  • you wipe everything before the limb (you could keep it, but as you don't need it anymore, tiu can put 0s instead)
  • you modify your 16 bytes limb
  • you keep unchanged everything that's after the unmodified limb

Not sure of what you're doing, I'm on mobile with low network

Copy link
Contributor Author

@ahamlat ahamlat Dec 4, 2024

Choose a reason for hiding this comment

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

Here the updated ram size should be the same as the original one ram

In my current implementation, it is the case, but any way, we need to follow this logic. The total size is the sum of the parts' sizes that we're putting together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure of what you're doing, I'm on mobile with low network

I'm doing the same work, but this implementation is faster as you can see in the flamegraphs

System.arraycopy(newLimb.toArray(), 0, updatedRam, limbStart, newLimb.size());
if (sliceSize > 0)
System.arraycopy(originalRam, limbEnd, updatedRam, limbStart + newLimb.size(), sliceSize);

mmuData.targetRamBytes(Bytes.wrap(updatedRam));
}
}
2 changes: 1 addition & 1 deletion linea-constraints
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should not be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why it was updated, it changed when I checkout the project. I thought it was expected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just point to latest master of constraint and it'll be ok. The tracer is currently pointing to a commit that disables the MMIO (needed for the release)

Submodule linea-constraints updated 148 files
Loading