view paper/src/sendTask.cbc @ 2:c7acb9211784

add code, figure. and paper fix content
author ryokka
date Mon, 27 Jan 2020 20:41:36 +0900
parents
children
line wrap: on
line source

__code spawnTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
    if (task->idgCount == 0) {
        goto taskSend();
    }
    goto next(...);
}

__code taskSend(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
    if (task->gpu) {
        goto taskSend1();
    } else {
        goto taskSend2();
    }
}

__code taskSend1(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
    int workerId = taskManager->sendGPUWorkerIndex;
    if(++taskManager->sendGPUWorkerIndex >= taskManager->cpu) {
        taskManager->sendGPUWorkerIndex = taskManager->gpu;
    }
    struct Queue* queue = taskManager->workers[workerId]->tasks;
    goto queue->put(task, next(...));
}

__code taskSend2(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
    int workerId = taskManager->sendCPUWorkerIndex;
    if(++taskManager->sendCPUWorkerIndex >= taskManager->maxCPU) {
        taskManager->sendCPUWorkerIndex = taskManager->cpu;
    }
    struct Queue* queue = taskManager->workers[workerId]->tasks;
    goto queue->put(task, next(...));
}