-
Notifications
You must be signed in to change notification settings - Fork 72
Kmh smt #745
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
Merged
Kmh smt #745
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| #ifndef __GEM5_O3_SMT_SCHED_HH__ | ||
| #define __GEM5_O3_SMT_SCHED_HH__ | ||
|
|
||
|
|
||
| #include <vector> | ||
|
|
||
| #include <boost/circular_buffer.hpp> | ||
tastynoob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #include "base/types.hh" | ||
| #include "cpu/o3/limits.hh" | ||
|
|
||
| namespace gem5 | ||
| { | ||
|
|
||
| namespace o3 | ||
| { | ||
|
|
||
| class InstsCounter | ||
| { | ||
| // can be placed in ftq、rob、lsq、iq, etc. to count the number of instructions | ||
| uint64_t counter[MaxThreads]; | ||
| public: | ||
| InstsCounter() { | ||
| for (int i = 0; i < MaxThreads; ++i) { | ||
| counter[i] = 0; | ||
| } | ||
| } | ||
|
|
||
| uint64_t getCounter(ThreadID tid) { return counter[tid]; } | ||
| void setCounter(ThreadID tid, uint64_t value) { counter[tid] = value; } | ||
| }; | ||
|
|
||
| class SMTScheduler | ||
| { | ||
| protected: | ||
| int numThreads; | ||
| public: | ||
| SMTScheduler(int numThreads) : numThreads(numThreads) {} | ||
| virtual ThreadID getThread(); | ||
tastynoob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
tastynoob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class ICountScheduler : public SMTScheduler | ||
| { | ||
| // count of inst based smt shceduler | ||
| protected: | ||
| InstsCounter* counter; | ||
|
|
||
| public: | ||
| ICountScheduler(int numThreads, InstsCounter* counter) : SMTScheduler(numThreads), counter(counter) {} | ||
|
|
||
| ThreadID getThread() override | ||
| { | ||
| // return the thread with the least number of instructions executed | ||
| ThreadID selectedTid = 0; | ||
| uint64_t minCount = counter->getCounter(0); | ||
| for (ThreadID tid = 1; tid < numThreads; ++tid) { | ||
| uint64_t count = counter->getCounter(tid); | ||
| if (count < minCount) { | ||
| minCount = count; | ||
| selectedTid = tid; | ||
| } | ||
| } | ||
| return selectedTid; | ||
| } | ||
| }; | ||
|
|
||
| class DelayedICountScheduler : public ICountScheduler | ||
| { | ||
| // delayed count of inst based smt shceduler, which can be used to implement round-robin scheduling | ||
| protected: | ||
| boost::circular_buffer<ThreadID> timebuffer; | ||
|
|
||
| public: | ||
| DelayedICountScheduler(int numThreads, InstsCounter* counter, int delay) : ICountScheduler(numThreads, counter) | ||
| { | ||
| timebuffer.set_capacity(delay); | ||
| for (int i = 0; i < delay; ++i) { | ||
| timebuffer.push_back(i % numThreads); | ||
| } | ||
| } | ||
|
|
||
| ThreadID getThread() override | ||
| { | ||
| // return the thread with the least number of instructions executed among the threads in the timebuffer | ||
| ThreadID selectedTid = timebuffer.front(); | ||
| timebuffer.pop_front(); | ||
| timebuffer.push_back(ICountScheduler::getThread()); | ||
| return selectedTid; | ||
tastynoob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| }; | ||
|
|
||
|
|
||
| class MultiPrioritySched : public SMTScheduler | ||
| { | ||
| // multi priority based smt scheduler | ||
| private: | ||
| std::vector<InstsCounter*> counter; | ||
|
|
||
| public: | ||
| // priority: higest -> lowest | ||
| MultiPrioritySched(int numThreads, std::initializer_list<InstsCounter*> counters) | ||
| : SMTScheduler(numThreads), counter(counters) {} | ||
|
|
||
| ThreadID getThread() override | ||
| { | ||
| for (size_t i = 0; i < counter.size(); ++i) { | ||
| bool set = false; | ||
| ThreadID selectedTid = 0; | ||
| uint64_t minCount = counter[i]->getCounter(0); | ||
| for (ThreadID tid = 1; tid < numThreads; ++tid) { | ||
| uint64_t count = counter[i]->getCounter(tid); | ||
| if (count < minCount) { | ||
| minCount = count; | ||
| selectedTid = tid; | ||
| set = true; | ||
| } | ||
| } | ||
| if (set) { | ||
| return selectedTid; | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| }} | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.