From 86fbf7c5beb1a6aa144813f6cd4e28ca93fa8304 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Tue, 14 Apr 2026 22:15:44 +0530 Subject: [PATCH 01/12] add task_bench example using upstream StanfordLegion/task-bench Signed-off-by: guptapratykshh --- examples/CMakeLists.txt | 1 + examples/task_bench/CMakeLists.txt | 77 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 examples/task_bench/CMakeLists.txt diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9dec78fb633..77dd48c2fda 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,6 +24,7 @@ set(subdirs random_mem_access spell_check startup_shutdown + task_bench throttle tuplespace transpose diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt new file mode 100644 index 00000000000..f4ddbfd13e5 --- /dev/null +++ b/examples/task_bench/CMakeLists.txt @@ -0,0 +1,77 @@ +# Copyright (c) 2026 Pratyksh Gupta +# +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +# This example builds the HPX driver from the upstream task-bench repository +# (https://github.com/StanfordLegion/task-bench) as an external dependency. +# No task-bench source files are vendored here. + +cmake_minimum_required(VERSION 3.17) + +include(FetchContent) + +# Fetch task-bench from upstream. Pin to the commit that includes the HPX +# driver so the build is reproducible. +FetchContent_Declare( + task_bench + GIT_REPOSITORY https://github.com/StanfordLegion/task-bench.git + GIT_TAG master + SOURCE_SUBDIR hpx +) + +# Build the core library first (required by the HPX driver). +FetchContent_GetProperties(task_bench) +if(NOT task_bench_POPULATED) + FetchContent_Populate(task_bench) +endif() + +set(TASK_BENCH_CORE_DIR "${task_bench_SOURCE_DIR}/core") + +# Build the core static library. +add_library( + task_bench_core STATIC + "${TASK_BENCH_CORE_DIR}/core.cc" + "${TASK_BENCH_CORE_DIR}/core_c.cc" + "${TASK_BENCH_CORE_DIR}/core_kernel.cc" + "${TASK_BENCH_CORE_DIR}/core_random.c" + "${TASK_BENCH_CORE_DIR}/siphash.c" + "${TASK_BENCH_CORE_DIR}/timer.cc" +) +target_include_directories(task_bench_core PUBLIC "${TASK_BENCH_CORE_DIR}") +target_compile_features(task_bench_core PUBLIC cxx_std_17) +set_target_properties(task_bench_core PROPERTIES OUTPUT_NAME "core_s") + +# Build the HPX fork-join driver (intra-node parallelism, no MPI required). +if(COMMAND add_hpx_executable) + add_hpx_executable( + hpx_fork_join + SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc" + FOLDER "Examples/TaskBench" + ) +else() + find_package(HPX REQUIRED) + add_executable(hpx_fork_join "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc") + target_link_libraries(hpx_fork_join PUBLIC HPX::hpx HPX::wrap_main) +endif() +target_include_directories(hpx_fork_join PRIVATE "${TASK_BENCH_CORE_DIR}") +target_link_libraries(hpx_fork_join PUBLIC task_bench_core) + +# Optionally build the distributed driver if MPI is available. +find_package(MPI) +if(MPI_FOUND) + if(COMMAND add_hpx_executable) + add_hpx_executable( + hpx_distributed + SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" + FOLDER "Examples/TaskBench" + ) + else() + add_executable(hpx_distributed + "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc") + target_link_libraries(hpx_distributed PUBLIC HPX::hpx HPX::wrap_main) + endif() + target_include_directories(hpx_distributed PRIVATE "${TASK_BENCH_CORE_DIR}") + target_link_libraries(hpx_distributed PUBLIC task_bench_core MPI::MPI_CXX) +endif() From e1e39cf54c9e8b1761fb8a958b330664af887c0d Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Tue, 14 Apr 2026 22:30:03 +0530 Subject: [PATCH 02/12] fix cmake-format and enable C language for task_bench_core Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index f4ddbfd13e5..c6fc3eb8375 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -5,30 +5,33 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # This example builds the HPX driver from the upstream task-bench repository -# (https://github.com/StanfordLegion/task-bench) as an external dependency. -# No task-bench source files are vendored here. +# (https://github.com/StanfordLegion/task-bench) as an external dependency. No +# task-bench source files are vendored here. cmake_minimum_required(VERSION 3.17) include(FetchContent) -# Fetch task-bench from upstream. Pin to the commit that includes the HPX -# driver so the build is reproducible. -FetchContent_Declare( +# Fetch task-bench from upstream. Pin to the commit that includes the HPX driver +# so the build is reproducible. +fetchcontent_declare( task_bench GIT_REPOSITORY https://github.com/StanfordLegion/task-bench.git - GIT_TAG master - SOURCE_SUBDIR hpx + GIT_TAG master + SOURCE_SUBDIR hpx ) # Build the core library first (required by the HPX driver). -FetchContent_GetProperties(task_bench) +fetchcontent_getproperties(task_bench) if(NOT task_bench_POPULATED) - FetchContent_Populate(task_bench) + fetchcontent_populate(task_bench) endif() set(TASK_BENCH_CORE_DIR "${task_bench_SOURCE_DIR}/core") +# core_random.c and siphash.c are C files; enable C so cmake can compile them. +enable_language(C) + # Build the core static library. add_library( task_bench_core STATIC @@ -68,10 +71,11 @@ if(MPI_FOUND) FOLDER "Examples/TaskBench" ) else() - add_executable(hpx_distributed - "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc") + add_executable( + hpx_distributed "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" + ) target_link_libraries(hpx_distributed PUBLIC HPX::hpx HPX::wrap_main) endif() target_include_directories(hpx_distributed PRIVATE "${TASK_BENCH_CORE_DIR}") - target_link_libraries(hpx_distributed PUBLIC task_bench_core MPI::MPI_CXX) + target_link_libraries(hpx_distributed PUBLIC task_bench_core MPI::MPI_C) endif() From 3022d53a637a978a3263f0e3108a3fb82e6384b1 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Tue, 14 Apr 2026 23:25:15 +0530 Subject: [PATCH 03/12] fix hpx/hpx.hpp not link hpx_include explicitly Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index c6fc3eb8375..80bd8f5c7f4 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -53,6 +53,12 @@ if(COMMAND add_hpx_executable) SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc" FOLDER "Examples/TaskBench" ) + # hpx/hpx.hpp and hpx/hpx_init.hpp live in the hpx_include module + # (libs/full/include/include). Link it explicitly because the include path is + # not always propagated via HPX::hpx on all platforms. + if(TARGET hpx_include) + target_link_libraries(hpx_fork_join PRIVATE hpx_include) + endif() else() find_package(HPX REQUIRED) add_executable(hpx_fork_join "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc") @@ -70,6 +76,9 @@ if(MPI_FOUND) SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" FOLDER "Examples/TaskBench" ) + if(TARGET hpx_include) + target_link_libraries(hpx_distributed PRIVATE hpx_include) + endif() else() add_executable( hpx_distributed "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" From c9807123bedb9b8821eceaf312403c1acc86e948 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Wed, 15 Apr 2026 00:37:29 +0530 Subject: [PATCH 04/12] fix hpx/hpx.hpp not found by adding direct include path Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index 80bd8f5c7f4..849232ecb54 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -53,12 +53,11 @@ if(COMMAND add_hpx_executable) SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc" FOLDER "Examples/TaskBench" ) - # hpx/hpx.hpp and hpx/hpx_init.hpp live in the hpx_include module - # (libs/full/include/include). Link it explicitly because the include path is - # not always propagated via HPX::hpx on all platforms. - if(TARGET hpx_include) - target_link_libraries(hpx_fork_join PRIVATE hpx_include) - endif() + # hpx/hpx.hpp and hpx/hpx_init.hpp live in libs/full/include/include which + # is not always on the compile path when building inside the HPX source tree. + target_include_directories( + hpx_fork_join PRIVATE "${CMAKE_SOURCE_DIR}/libs/full/include/include" + ) else() find_package(HPX REQUIRED) add_executable(hpx_fork_join "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc") @@ -76,9 +75,9 @@ if(MPI_FOUND) SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" FOLDER "Examples/TaskBench" ) - if(TARGET hpx_include) - target_link_libraries(hpx_distributed PRIVATE hpx_include) - endif() + target_include_directories( + hpx_distributed PRIVATE "${CMAKE_SOURCE_DIR}/libs/full/include/include" + ) else() add_executable( hpx_distributed "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" From 17d437a0e9b9b966ed240cd5163b171763615cb1 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Wed, 15 Apr 2026 01:17:16 +0530 Subject: [PATCH 05/12] suppress C++ MPI bindings to fix undefined ompi symbols Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index 849232ecb54..580fe862940 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -86,4 +86,9 @@ if(MPI_FOUND) endif() target_include_directories(hpx_distributed PRIVATE "${TASK_BENCH_CORE_DIR}") target_link_libraries(hpx_distributed PUBLIC task_bench_core MPI::MPI_C) + # Suppress OpenMPI/MPICH C++ bindings header pulled in when is + # included from a C++ TU; hpx_distributed.cc only uses the C MPI API. + target_compile_definitions( + hpx_distributed PRIVATE OMPI_SKIP_MPICXX MPICH_SKIP_MPICXX + ) endif() From 24414a338793588c6d8b04a830c84b0178c805b6 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Wed, 15 Apr 2026 09:54:40 +0530 Subject: [PATCH 06/12] use hpx_include target + dist-runtime guard Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index 580fe862940..4cca46a157d 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -46,6 +46,14 @@ target_include_directories(task_bench_core PUBLIC "${TASK_BENCH_CORE_DIR}") target_compile_features(task_bench_core PUBLIC cxx_std_17) set_target_properties(task_bench_core PROPERTIES OUTPUT_NAME "core_s") +# The HPX drivers include hpx/hpx.hpp and hpx/hpx_init.hpp, which are only +# available when the distributed runtime is enabled. Skip them otherwise. +if(COMMAND add_hpx_executable) + if(NOT HPX_WITH_DISTRIBUTED_RUNTIME) + return() + endif() +endif() + # Build the HPX fork-join driver (intra-node parallelism, no MPI required). if(COMMAND add_hpx_executable) add_hpx_executable( @@ -53,11 +61,11 @@ if(COMMAND add_hpx_executable) SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc" FOLDER "Examples/TaskBench" ) - # hpx/hpx.hpp and hpx/hpx_init.hpp live in libs/full/include/include which - # is not always on the compile path when building inside the HPX source tree. - target_include_directories( - hpx_fork_join PRIVATE "${CMAKE_SOURCE_DIR}/libs/full/include/include" - ) + # hpx_include carries the libs/full/include/include path (and all its + # transitive module deps such as hpx_segmented_algorithms) that hpx/hpx.hpp + # requires. It is only defined when HPX_WITH_DISTRIBUTED_RUNTIME=ON, which is + # already guaranteed by the guard above. + target_link_libraries(hpx_fork_join PRIVATE hpx_include) else() find_package(HPX REQUIRED) add_executable(hpx_fork_join "${task_bench_SOURCE_DIR}/hpx/hpx_fork_join.cc") @@ -75,9 +83,7 @@ if(MPI_FOUND) SOURCES "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" FOLDER "Examples/TaskBench" ) - target_include_directories( - hpx_distributed PRIVATE "${CMAKE_SOURCE_DIR}/libs/full/include/include" - ) + target_link_libraries(hpx_distributed PRIVATE hpx_include) else() add_executable( hpx_distributed "${task_bench_SOURCE_DIR}/hpx/hpx_distributed.cc" From 18eac12d3b01c2405e6ac27148104f1622ae580b Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Wed, 15 Apr 2026 10:12:01 +0530 Subject: [PATCH 07/12] register targets with example pseudo-target system Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index 4cca46a157d..d021ed2ccb7 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -73,6 +73,7 @@ else() endif() target_include_directories(hpx_fork_join PRIVATE "${TASK_BENCH_CORE_DIR}") target_link_libraries(hpx_fork_join PUBLIC task_bench_core) +add_hpx_example_target_dependencies("task_bench" hpx_fork_join) # Optionally build the distributed driver if MPI is available. find_package(MPI) @@ -92,6 +93,7 @@ if(MPI_FOUND) endif() target_include_directories(hpx_distributed PRIVATE "${TASK_BENCH_CORE_DIR}") target_link_libraries(hpx_distributed PUBLIC task_bench_core MPI::MPI_C) + add_hpx_example_target_dependencies("task_bench" hpx_distributed) # Suppress OpenMPI/MPICH C++ bindings header pulled in when is # included from a C++ TU; hpx_distributed.cc only uses the C MPI API. target_compile_definitions( From 7001b6534ad5b9ba43da4c5f800af6f08492c244 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Wed, 15 Apr 2026 10:39:31 +0530 Subject: [PATCH 08/12] skip on MSVC Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index d021ed2ccb7..6973262f0e0 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -10,6 +10,12 @@ cmake_minimum_required(VERSION 3.17) +# task-bench core uses POSIX APIs (clock_gettime, etc.) that are not available +# on Windows. Skip the entire example on MSVC builds. +if(MSVC) + return() +endif() + include(FetchContent) # Fetch task-bench from upstream. Pin to the commit that includes the HPX driver From 9b774b59664bdf4754dc39d9b2ec8f73d6cc95de Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Thu, 7 May 2026 07:33:20 +0530 Subject: [PATCH 09/12] gate task_bench example behind HPX_WITH_EXAMPLES_TASKBENCH option Signed-off-by: guptapratykshh --- CMakeLists.txt | 8 ++++++++ examples/CMakeLists.txt | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0468591978..47ba3b44ed7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1561,6 +1561,14 @@ if(HPX_WITH_EXAMPLES_QTHREADS) endif() endif() +hpx_option( + HPX_WITH_EXAMPLES_TASKBENCH BOOL + "Enable the task-bench example (fetched from upstream StanfordLegion/task-bench, default: OFF)." + OFF + CATEGORY "Build Targets" + ADVANCED +) + hpx_option( HPX_WITH_EXAMPLES_HDF5 BOOL "Enable examples requiring HDF5 support (default: OFF)." OFF diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 77dd48c2fda..1d5df7a4a02 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,6 @@ set(subdirs random_mem_access spell_check startup_shutdown - task_bench throttle tuplespace transpose @@ -34,6 +33,10 @@ if(HPX_WITH_ITTNOTIFY) set(subdirs ${subdirs} itt_notify) endif() +if(HPX_WITH_EXAMPLES_TASKBENCH) + set(subdirs ${subdirs} task_bench) +endif() + if(HPX_WITH_EXAMPLES_HDF5) set(subdirs ${subdirs} interpolate1d sheneos) endif() From a93ed8481db0124ce96e19333963c9cb051e2028 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Thu, 7 May 2026 07:37:04 +0530 Subject: [PATCH 10/12] fix cmake-format Signed-off-by: guptapratykshh --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47ba3b44ed7..08abbac3cea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1562,7 +1562,8 @@ if(HPX_WITH_EXAMPLES_QTHREADS) endif() hpx_option( - HPX_WITH_EXAMPLES_TASKBENCH BOOL + HPX_WITH_EXAMPLES_TASKBENCH + BOOL "Enable the task-bench example (fetched from upstream StanfordLegion/task-bench, default: OFF)." OFF CATEGORY "Build Targets" From ea25a41e5b097c3ea5b658af5983b3af242a36d8 Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Thu, 7 May 2026 08:00:13 +0530 Subject: [PATCH 11/12] bump cmake_minimum_required to 3.18 to match HPX top-level Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index 6973262f0e0..5435181f0a6 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -8,7 +8,7 @@ # (https://github.com/StanfordLegion/task-bench) as an external dependency. No # task-bench source files are vendored here. -cmake_minimum_required(VERSION 3.17) +cmake_minimum_required(VERSION 3.18) # task-bench core uses POSIX APIs (clock_gettime, etc.) that are not available # on Windows. Skip the entire example on MSVC builds. From 25151faf4915b795082de374c10b1ce1c0573aad Mon Sep 17 00:00:00 2001 From: guptapratykshh Date: Wed, 13 May 2026 10:42:58 +0530 Subject: [PATCH 12/12] skip task_bench on all Windows toolchains, not just MSVC Signed-off-by: guptapratykshh --- examples/task_bench/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/task_bench/CMakeLists.txt b/examples/task_bench/CMakeLists.txt index 5435181f0a6..c67e6710425 100644 --- a/examples/task_bench/CMakeLists.txt +++ b/examples/task_bench/CMakeLists.txt @@ -11,8 +11,8 @@ cmake_minimum_required(VERSION 3.18) # task-bench core uses POSIX APIs (clock_gettime, etc.) that are not available -# on Windows. Skip the entire example on MSVC builds. -if(MSVC) +# on Windows. Skip the entire example on Windows builds (MSVC and MinGW). +if(WIN32) return() endif()