Skip to content

Commit

Permalink
patch scheduler interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dorhan1 committed Jul 31, 2024
1 parent c5a571e commit 6ced1a9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/Scheduler/OTAC/Scheduler_OTAC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class Scheduler_OTAC : public Scheduler
virtual void schedule() override;
double get_period() const;
virtual void reset() override;
virtual double get_throughput_est() const override;

private:
/**
* Find if there is a solution.
* Find a solution.
* @param chain An input vector of tasks descriptor with profiled time.
* @param R The input number of resources available.
* @param P The output periodicity (reciprocal of pipeline throughput).
* @param solution The output solution in the form of a vector of (n,r) pairs.
* @return A boolean depending if there is a solution or not.
*/
void SOLVE(const std::vector<task_desc_t>& chain,
const size_t R,
Expand Down
2 changes: 2 additions & 0 deletions include/Scheduler/Scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Scheduler : public tools::Interface_reset
const bool thread_pining = false,
const std::string& pinning_policy = "");
std::string perform_threads_mapping() const;
size_t get_n_alloc_ressources() const;
virtual double get_throughput_est() const; // return the estimated number of streams per second
};
} // namespace sched
} // namespace spu
Expand Down
6 changes: 6 additions & 0 deletions src/Scheduler/OTAC/Scheduler_OTAC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,9 @@ Scheduler_OTAC::reset()
Scheduler::reset();
this->P = std::numeric_limits<double>::infinity();
}

double
Scheduler_OTAC::get_throughput_est() const
{
return (1.0 / this->get_period()) * 1e9; // n streams per second
}
22 changes: 22 additions & 0 deletions src/Scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,25 @@ Scheduler::generate_pipeline()

return this->instantiate_pipeline(1, false, tools::Thread_pinning::is_init(), this->perform_threads_mapping());
}

size_t
Scheduler::get_n_alloc_ressources() const
{
if (this->solution.size() == 0)
{
std::stringstream message;
message
<< "The solution has to contain at least one element, please run the 'Scheduler::schedule' method first.";
throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());
}
size_t R = 0;
for (auto s : this->solution)
R += s.second;
return R;
}

double
Scheduler::get_throughput_est() const
{
throw tools::unimplemented_error(__FILE__, __LINE__, __func__);
}

0 comments on commit 6ced1a9

Please sign in to comment.