Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static assert for task return and check for derived of ttg::coroutine_handle #286

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions ttg/ttg/tt.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,28 @@ namespace ttg {

#ifndef TTG_PROCESS_TT_OP_RETURN
#ifdef TTG_HAVE_COROUTINE
#define TTG_PROCESS_TT_OP_RETURN(result, id, invoke) \
{ \
using return_type = decltype(invoke); \
if constexpr (std::is_same_v<return_type, void>) { \
invoke; \
id = ttg::TaskCoroutineID::Invalid; \
} else { \
auto coro_return = invoke; \
if constexpr (std::is_same_v<decltype(coro_return), ttg::coroutine_handle<ttg::resumable_task_state>>) \
id = ttg::TaskCoroutineID::ResumableTask; \
else if constexpr (std::is_same_v<decltype(coro_return), \
ttg::coroutine_handle<ttg::device::detail::device_task_promise_type>>) \
id = ttg::TaskCoroutineID::DeviceTask; \
else \
std::abort(); \
result = coro_return.address(); \
} \
#define TTG_PROCESS_TT_OP_RETURN(result, id, invoke) \
{ \
using return_type = decltype(invoke); \
if constexpr (std::is_same_v<return_type, void>) { \
invoke; \
id = ttg::TaskCoroutineID::Invalid; \
} else { \
auto coro_return = invoke; \
static_assert(std::is_same_v<return_type, void> || \
std::is_base_of_v<ttg::coroutine_handle<ttg::resumable_task_state>, decltype(coro_return)>|| \
std::is_base_of_v<ttg::coroutine_handle<ttg::device::detail::device_task_promise_type>, \
decltype(coro_return)>); \
if constexpr (std::is_base_of_v<ttg::coroutine_handle<ttg::resumable_task_state>, decltype(coro_return)>) \
id = ttg::TaskCoroutineID::ResumableTask; \
else if constexpr (std::is_base_of_v< \
ttg::coroutine_handle<ttg::device::detail::device_task_promise_type>, \
decltype(coro_return)>) \
id = ttg::TaskCoroutineID::DeviceTask; \
else \
std::abort(); \
result = coro_return.address(); \
} \
}
#else
#define TTG_PROCESS_TT_OP_RETURN(result, id, invoke) invoke
Expand Down
Loading