Mercurial > hg > Papers > 2021 > soto-thesis
comparison paper/src/createTaskManager.cbc @ 3:959f4b34d6f4
add final thesis
author | soto |
---|---|
date | Tue, 09 Feb 2021 18:44:53 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:2c50fd1d115e | 3:959f4b34d6f4 |
---|---|
1 TaskManager* createTaskManagerImpl(struct Context* context, int numCPU, int numGPU, int numIO) { | |
2 struct TaskManager* taskManager = new TaskManager(); | |
3 taskManager->spawnTasks = C_spawnTasksTaskManagerImpl; | |
4 taskManager->spawn = C_spawnTaskManagerImpl; | |
5 taskManager->shutdown = C_shutdownTaskManagerImpl; | |
6 taskManager->incrementTaskCount = C_incrementTaskCountTaskManagerImpl; | |
7 taskManager->decrementTaskCount = C_decrementTaskCountTaskManagerImpl; | |
8 taskManager->setWaitTask = C_setWaitTaskTaskManagerImpl; | |
9 struct TaskManagerImpl* taskManagerImpl = new TaskManagerImpl(); | |
10 // 0...numIO-1 IOProcessor | |
11 // numIO...numIO+numGPU-1 GPUProcessor | |
12 // numIO+numGPU...numIO+numGPU+numCPU-1 CPUProcessor | |
13 taskManagerImpl->io = 0; | |
14 taskManagerImpl->gpu = numIO; | |
15 taskManagerImpl->cpu = numIO+numGPU; | |
16 taskManagerImpl->maxCPU = numIO+numGPU+numCPU; | |
17 taskManagerImpl->numWorker = taskManagerImpl->maxCPU; | |
18 taskManagerImpl->sendGPUWorkerIndex = taskManagerImpl->gpu; | |
19 taskManagerImpl->sendCPUWorkerIndex = taskManagerImpl->cpu; | |
20 taskManagerImpl->taskCount = 0; | |
21 taskManagerImpl->loopCounter = 0; | |
22 createWorkers(context, taskManagerImpl); | |
23 taskManager->taskManager = (union Data*)taskManagerImpl; | |
24 return taskManager; | |
25 } | |
26 | |
27 void createWorkers(struct Context* context, TaskManagerImpl* taskManager) { | |
28 int i = 0; | |
29 taskManager->workers = (Worker**)ALLOCATE_PTR_ARRAY(context, Worker, taskManager->maxCPU); | |
30 for (;i<taskManager->gpu;i++) { | |
31 Queue* queue = createSynchronizedQueue(context); | |
32 taskManager->workers[i] = (Worker*)createCPUWorker(context, i, queue); | |
33 } | |
34 for (;i<taskManager->cpu;i++) { | |
35 Queue* queue = createSynchronizedQueue(context); | |
36 #ifdef USE_CUDAWorker | |
37 taskManager->workers[i] = (Worker*)createCUDAWorker(context, i, queue,0); | |
38 #else | |
39 taskManager->workers[i] = (Worker*)createCPUWorker(context, i, queue); | |
40 #endif | |
41 } | |
42 for (;i<taskManager->maxCPU;i++) { | |
43 Queue* queue = createSynchronizedQueue(context); | |
44 taskManager->workers[i] = (Worker*)createCPUWorker(context, i, queue); | |
45 } | |
46 } |