Autodetect number of threads (remove setting). Fix some bugs.

This commit is contained in:
Henrik Rydgård committed 2021-06-12 21:06:59 +02:00
1 parent 03c79ae055
commit 0fa27ff9d7
14 files changed
+112 -40

No files matched your search

+9 -3
View File
@@ -41,9 +41,12 @@ public:
ThreadManager();
~ThreadManager();
void Init(int numWorkerThreads);
void EnqueueTask(Task *task, TaskType taskType = TaskType::CPU_COMPUTE);
void EnqueueTaskOnThread(int threadNum, Task *task, TaskType taskType = TaskType::CPU_COMPUTE);
// The distinction here is to be able to take hyper-threading into account.
// It gets even trickier when you think about mobile chips with BIG/LITTLE, but we'll
// just ignore it and let the OS handle it.
void Init(int numRealCores, int numLogicalCores);
void EnqueueTask(Task *task, TaskType taskType);
void EnqueueTaskOnThread(int threadNum, Task *task, TaskType taskType);
// Currently does nothing. It will always be best-effort - maybe it cancels,
// maybe it doesn't. Note that the id is the id() returned by the task. You need to make that
@@ -57,6 +60,9 @@ public:
private:
GlobalThreadContext *global_;
int numThreads_ = 0;
int numComputeThreads_ = 0;
friend struct ThreadContext;
};