Skip to content

Commit

Permalink
rpcsx-gpu: scheduler: fix race
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Sep 1, 2024
1 parent 700e75c commit e0729f1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hw/amdgpu/device/include/amdgpu/device/gpu-scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <atomic>
#include <concepts>
#include <cstdint>
#include <deque>
#include <list>
#include <source_location>
#include <thread>
Expand Down Expand Up @@ -203,8 +204,8 @@ struct TaskChain {

class GpuScheduler {
std::list<std::thread> workThreads;
std::vector<GpuTaskLayout> tasks;
std::vector<GpuTaskLayout> delayedTasks;
std::deque<GpuTaskLayout> tasks;
std::deque<GpuTaskLayout> delayedTasks;
std::mutex taskMtx;
std::condition_variable taskCv;
std::atomic<bool> exit{false};
Expand Down Expand Up @@ -339,14 +340,14 @@ class GpuScheduler {
}
}

task = std::move(tasks.back());
tasks.pop_back();
task = std::move(tasks.front());
tasks.pop_front();
}

if (task.waitId != GpuTaskLayout::kInvalidId &&
!task.chain->isComplete(task.waitId)) {
std::unique_lock lock(taskMtx);
delayedTasks.push_back(std::move(task));
delayedTasks.push_front(std::move(task));
taskCv.notify_one();
continue;
}
Expand Down

0 comments on commit e0729f1

Please sign in to comment.