@@ -1609,15 +1609,29 @@ namespace ttg_parsec {
16091609 // get the promise which contains the views
16101610 auto dev_data = dev_task.promise ();
16111611
1612- if (dev_data.state () == ttg::device::detail::TTG_DEVICE_CORO_SENDOUT ) {
1612+
1613+ auto is_singleton = [](parsec_gpu_task_t *task)
1614+ {
1615+ parsec_list_item_t *item = &task->list_item ;
1616+ return (item->list_next == item) && (item->list_prev == item);
1617+ };
1618+
1619+
1620+ /* *
1621+ * NOTE: we can only take this short-cut if the device is a singleton, i.e., it
1622+ * is not the leader of a ring. If it is, we have to make sure we account
1623+ * for all other tasks in the ring.
1624+ */
1625+ if (dev_data.state () == ttg::device::detail::TTG_DEVICE_CORO_SENDOUT && is_singleton (gpu_task)) {
16131626 /* The device task is sending out already but we go through the device scheduler
16141627 * for a pushout. We just report this task done, no callbacks to invoke. */
16151628 return PARSEC_HOOK_RETURN_DONE ;
16161629 }
16171630
16181631 /* we're waiting for the initial transfers or for the kernel to complete */
16191632 assert (dev_data.state () == ttg::device::detail::TTG_DEVICE_CORO_WAIT_TRANSFER ||
1620- dev_data.state () == ttg::device::detail::TTG_DEVICE_CORO_WAIT_KERNEL );
1633+ dev_data.state () == ttg::device::detail::TTG_DEVICE_CORO_WAIT_KERNEL ||
1634+ dev_data.state () == ttg::device::detail::TTG_DEVICE_CORO_SENDOUT );
16211635
16221636 /* Never batch a task re-entering purely to resolve a pending kernel wait;
16231637 * only tasks fresh off their select() (WAIT_TRANSFER) can become a batch head. */
@@ -1734,6 +1748,11 @@ namespace ttg_parsec {
17341748 do {
17351749 if (member_state (cur) == ttg::device::detail::TTG_DEVICE_CORO_WAIT_KERNEL ) {
17361750 resume_member (cur);
1751+ if (member_state (cur) == ttg::device::detail::TTG_DEVICE_CORO_WAIT_BATCH ) {
1752+ throw std::runtime_error (" Repeated coop() calls are not allowed." );
1753+ }
1754+ assert (member_state (cur) == ttg::device::detail::TTG_DEVICE_CORO_SENDOUT ||
1755+ member_state (cur) == ttg::device::detail::TTG_DEVICE_CORO_COMPLETE );
17371756 }
17381757 cur = (parsec_gpu_task_t *)cur->list_item .list_next ;
17391758 } while (cur != ring_head);
0 commit comments