11cmake_minimum_required (VERSION 3.13 FATAL_ERROR)
22
3- project (BabelStream VERSION 4.0 LANGUAGES CXX)
3+ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0" )
4+ cmake_policy (SET CMP0135 NEW)
5+ endif ()
6+
7+ project (BabelStream VERSION 5.0 LANGUAGES CXX C)
48
59# uncomment for debugging build issues:
610#set(CMAKE_VERBOSE_MAKEFILE ON)
@@ -27,8 +31,6 @@ endmacro()
2731# the final executable name
2832set (EXE_NAME babelstream)
2933
30- # select default build type
31- set (CMAKE_BUILD_TYPE "Release" )
3234# for chrono and some basic CXX features, models can overwrite this if required
3335set (CMAKE_CXX_STANDARD 11)
3436
@@ -71,6 +73,75 @@ hint_flag(CXX_EXTRA_LINKER_FLAGS "
7173# Honor user's CXX_EXTRA_LINK_FLAGS
7274set (CXX_EXTRA_LINK_FLAGS ${CXX_EXTRA_FLAGS} ${CXX_EXTRA_LINK_FLAGS} )
7375
76+ option (USE_TBB "Enable the oneTBB library for *supported* models. Enabling this on models that
77+ don't explicitly link against TBB is a no-op, see description of your selected
78+ model on how this is used." OFF )
79+
80+ option (FETCH_TBB "Fetch (download) the oneTBB library for *supported* models. This uses CMake's
81+ FetchContent feature. Specify version by setting FETCH_TBB_VERSION" OFF )
82+ set (FETCH_TBB_VERSION "v2021.10.0" CACHE STRING "Specify version of oneTBB to use if FETCH_TBB is ON" )
83+
84+ if (FETCH_TBB)
85+ FetchContent_Declare(
86+ TBB
87+ GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git
88+ GIT_TAG "${FETCH_TBB_VERSION} "
89+ )
90+ # Don't fail builds on waring (TBB has -Wall while not being free of warnings from unused symbols...)
91+ set (CMAKE_POLICY_DEFAULT_CMP0077 NEW)
92+ set (TBB_STRICT OFF )
93+ # Not using FetchContent_MakeAvailable (CMake>= 3.14) because we need EXCLUDE_FROM_ALL
94+ FetchContent_GetProperties(TBB)
95+ if (NOT TBB_POPULATED)
96+ FetchContent_Populate(TBB)
97+ add_subdirectory (${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} EXCLUDE_FROM_ALL )
98+ endif ()
99+ endif ()
100+
101+ option (USE_ONEDPL "Enable the oneDPL library for *supported* models. Enabling this on models that
102+ don't explicitly link against DPL is a no-op, see description of your selected
103+ model on how this is used." OFF )
104+
105+ option (FETCH_ONEDPL "Fetch (download) the oneDPL library for *supported* models. This uses CMake's
106+ FetchContent feature. Specify version by setting FETCH_ONEDPL_VERSION" OFF )
107+ set (FETCH_ONEDPL_VERSION "oneDPL-2022.2.0-rc1" CACHE STRING "Specify version of oneTBB to use if FETCH_ONEDPL is ON" )
108+
109+ if (FETCH_ONEDPL)
110+ FetchContent_Declare(
111+ oneDPL
112+ GIT_REPOSITORY https://github.com/oneapi-src/oneDPL.git
113+ GIT_TAG "${FETCH_ONEDPL_VERSION} "
114+ )
115+ string (TOLOWER ${USE_ONEDPL} ONEDPL_BACKEND)
116+ # XXX oneDPL looks for omp instead of openmp, which mismatches(!) with ONEDPL_PAR_BACKEND if using find_package
117+ if (ONEDPL_BACKEND STREQUAL "openmp" )
118+ set (ONEDPL_BACKEND omp)
119+ endif ()
120+ # Not using FetchContent_MakeAvailable (CMake>= 3.14) because we need EXCLUDE_FROM_ALL
121+ FetchContent_GetProperties(oneDPL)
122+ if (NOT oneDPL_POPULATED)
123+ FetchContent_Populate(oneDPL)
124+ if (USE_TBB)
125+ macro (find_package NAME )
126+ if ("${NAME} " STREQUAL "TBB" )
127+ message (STATUS "Discarding oneDPL's call to find_package(${NAME} ${ARGN} )" )
128+ else ()
129+ _find_package(${NAME} ${ARGN} )
130+ endif ()
131+ endmacro ()
132+ endif ()
133+ add_subdirectory (${onedpl_SOURCE_DIR} ${onedpl_BINARY_DIR} EXCLUDE_FROM_ALL )
134+
135+ # Fixup oneDPL's omission on setting DPCPP definitions.
136+ # We do this after the creation of the oneDPL target.
137+ if (ONEDPL_BACKEND MATCHES "^(dpcpp|dpcpp_only)$" )
138+ target_compile_definitions (oneDPL INTERFACE ONEDPL_USE_DPCPP_BACKEND=1)
139+ endif ()
140+
141+ endif ()
142+ endif ()
143+
144+
74145# include our macros
75146include (cmake/register_models.cmake)
76147
@@ -84,12 +155,14 @@ register_model(hip HIP HIPStream.cpp)
84155register_model(cuda CUDA CUDAStream.cu)
85156register_model(kokkos KOKKOS KokkosStream.cpp)
86157register_model(sycl SYCL SYCLStream.cpp)
87- register_model(sycl2020 SYCL2020 SYCLStream2020.cpp)
158+ register_model(sycl2020-acc SYCL2020 SYCLStream2020.cpp)
159+ register_model(sycl2020-usm SYCL2020 SYCLStream2020.cpp)
88160register_model(acc ACC ACCStream.cpp)
89161# defining RAJA collides with the RAJA namespace so USE_RAJA
90162register_model(raja USE_RAJA RAJAStream.cpp)
91163register_model(tbb TBB TBBStream.cpp)
92164register_model(thrust THRUST ThrustStream.cu) # Thrust uses cu, even for rocThrust
165+ register_model(futhark FUTHARK FutharkStream.cpp)
93166
94167
95168set (USAGE ON CACHE BOOL "Whether to print all custom flags for the selected model" )
@@ -101,6 +174,12 @@ else ()
101174 message (STATUS "Selected model : ${MODEL} " )
102175endif ()
103176
177+ if (MODEL STREQUAL "sycl2020" )
178+ message (FATAL_ERROR "
179+ Model sycl2020 has been renamed to sycl2020-acc, and a new sycl2020-usm model is now available.
180+ Please use sycl2020-acc for SYCL2020 style accessors and sycl2020-usm for USM" )
181+ endif ()
182+
104183# load the $MODEL.cmake file and setup the correct IMPL_* based on $MODEL
105184load_model(${MODEL} )
106185
@@ -151,6 +230,7 @@ include_directories(src)
151230add_executable (${EXE_NAME} ${IMPL_SOURCES} src/main.cpp)
152231target_link_libraries (${EXE_NAME} PUBLIC ${LINK_LIBRARIES} )
153232target_compile_definitions (${EXE_NAME} PUBLIC ${IMPL_DEFINITIONS} )
233+ target_include_directories (${EXE_NAME} PUBLIC ${IMPL_DIRECTORIES} )
154234
155235if (CXX_EXTRA_LIBRARIES)
156236 target_link_libraries (${EXE_NAME} PUBLIC ${CXX_EXTRA_LIBRARIES} )
0 commit comments