Skip to content

Commit

Permalink
Add TTG_ENABLE_COROUTINES CMake option and fix non-coro builds
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed May 30, 2024
1 parent df32b1e commit a9c33d4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
37 changes: 20 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ option(TTG_ENABLE_LEVEL_ZERO "Whether to TTG will look for Intel oneAPI Level Ze
option(TTG_EXAMPLES "Whether to build examples" OFF)
option(TTG_ENABLE_ASAN "Whether to enable address sanitizer" OFF)

option(TTG_ENABLE_COROUTINES "Whether to enable C++ coroutines, needed for accelerator device support" ON)
option(TTG_FETCH_BOOST "Whether to fetch+build Boost, if missing" OFF)
option(TTG_IGNORE_BUNDLED_EXTERNALS "Whether to skip installation and use of bundled external dependencies (Boost.CallableTraits)" OFF)
option(TTG_ENABLE_TRACE "Whether to enable ttg::trace() output" OFF)
Expand Down Expand Up @@ -95,23 +96,25 @@ endif (BUILD_TESTING)
# Boost
include("${PROJECT_SOURCE_DIR}/cmake/modules/FindOrFetchBoost.cmake")

# C++ coroutines, check for broken GCC releases and skip if one is found
set(SKIP_COROUTINE_DETECTION FALSE)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 11.4.0)
set(SKIP_COROUTINE_DETECTION TRUE)
elseif(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 12.1.0 AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.3.0)
set(SKIP_COROUTINE_DETECTION TRUE)
endif()
if (SKIP_COROUTINE_DETECTION)
message(WARNING "GCC with broken Coroutine support detected, disabling Coroutine support. At least GCC 11.4, 12.3, or 13.1 required.")
endif(SKIP_COROUTINE_DETECTION)
endif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")

if (NOT SKIP_COROUTINE_DETECTION)
find_package(CXXStdCoroutine MODULE REQUIRED COMPONENTS Final Experimental)
set(TTG_HAVE_COROUTINE CXXStdCoroutine_FOUND CACHE BOOL "True if the compiler has coroutine support")
endif(SKIP_COROUTINE_DETECTION)
if (TTG_ENABLE_COROUTINES)
set(SKIP_COROUTINE_DETECTION FALSE)
# C++ coroutines, check for broken GCC releases and skip if one is found
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 11.4.0)
set(SKIP_COROUTINE_DETECTION TRUE)
elseif(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 12.1.0 AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.3.0)
set(SKIP_COROUTINE_DETECTION TRUE)
endif()
if (SKIP_COROUTINE_DETECTION)
message(WARNING "GCC with broken Coroutine support detected, disabling Coroutine support. At least GCC 11.4, 12.3, or 13.1 required.")
endif(SKIP_COROUTINE_DETECTION)
endif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")

if (NOT SKIP_COROUTINE_DETECTION)
find_package(CXXStdCoroutine MODULE REQUIRED COMPONENTS Final Experimental)
set(TTG_HAVE_COROUTINE CXXStdCoroutine_FOUND CACHE BOOL "True if the compiler has coroutine support")
endif(NOT SKIP_COROUTINE_DETECTION)
endif(TTG_ENABLE_COROUTINES)


##########################
Expand Down
3 changes: 2 additions & 1 deletion ttg/ttg/coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
#define TTG_COROUTINE_H

#include "ttg/config.h"

#ifdef TTG_HAVE_COROUTINE
#include TTG_CXX_COROUTINE_HEADER

#include <algorithm>
#include <array>

#ifdef TTG_HAVE_COROUTINE

namespace ttg {

Expand Down
2 changes: 1 addition & 1 deletion ttg/ttg/parsec/ttg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1724,14 +1724,14 @@ namespace ttg_parsec {
}
task->tt->set_outputs_tls_ptr(old_output_tls_ptr);
detail::parsec_ttg_caller = nullptr;
task->suspended_task_address = suspended_task_address;
}
else
ttg::abort(); // unrecognized task id
#else // TTG_HAVE_COROUTINE
ttg::abort(); // should not happen
#endif // TTG_HAVE_COROUTINE
}
task->suspended_task_address = suspended_task_address;

if (suspended_task_address == nullptr) {
ttT *baseobj = task->tt;
Expand Down

0 comments on commit a9c33d4

Please sign in to comment.