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

Prefetcher API #180

Conversation

rajatbhatia1
Copy link
Collaborator

@rajatbhatia1 rajatbhatia1 commented Jul 16, 2024

Initial version of prefetcher API

This API proposes to separate the prefetcher interface (defined in PrefetcherIF.hpp) with actual implementation of prefetch engine (defined in PrefetchEngineIF.hpp). This approach allows the model to rapidly customize the prefetchers with multiple prefetch policies
e.g. We can create stride prefetch engine and use the same engine in L2 Prefetcher as well as L3 prefetcher.

Prefetchers that depend on external (to prefetcher) state can optionally create an Update Object deriving it from PrefetcherStateUpdateType and pass the updates to the prefetcher.

NextLinePrefetchEngine is an example implementation of PrefetchEngineIF
DataPrefetcher is an example implementation of a simple prefetcher utilizing the above engine

The files have been compile tested.
Unit testing, LSU integration is TBD and will be done after review and possible changes.

This API proposes to seperate the prefetcher interface (defined in PrefetcherIF.hpp) with
actual implementation of prefetch engine (defined in PrefetchEngineIF.hpp). This approach
allows the model to rapidly customize the prefetchers with multiple prefetch policies
e.g. We can create stride prefetch engine and use the same engine in L2 Prefetcher as well
as L3 prefetcher.

Prefetchers that depend on external (to prefetcher) state can optionally create an Update Object
deriving it from PrefetcherStateUpdateType and pass the updates to the prefetcher.

NextLinePrefetchEngine is an example implementation of PrefetchEngineIF
DataPrefetcher is an example implementation of a simple prefetcher utilizing the above engine

The files have been compile tested.
Unit testing, LSU integraion is TBD and will be done after review and possible changes.

DataPrefetcher::DataPrefetcher(sparta::TreeNode* node, const DataPrefetcherParameterSet* p) :
sparta::Unit(node),
PrefetcherIF<PrefetchEngineIF<>>(dynamic_cast<sparta::Unit*>(this)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to avoid the dynamic cast? I think you can use the getResourceAs Sparta method like this:

node->getResourceAs<sparta::Unit*>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I don't understand the need for the d_c here...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will remove the dynamic cast


//! Process the incoming memory access and send to the engine
void
DataPrefetcher::processIncomingReq(const olympia::MemoryAccessInfoPtr & mem_access_info_ptr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove new line

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

Copy link
Collaborator

@jeffnye-gh jeffnye-gh left a comment

Choose a reason for hiding this comment

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

This code looks fine to me.

I've have a question on the API larger intent/future plans. I (will) put this in the originating issue #142

Never mind I found what I was going to ask about in MemoryAccessInfo.

Copy link
Collaborator

@klingaard klingaard left a comment

Choose a reason for hiding this comment

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

Can you make a diagram on how these classes interrelate? Give this tool a try: http://mermaid.js.org/


DataPrefetcher::DataPrefetcher(sparta::TreeNode* node, const DataPrefetcherParameterSet* p) :
sparta::Unit(node),
PrefetcherIF<PrefetchEngineIF<>>(dynamic_cast<sparta::Unit*>(this)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I don't understand the need for the d_c here...

}

//! \brief Flush handler
void DataPrefetcher::handleFlush(const olympia::FlushManager::FlushingCriteria & criteria)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious, does a prefetcher really care about flushes?

Copy link
Collaborator Author

@rajatbhatia1 rajatbhatia1 Oct 21, 2024

Choose a reason for hiding this comment

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

It is a placeholder. I can imagine prefetchers making prefetch decisions based on a state change outside and may want to cancel them for performance reasons.

{
ev_gen_prefetch_.schedule(sparta::Clock::Cycle(1));
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

else { ?? } If the prefetch engine is not ready, then 1) why is this function called and 2) should you reschedule for the future in case it will be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I just realize that I already checked for isPrefetchReady(), will remove this part of conditional.
Here I am scheduling the next prefetch in queue (if I have credits)

@klingaard
Copy link
Collaborator

Hey @rajatbhatia1 where are you on this work?

@klingaard
Copy link
Collaborator

I'm going to close this PR for now until @rajatbhatia1 has more updates for us to look at.

@klingaard klingaard closed this Nov 10, 2024
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.

5 participants