Skip to content

Commit 384641e

Browse files
committed
configure time error reporting for STDPAR feature and CI test
1 parent fd1305f commit 384641e

3 files changed

Lines changed: 62 additions & 17 deletions

File tree

.github/workflows/builds.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
- os: ubuntu-22.04
1515
- os: ubuntu-22.04
1616
parallelisation: 'openmp'
17+
- os: ubuntu-22.04
18+
parallelisation: 'stdpar'
1719
env:
1820
BUILD_TYPE: Release
1921
CMAKE_FLAGS: >
@@ -59,6 +61,17 @@ jobs:
5961
-DSPIRIT_USE_OPENMP=ON
6062
$CMAKE_FLAGS
6163
64+
- name: Configure with STL parallelisation
65+
if: matrix.parallelisation == 'stdpar'
66+
shell: bash
67+
working-directory: ${{runner.workspace}}/build
68+
run: >
69+
cmake $GITHUB_WORKSPACE
70+
$BUILD_SYSTEM_FLAG
71+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
72+
$CMAKE_FLAGS
73+
-DSPIRIT_USE_STDPAR=ON
74+
6275
- name: Build
6376
shell: bash
6477
working-directory: ${{runner.workspace}}/build
@@ -80,6 +93,8 @@ jobs:
8093
parallelisation: ''
8194
- os: ubuntu-24.04
8295
parallelisation: 'openmp'
96+
- os: ubuntu-24.04
97+
parallelisation: 'stdpar'
8398
# this build cannot be configured currently
8499
# - os: ubuntu-24.04
85100
# parallelisation: "cuda"
@@ -190,6 +205,17 @@ jobs:
190205
$CMAKE_FLAGS
191206
-DSPIRIT_USE_OPENMP=ON
192207
208+
- name: Configure with STL parallelisation
209+
if: matrix.parallelisation == 'stdpar'
210+
shell: bash
211+
working-directory: ${{runner.workspace}}/build
212+
run: >
213+
cmake $GITHUB_WORKSPACE
214+
$BUILD_SYSTEM_FLAG
215+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
216+
$CMAKE_FLAGS
217+
-DSPIRIT_USE_STDPAR=ON
218+
193219
- name: Build
194220
shell: bash
195221
working-directory: ${{runner.workspace}}/build

core/CMake/FindTBB.cmake

Lines changed: 0 additions & 11 deletions
This file was deleted.

core/CMakeLists.txt

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,44 @@ endif()
232232

233233
######### TBB decisions ############################################
234234
if( SPIRIT_USE_STDPAR )
235-
include( FindTBB )
236-
if( TBB_FOUND )
237-
set( SPIRIT_COMPILE_DEFINITIONS ${SPIRIT_COMPILE_DEFINITIONS} -DSPIRIT_USE_STDPAR )
238-
message( STATUS ">> using TBB for parallel STL" )
235+
include(CheckCXXSourceCompiles)
236+
set( SOURCE_CXX17_PARALLEL_ALGORITHM "
237+
#include <execution>
238+
int main()
239+
{
240+
std::execution::seq;
241+
std::execution::par;
242+
std::execution::par_unseq;
243+
return 0;
244+
}
245+
" )
246+
check_cxx_source_compiles( "${SOURCE_CXX17_PARALLEL_ALGORITHM}"
247+
HAVE_BUILTIN_CXX17_PARALLEL_ALGORITHM )
248+
249+
if( NOT HAVE_BUILTIN_CXX17_PARALLEL_ALGORITHM )
250+
# Try to find TBB module
251+
find_package( TBB )
252+
if( TBB_FOUND )
253+
set( TBB_LIB TBB::tbb )
254+
message( STATUS ">> using TBB for parallel STL" )
255+
else()
256+
set( TBB_LIB )
257+
message( WARNING ">> TBB could not be found." )
258+
endif()
259+
# All of these symbols are required to use this feature.
260+
# So, if this compiles even if TBB was not found it should be fine.
261+
list( APPEND CMAKE_REQUIRED_LIBRARIES ${TBB_LIB} )
262+
check_cxx_source_compiles( "${SOURCE_CXX17_PARALLEL_ALGORITHM}"
263+
HAVE_TBB_CXX17_PARALLEL_ALGORITHM )
264+
set( HAVE_CXX17_PARALLEL_ALGORITHM ${HAVE_TBB_CXX17_PARALLEL_ALGORITHM} )
239265
else()
240-
message( WARNING ">> TBB could not be found." )
241-
set( SPIRIT_USE_STDPAR OFF )
266+
set( HAVE_CXX17_PARALLEL_ALGORITHM ${HAVE_BUILTIN_CXX17_PARALLEL_ALGORITHM} )
267+
endif()
268+
269+
if( NOT HAVE_CXX17_PARALLEL_ALGORITHM )
270+
message( FATAL_ERROR "C++17 execution policies are required for SPIRIT_USE_STDPAR=ON" )
242271
endif()
272+
set( SPIRIT_COMPILE_DEFINITIONS ${SPIRIT_COMPILE_DEFINITIONS} -DSPIRIT_USE_STDPAR )
243273
endif()
244274
######### TBB decisions ############################################
245275

0 commit comments

Comments
 (0)