view paper/src/sendTask.cbc @ 30:9fa82713bd5c

Add files
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Fri, 02 Feb 2018 03:42:23 +0900
parents a0f9def49535
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(...));
}