Public API

All names below are also available in the top-level hpx namespace unless otherwise noted. The names in hpx should be preferred. The names in sub-namespaces will eventually be removed.

Header hpx/algorithm.hpp

This header includes Header hpx/local/algorithm.hpp and contains overloads of the algorithms for segmented iterators.

Header hpx/local/algorithm.hpp

Corresponds to the C++ standard library header algorithm. See Using parallel algorithms for more information about the parallel algorithms.

Functions

Header hpx/any.hpp

This header includes Header hpx/local/any.hpp.

Header hpx/local/any.hpp

Corresponds to the C++ standard library header any. hpx::any is compatible with std::any.

Header hpx/assert.hpp

Corresponds to the C++ standard library header cassert. HPX_ASSERT is the HPX equivalent to assert in cassert. HPX_ASSERT can also be used in CUDA device code.

Header hpx/barrier.hpp

This header includes Header hpx/local/barrier.hpp and contains a distributed barrier implementation. This functionality is also exposed through the hpx::distributed namespace. The name in hpx::distributed should be preferred.

Header hpx/local/barrier.hpp

Corresponds to the C++ standard library header barrier.

Classes

  • hpx::lcos::local::cpp20_barrier

Header hpx/channel.hpp

This header includes Header hpx/local/channel.hpp and contains a distributed channel implementation. This functionality is also exposed through the hpx::distributed namespace. The name in hpx::distributed should be preferred.

Classes

  • hpx::lcos::channel

Header hpx/local/channel.hpp

Contains a local channel implementation.

Classes

  • hpx::lcos::local::channel

Header hpx/chrono.hpp

This header includes Header hpx/local/chrono.hpp.

Header hpx/local/chrono.hpp

Corresponds to the C++ standard library header chrono. The following replacements and extensions are provided compared to chrono. The classes below are also available in the hpx::chrono namespace, not in the top-level hpx namespace.

Header hpx/condition_variable.hpp

This header includes Header hpx/local/condition_variable.hpp.

Header hpx/local/condition_variable.hpp

Corresponds to the C++ standard library header condition_variable.

Header hpx/exception.hpp

This header includes Header hpx/local/exception.hpp.

Header hpx/local/exception.hpp

Corresponds to the C++ standard library header exception. hpx::exception extends std::exception and is the base class for all exceptions thrown in HPX. HPX_THROW_EXCEPTION can be used to throw HPX exceptions with file and line information attached to the exception.

Header hpx/execution.hpp

This header includes Header hpx/local/execution.hpp.

Header hpx/local/execution.hpp

Corresponds to the C++ standard library header execution. See High level parallel facilities, Using parallel algorithms and Executor parameters and executor parameter traits for more information about execution policies and executor parameters.

Note

These names are only available in the hpx::execution namespace, not in the top-level hpx namespace.

Constants

Header hpx/functional.hpp

This header includes Header hpx/local/functional.hpp.

Header hpx/local/functional.hpp

Corresponds to the C++ standard library header functional. hpx::util::function is a more efficient and serializable replacement for std::function.

Constants

The following constants are also available in hpx::placeholders, not the top-level hpx namespace.

  • hpx::util::placeholders::_1

  • hpx::util::placeholders::_2

  • hpx::util::placeholders::_9

Classes

Header hpx/future.hpp

This header includes Header hpx/local/future.hpp and contains overloads of hpx::async, hpx::apply, hpx::sync, and hpx::dataflow that can be used with actions. See Action invocation for more information about invoking actions.

Note

The alias from hpx::promise to hpx::lcos::promise is deprecated and will be removed in a future release. The alias hpx::distributed::promise should be used in new applications.

Classes

  • hpx::lcos::promise

Header hpx/local/future.hpp

Corresponds to the C++ standard library header future. See Extended facilities for futures for more information about extensions to futures compared to the C++ standard library.

Note

All names except hpx::lcos::local::promise are also available in the top-level hpx namespace. hpx::promise refers to hpx::lcos::promise, a distributed variant of hpx::lcos::local::promise, but will eventually refer to hpx::lcos::local::promise after a deprecation period.

Classes

  • hpx::lcos::future

  • hpx::lcos::shared_future

  • hpx::lcos::local::promise

  • hpx::launch

Examples

#include <hpx/assert.hpp>
#include <hpx/future.hpp>
#include <hpx/hpx_main.hpp>
#include <hpx/tuple.hpp>

#include <iostream>
#include <utility>

int main()
{
    // Asynchronous execution with futures
    hpx::future<void> f1 = hpx::async(hpx::launch::async, []() {});
    hpx::shared_future<int> f2 =
        hpx::async(hpx::launch::async, []() { return 42; });
    hpx::future<int> f3 =
        f2.then([](hpx::shared_future<int>&& f) { return f.get() * 3; });

    hpx::lcos::local::promise<double> p;
    auto f4 = p.get_future();
    HPX_ASSERT(!f4.is_ready());
    p.set_value(123.45);
    HPX_ASSERT(f4.is_ready());

    hpx::packaged_task<int()> t([]() { return 43; });
    hpx::future<int> f5 = t.get_future();
    HPX_ASSERT(!f5.is_ready());
    t();
    HPX_ASSERT(f5.is_ready());

    // Fire-and-forget
    hpx::apply([]() {
        std::cout << "This will be printed later\n" << std::flush;
    });

    // Synchronous execution
    hpx::sync([]() {
        std::cout << "This will be printed immediately\n" << std::flush;
    });

    // Combinators
    hpx::future<double> f6 = hpx::async([]() { return 3.14; });
    hpx::future<double> f7 = hpx::async([]() { return 42.0; });
    std::cout
        << hpx::when_all(f6, f7)
               .then([](hpx::future<
                         hpx::tuple<hpx::future<double>, hpx::future<double>>>
                             f) {
                   hpx::tuple<hpx::future<double>, hpx::future<double>> t =
                       f.get();
                   double pi = hpx::get<0>(t).get();
                   double r = hpx::get<1>(t).get();
                   return pi * r * r;
               })
               .get()
        << std::endl;

    // Easier continuations with dataflow; it waits for all future or
    // shared_future arguments before executing the continuation, and also
    // accepts non-future arguments
    hpx::future<double> f8 = hpx::async([]() { return 3.14; });
    hpx::future<double> f9 = hpx::make_ready_future(42.0);
    hpx::shared_future<double> f10 = hpx::async([]() { return 123.45; });
    hpx::future<hpx::tuple<double, double>> f11 = hpx::dataflow(
        [](hpx::future<double> a, hpx::future<double> b,
            hpx::shared_future<double> c, double d) {
            return hpx::make_tuple<>(a.get() + b.get(), c.get() / d);
        },
        f8, f9, f10, -3.9);

    // split_future gives a tuple of futures from a future of tuple
    hpx::tuple<hpx::future<double>, hpx::future<double>> f12 =
        hpx::split_future(std::move(f11));
    std::cout << hpx::get<1>(f12).get() << std::endl;

    return 0;
}

Header hpx/init.hpp

This header contains functionality for starting, stopping, suspending, and resuming the HPX runtime. This is the main way to explicitly start the HPX runtime. See Starting the HPX runtime for more details on starting the HPX runtime.

Header hpx/latch.hpp

This header includes Header hpx/local/latch.hpp and contains a distributed latch implementation. This functionality is also exposed through the hpx::distributed namespace. The name in hpx::distributed should be preferred.

Header hpx/local/latch.hpp

Corresponds to the C++ standard library header latch.

Header hpx/mutex.hpp

This header includes Header hpx/local/mutex.hpp.

Header hpx/memory.hpp

This header includes Header hpx/local/memory.hpp.

Header hpx/numeric.hpp

This header includes Header hpx/local/numeric.hpp.

Header hpx/optional.hpp

This header includes Header hpx/local/optional.hpp.

Header hpx/local/optional.hpp

Corresponds to the C++ standard library header optional. hpx::util::optional is compatible with std::optional.

Header hpx/runtime.hpp

This header includes Header hpx/local/runtime.hpp and contains functions for accessing distributed runtime information.

Header hpx/system_error.hpp

This header includes Header hpx/local/system_error.hpp.

Header hpx/local/system_error.hpp

Corresponds to the C++ standard library header system_error.

Header hpx/task_block.hpp

This header includes Header hpx/local/task_black.hpp.

Header hpx/local/task_black.hpp

Corresponds to the task_block feature in N4411. See Using task blocks for more details on using task blocks.

Classes

Header hpx/thread.hpp

This header includes Header hpx/local/thread.hpp.

Header hpx/local/thread.hpp

Corresponds to the C++ standard library header thread. The functionality in this header is equivalent to the standard library thread functionality, with the exception that the HPX equivalents are implemented on top of lightweight threads and the HPX runtime.

Header hpx/semaphore.hpp

This header includes Header hpx/local/semaphore.hpp.

Header hpx/local/semaphore.hpp

Corresponds to the C++ standard library header semaphore.

Classes

  • hpx::lcos::local::cpp20_binary_semaphore

  • hpx::lcos::local::cpp20_counting_semaphore

Header hpx/shared_mutex.hpp

This header includes Header hpx/local/shared_mutex.hpp.

Header hpx/local/shared_mutex.hpp

Corresponds to the C++ standard library header shared_mutex.

Header hpx/stop_token.hpp

This header includes Header hpx/local/stop_token.hpp.

Header hpx/local/stop_token.hpp

Corresponds to the C++ standard library header stop_token.

Constants

  • hpx::nostopstate

Header hpx/tuple.hpp

This header includes Header hpx/local/tuple.hpp.

Header hpx/local/tuple.hpp

Corresponds to the C++ standard library header tuple. hpx::tuple can be used in CUDA device code, unlike std::tuple.

Constants

Classes

Header hpx/type_traits.hpp

This header includes Header hpx/local/type_traits.hpp.

Header hpx/local/type_traits.hpp

Corresponds to the C++ standard library header type_traits.

Classes

  • hpx::is_invocable

  • hpx::is_invocable_r

Header hpx/unwrap.hpp

This header includes Header hpx/local/unwrap.hpp.

Header hpx/version.hpp

This header provides version information about HPX.

Macros

  • HPX_VERSION_MAJOR

  • HPX_VERSION_MINOR

  • HPX_VERSION_SUBMINOR

  • HPX_VERSION_FULL

  • HPX_VERSION_DATE

  • HPX_VERSION_TAG

  • HPX_AGAS_VERSION

Header hpx/wrap_main.hpp

This header does not provide any direct functionality but is used for implicitly using main as the runtime entry point. See Re-use the main() function as the main HPX entry point for more details on implicitly starting the HPX runtime.