Skip to content

Commit

Permalink
better work allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Oct 13, 2024
1 parent 0707fb0 commit cd06ef9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions inc/mkn/gpu/multi_launch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,11 @@ struct ThreadedStreamLauncher : public StreamLauncher<Datas, ThreadedStreamLaunc
return true;
}

std::pair<SFP, std::size_t> get_work(std::size_t const& start = 0) {
std::pair<SFP, std::size_t> get_work(/*std::size_t const& start = 0*/) {
std::scoped_lock<std::mutex> lk(work_);
for (std::size_t i = start; i < datas.size(); ++i) {
// for (std::size_t i = start; i < datas.size(); ++i) {
for (; work_i < datas.size(); ++work_i) {
auto const& i = work_i;
if (status[i] == SFS::BUSY) {
if (is_fn_finished(i)) status[i] = SFS::WAIT;
}
Expand All @@ -404,6 +406,7 @@ struct ThreadedStreamLauncher : public StreamLauncher<Datas, ThreadedStreamLaunc
return std::make_pair(SFP::WORK, i);
}
}
work_i = 0;
if (check_finished()) done = 1;
return std::make_pair(SFP::SKIP, 0);
}
Expand Down Expand Up @@ -437,6 +440,7 @@ struct ThreadedStreamLauncher : public StreamLauncher<Datas, ThreadedStreamLaunc

private:
bool joined = false, started = false, done = false;
std::size_t work_i = 0;
};

} // namespace mkn::gpu
Expand Down

0 comments on commit cd06ef9

Please sign in to comment.