Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions libs/core/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(config_macro_headers
hpx/config/forward.hpp
hpx/config/manual_profiling.hpp
hpx/config/move.hpp
hpx/config/static_linker_check.hpp
hpx/config/threads_stack.hpp
hpx/config/warnings_prefix.hpp
hpx/config/warnings_suffix.hpp
Expand Down
20 changes: 20 additions & 0 deletions libs/core/config/include/hpx/config/static_linker_check.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2026 The STE||AR-Group
//
// 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)

// hpxinspect:linelength
#pragma once

#include <hpx/config/defines.hpp>

#if defined(HPX_HAVE_DYNAMIC_HPX_MAIN)
#if (defined(__linux) || defined(__linux__) || defined(linux) || \
defined(__APPLE__)) && \
defined(HPX_HAVE_STATIC_LINKING) && \
!defined(HPX_HAVE_WRAP_MAIN_CONFIGURED)
#warning \
"You are statically linking HPX on Linux/macOS while using hpx_main.hpp. Please ensure you manually configure the linker to use wrap_main, or use the CMake target HPX::wrap_main to avoid linking errors."
#endif
#endif
1 change: 1 addition & 0 deletions libs/core/include_local/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(include_local_headers
hpx/format.hpp
hpx/functional.hpp
hpx/generator.hpp
hpx/local.hpp
hpx/memory.hpp
hpx/mutex.hpp
hpx/numeric.hpp
Expand Down
36 changes: 36 additions & 0 deletions libs/core/include_local/include/hpx/local.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2020-2026 The STE||AR-Group
//
// 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)

/// \file hpx/local.hpp
/// \brief Single-include convenience header for single-node HPX usage.
///
/// This header bundles the **Standard Parallel Toolkit** -- the most commonly
/// used HPX facilities for local (single-node) execution:
///
/// - \c hpx/modules/algorithms.hpp -- Parallel algorithms (for_each, sort, ...)
/// - \c hpx/modules/execution.hpp -- Execution policies (par, par_unseq, seq)
/// - \c hpx/modules/futures.hpp -- Futures and dataflow
/// - \c hpx/numeric.hpp -- Parallel numeric (reduce, transform_reduce, ...)
///
/// **Selection criteria**: each header is part of the HPX core module,
/// provides ISO C++ Standard Library parallel equivalents, and has no
/// dependency on the distributed runtime or networking layer.
///
/// \note This header intentionally does NOT include hpx/hpx_main.hpp.
/// Including hpx_main.hpp has observable side effects: it emits
/// non-weak symbol definitions and redefines 'main' via a
/// preprocessor macro. Users who need the zero-boilerplate HPX
/// runtime entry-point should include hpx/hpx_main.hpp explicitly.

#pragma once

#include <hpx/config.hpp>

// --- Standard Parallel Toolkit (core, no networking dependency) ---
#include <hpx/modules/algorithms.hpp>
#include <hpx/modules/execution.hpp>
#include <hpx/modules/futures.hpp>
#include <hpx/numeric.hpp>
23 changes: 22 additions & 1 deletion libs/core/include_local/tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Copyright (c) 2020-2021 The STE||AR-Group
# Copyright (c) 2026 The STE||AR-Group
#
# 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)

set(tests local_header)

set(local_header_FLAGS NOLIBS DEPENDENCIES HPX::hpx HPX::wrap_main)

foreach(test ${tests})
set(sources ${test}.cpp)

source_group("Source Files" FILES ${sources})

set(folder_name "Tests/Unit/Modules/Core/IncludeLocal")

add_hpx_executable(
${test}_test INTERNAL_FLAGS
SOURCES ${sources} ${${test}_FLAGS}
EXCLUDE_FROM_ALL
FOLDER ${folder_name}
)

add_hpx_unit_test("modules.include_local" ${test} ${${test}_PARAMETERS})
endforeach()
42 changes: 42 additions & 0 deletions libs/core/include_local/tests/unit/local_header.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2020-2026 The STE||AR-Group
//
// 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)

// Verify that hpx/local.hpp provides access to the Standard Parallel Toolkit:
// parallel algorithms, numeric algorithms, and execution policies.
//
// We use hpx::local::init to drive the HPX runtime without requiring any
// dependency on the wrap module (hpx_main.hpp / HPX::wrap_main).

#include <hpx/config.hpp>
#include <hpx/init.hpp>
#include <hpx/local.hpp>

#include <cstddef>
#include <iostream>
#include <numeric>
#include <vector>

int test_main(int argc, char* argv[])
{
// 1. Verify parallel algorithms are reachable via hpx/local.hpp
std::vector<int> v(100);
std::iota(v.begin(), v.end(), 1);

hpx::for_each(
hpx::execution::par, v.begin(), v.end(), [](int& x) { x *= 2; });

// 2. Verify numeric algorithms are reachable
int sum = hpx::reduce(hpx::execution::par, v.begin(), v.end(), 0);

std::cout << "reduce sum: " << sum << std::endl;

return hpx::local::finalize();
}

int main(int argc, char* argv[])
{
return hpx::local::init(test_main, argc, argv);
}
4 changes: 4 additions & 0 deletions wrap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ endif()
if(HPX_WITH_DYNAMIC_HPX_MAIN)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
target_link_libraries(hpx_wrap INTERFACE "-Wl,-wrap=main")
target_compile_definitions(hpx_wrap INTERFACE HPX_HAVE_WRAP_MAIN_CONFIGURED)
target_link_libraries(hpx_auto_wrap INTERFACE "-Wl,-wrap=main")
target_compile_definitions(
hpx_auto_wrap INTERFACE HPX_HAVE_WRAP_MAIN_CONFIGURED
)
elseif(APPLE)
target_link_libraries(hpx_wrap INTERFACE "-Wl,-e,_initialize_main")
target_link_libraries(hpx_auto_wrap INTERFACE "-Wl,-e,_initialize_main")
Expand Down
1 change: 1 addition & 0 deletions wrap/include/hpx/hpx_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#include <hpx/config/static_linker_check.hpp>
#include <hpx/wrap_main.hpp>

#if defined(HPX_HAVE_RUN_MAIN_EVERYWHERE)
Expand Down
Loading