Last active
May 20, 2022 07:03
-
-
Save liuliu/dac0fc6c5d3222631c779cdb98769cca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void taskcudaresume(cudaStream_t stream, cudaError_t status, void* userdata) | |
{ | |
task_t* const task = (task_t*)userdata; | |
pthread_mutex_lock(&task->schd->mutex); | |
addtask(task->schd, task); | |
--task->schd->count.suspend; | |
pthread_cond_signal(&task->schd->cv); | |
pthread_mutex_unlock(&task->schd->mutex); | |
} | |
static void taskcudawait(task_t* const task, cudaStream_t stream) | |
{ | |
pthread_mutex_lock(&task->schd->mutex); | |
++task->schd->count.suspend; | |
cudaStreamAddCallback(stream, taskcudaresume, task, 0); | |
pthread_mutex_unlock(&task->schd->mutex); | |
// Compare to taskyield, this function doesn't do addtask(task->schd, task); | |
swapcontext(&task->schd->callee, &task->schd->caller); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment