class runtime

Declaration

class runtime { /* full declaration omitted */ };

Description

////////////////////////////////////////////////////////////////////////

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:55

Member Variables

protected pika::runtime::on_exit_type on_exit_functions_
protected std::mutex mtx_
protected pika::util::runtime_configuration rtcfg_
protected long instance_number_
protected std::unique_ptr<util::thread_mapper> thread_support_
protected threads::detail::topology& topology_
protected std::atomic<state> state_
protected notification_policy_type::on_startstop_type on_start_func_
protected notification_policy_type::on_startstop_type on_stop_func_
protected notification_policy_type::on_error_type on_error_func_
protected int result_
protected std::exception_ptr exception_
protected pika::runtime::notification_policy_type notifier_
protected std::unique_ptr<pika::threads::threadmanager> thread_manager_
protected static std::atomic<int> instance_number_counter_

Method Overview

  • public virtual void add_pre_shutdown_function(pika::shutdown_function_type f)
  • public virtual void add_pre_startup_function(pika::startup_function_type f)
  • public virtual void add_shutdown_function(pika::shutdown_function_type f)
  • public virtual void add_startup_function(pika::startup_function_type f)
  • public virtual std::uint32_t assign_cores()
  • public virtual std::uint32_t assign_cores(const std::string &, std::uint32_t)
  • protected void deinit_global_data()
  • public virtual bool enumerate_os_threads(const util::function<bool (const os_thread_data &)> & f) const
  • public virtual int finalize(double)
  • public pika::util::runtime_configuration & get_config()
  • public const pika::util::runtime_configuration & get_config() const
  • public virtual std::uint32_t get_initial_num_localities() const
  • public std::size_t get_instance_number() const
  • public virtual std::uint32_t get_locality_id(pika::error_code & ec) const
  • public virtual std::string get_locality_name() const
  • public virtual pika::runtime::notification_policy_type get_notification_policy(const char * prefix, pika::os_thread_type type)
  • public virtual std::uint32_t get_num_localities(pika::launch::sync_policy, pika::error_code & ec) const
  • public virtual pika::future<std::uint32_t> get_num_localities() const
  • public virtual std::size_t get_num_worker_threads() const
  • public virtual pika::os_thread_data get_os_thread_data(const std::string & label) const
  • public pika::state get_state() const
  • public static std::uint64_t get_system_uptime()
  • public virtual pika::threads::threadmanager & get_thread_manager()
  • public util::thread_mapper & get_thread_mapper()
  • public const threads::detail::topology & get_topology() const
  • public virtual std::string here() const
  • protected void init()
  • protected void init_global_data()
  • public virtual bool is_networking_enabled()
  • public notification_policy_type::on_error_type on_error_func(notification_policy_type::on_error_type &&)
  • public notification_policy_type::on_error_type on_error_func() const
  • public void on_exit(const util::function<void ()> & f)
  • public notification_policy_type::on_startstop_type on_start_func(notification_policy_type::on_startstop_type &&)
  • public notification_policy_type::on_startstop_type on_start_func() const
  • public notification_policy_type::on_startstop_type on_stop_func(notification_policy_type::on_startstop_type &&)
  • public notification_policy_type::on_startstop_type on_stop_func() const
  • public virtual bool register_thread(const char * name, std::size_t num = 0, bool service_thread = true, pika::error_code & ec = throws)
  • public virtual bool report_error(const std::exception_ptr & e, bool terminate_all = true)
  • public virtual bool report_error(std::size_t num_thread, const std::exception_ptr & e, bool terminate_all = true)
  • public virtual int resume()
  • public virtual void rethrow_exception()
  • public virtual int run(const util::function<pika_main_function_type> & func)
  • public virtual int run()
  • protected threads::thread_result_type run_helper(const util::function<runtime::pika_main_function_type> & func, int & result, bool call_startup_functions)
  • public runtime(pika::util::runtime_configuration & rtcfg, bool initialize)
  • protected runtime(pika::util::runtime_configuration & rtcfg)
  • protected void set_notification_policies(pika::runtime::notification_policy_type && notifier, threads::detail::network_background_callback_type network_background_callback)
  • public void set_state(pika::state s)
  • public virtual int start(const util::function<pika_main_function_type> & func, bool blocking = false)
  • public virtual int start(bool blocking = false)
  • public void starting()
  • public virtual void stop(bool blocking = true)
  • public bool stopped() const
  • public void stopping()
  • public virtual int suspend()
  • public virtual bool unregister_thread()
  • public virtual int wait()
  • protected void wait_helper(std::mutex & mtx, std::condition_variable & cond, bool & running)
  • public virtual ~runtime()

Methods

virtual void add_pre_shutdown_function(
    pika::shutdown_function_type f)

Description

Add a function to be executed inside a pika thread during pika::finalize, but guaranteed before any of the shutdown functions is executed.

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:279

Parameters

pika::shutdown_function_type f
The function 'f' will be called from inside a pika thread while pika::finalize is executed. This is very useful to tear down the runtime environment of the application (uninstall performance counters, etc.)

virtual void add_pre_startup_function(
    pika::startup_function_type f)

Description

Add a function to be executed inside a pika thread before pika_main but guaranteed to be executed before any startup function registered with \a

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:257

Parameters

pika::startup_function_type f
The function 'f' will be called from inside a pika thread before pika_main is executed. This is very useful to setup the runtime environment of the application (install performance counters, etc.)

virtual void add_shutdown_function(
    pika::shutdown_function_type f)

Description

Add a function to be executed inside a pika thread during pika::finalize

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:287

Parameters

pika::shutdown_function_type f
The function 'f' will be called from inside a pika thread while pika::finalize is executed. This is very useful to tear down the runtime environment of the application (uninstall performance counters, etc.)

virtual void add_startup_function(
    pika::startup_function_type f)

Description

Add a function to be executed inside a pika thread before pika_main

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:265

Parameters

pika::startup_function_type f
The function 'f' will be called from inside a pika thread before pika_main is executed. This is very useful to setup the runtime environment of the application (install performance counters, etc.)

virtual std::uint32_t assign_cores()

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:374

virtual std::uint32_t assign_cores(
    const std::string&,
    std::uint32_t)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:369

Parameters

const std::string&
std::uint32_t

void deinit_global_data()

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:381

virtual bool enumerate_os_threads(
    const util::function<
        bool(const os_thread_data&)>& f) const

Description

Enumerate all OS threads that have registered with the runtime.

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:342

Parameters

const util::function<bool(const os_thread_data&)>& f

virtual int finalize(double)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:213

Parameters

double

pika::util::runtime_configuration& get_config()

Description

access configuration information

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:106

const pika::util::runtime_configuration&
get_config() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:108

virtual std::uint32_t get_initial_num_localities()
    const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:363

std::size_t get_instance_number() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:110

virtual std::uint32_t get_locality_id(
    pika::error_code& ec) const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:356

Parameters

pika::error_code& ec

virtual std::string get_locality_name() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:367

virtual pika::runtime::notification_policy_type
get_notification_policy(const char* prefix,
                        pika::os_thread_type type)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:61

Parameters

const char* prefix
pika::os_thread_type type

virtual std::uint32_t get_num_localities(
    pika::launch::sync_policy,
    pika::error_code& ec) const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:360

Parameters

pika::launch::sync_policy
pika::error_code& ec

virtual pika::future<std::uint32_t>
get_num_localities() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:365

virtual std::size_t get_num_worker_threads() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:358

virtual pika::os_thread_data get_os_thread_data(
    const std::string& label) const

Description

Access data for a given OS thread that was previously registered by\a

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:338

Parameters

const std::string& label

pika::state get_state() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:64

static std::uint64_t get_system_uptime()

Description

Return the system uptime measure on the thread executing this call

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:113

virtual pika::threads::threadmanager&
get_thread_manager()

Description

Allow access to the thread manager instance used by the pika runtime.

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:220

util::thread_mapper& get_thread_mapper()

Description

Return a reference to the internal PAPI thread manager

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:116

const threads::detail::topology& get_topology()
    const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:118

virtual std::string here() const

Description

Returns a string of the locality endpoints (usable in debug output)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:223

void init()

Description

Common initialization for different constructors

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:86

void init_global_data()

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:380

virtual bool is_networking_enabled()

Description

Return true if networking is enabled.

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:216

notification_policy_type::on_error_type
on_error_func(
    notification_policy_type::on_error_type&&)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:353

Parameters

notification_policy_type::on_error_type&&

notification_policy_type::on_error_type
on_error_func() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:347

void on_exit(const util::function<void()>& f)

Description

Manage list of functions to call on exit

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:94

Parameters

const util::function<void()>& f

notification_policy_type::on_startstop_type
on_start_func(
    notification_policy_type::on_startstop_type&&)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:349

Parameters

notification_policy_type::on_startstop_type&&

notification_policy_type::on_startstop_type
on_start_func() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:345

notification_policy_type::on_startstop_type
on_stop_func(
    notification_policy_type::on_startstop_type&&)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:351

Parameters

notification_policy_type::on_startstop_type&&

notification_policy_type::on_startstop_type
on_stop_func() const

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:346

virtual bool register_thread(
    const char* name,
    std::size_t num = 0,
    bool service_thread = true,
    pika::error_code& ec = throws)

Description

Register an external OS-thread with pika

This function should be called from any OS-thread which is external to pika (not created by pika), but which needs to access pika functionality, such as setting a value on a promise or similar. 'main', 'io', 'timer', 'parcel', 'worker'

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:319

Parameters

const char* name
[in] The name to use for thread registration.
std::size_t num = 0
[in] The sequence number to use for thread registration. The default for this parameter is zero.
bool service_thread = true
[in] The thread should be registered as a service thread. The default for this parameter is 'true'. Any service threads will be pinned to cores not currently used by any of the pika worker threads.
pika::error_code& ec = throws

Returns

This function will return whether the requested operation succeeded or not.

virtual bool report_error(
    const std::exception_ptr& e,
    bool terminate_all = true)

Description

Report a non-recoverable error to the runtime system

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:242

Parameters

const std::exception_ptr& e
[in] This is an instance encapsulating an exception which lead to this function call.
bool terminate_all = true

virtual bool report_error(
    std::size_t num_thread,
    const std::exception_ptr& e,
    bool terminate_all = true)

Description

Report a non-recoverable error to the runtime system

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:231

Parameters

std::size_t num_thread
[in] The number of the operating system thread the error has been detected in.
const std::exception_ptr& e
[in] This is an instance encapsulating an exception which lead to this function call.
bool terminate_all = true

virtual int resume()

Description

Resume the runtime system

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:211

virtual void rethrow_exception()

Description

Rethrow any stored exception (to be called after stop())

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:152

virtual int run(
    const util::function<pika_main_function_type>&
        func)

Description

Run the pika runtime system, use the given function for the main \aand block waiting for all threads to finish

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:142

Parameters

const util::function<pika_main_function_type>& func
[in] This is the main function of an pika application. It will be scheduled for execution by the thread manager as soon as the runtime has been initialized. This function is expected to expose an interface as defined by the typedef\aThis parameter is optional and defaults to none main thread function, in which case all threads have to be scheduled explicitly.

Returns

This function will return the value as returned as the result of the invocation of the function object given by the parameter \p

virtual int run()

Description

Run the pika runtime system, initially use the given number of (OS) threads in the thread-manager and block waiting for all threads to finish.

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:149

Returns

This function will always return 0 (zero).

threads::thread_result_type run_helper(
    const util::function<
        runtime::pika_main_function_type>& func,
    int& result,
    bool call_startup_functions)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:383

Parameters

const util::function< runtime::pika_main_function_type>& func
int& result
bool call_startup_functions

runtime(pika::util::runtime_configuration& rtcfg,
        bool initialize)

Description

Construct a new pika runtime instance

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:75

Parameters

pika::util::runtime_configuration& rtcfg
bool initialize

runtime(pika::util::runtime_configuration& rtcfg)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:79

Parameters

pika::util::runtime_configuration& rtcfg

void set_notification_policies(
    pika::runtime::notification_policy_type&&
        notifier,
    threads::detail::
        network_background_callback_type
            network_background_callback)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:81

Parameters

pika::runtime::notification_policy_type&& notifier
threads::detail::network_background_callback_type network_background_callback

void set_state(pika::state s)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:65

Parameters

pika::state s

virtual int start(
    const util::function<pika_main_function_type>&
        func,
    bool blocking = false)

Description

Start the runtime system

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:172

Parameters

const util::function<pika_main_function_type>& func
[in] This is the main function of an pika application. It will be scheduled for execution by the thread manager as soon as the runtime has been initialized. This function is expected to expose an interface as defined by the typedef\a
bool blocking = false
[in] This allows to control whether this call blocks until the runtime system has been stopped. If this parameter is \athe function \awill call\ainternally.

Returns

If a blocking is a true, this function will return the value as returned as the result of the invocation of the function object given by the parameter \pOtherwise it will return zero.

virtual int start(bool blocking = false)

Description

Start the runtime system

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:187

Parameters

bool blocking = false
[in] This allows to control whether this call blocks until the runtime system has been stopped. If this parameter is \athe function \awill call\ainternally .

Returns

If a blocking is a true, this function will return the value as returned as the result of the invocation of the function object given by the parameter \pOtherwise it will return zero.

void starting()

Description

Manage runtime 'stopped' state

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:97

virtual void stop(bool blocking = true)

Description

Initiate termination of the runtime system

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:205

Parameters

bool blocking = true
[in] This allows to control whether this call blocks until the runtime system has been fully stopped. If this parameter is \athen this call will initiate the stop action but will return immediately. Use a second call to stop with this parameter set to \ato wait for all internal work to be completed.

bool stopped() const

Description

This accessor returns whether the runtime instance has been stopped

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:103

void stopping()

Description

Call all registered on_exit functions

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:100

virtual int suspend()

Description

Suspend the runtime system

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:208

virtual bool unregister_thread()

Description

Unregister an external OS-thread with pika

This function will unregister any external OS-thread from pika.

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:334

Returns

This function will return whether the requested operation succeeded or not.

virtual int wait()

Description

Wait for the shutdown action to be executed

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:194

Returns

This function will return the value as returned as the result of the invocation of the function object given by the parameter \p

void wait_helper(std::mutex& mtx,
                 std::condition_variable& cond,
                 bool& running)

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:387

Parameters

std::mutex& mtx
std::condition_variable& cond
bool& running

virtual ~runtime()

Description

The destructor makes sure all pika runtime services are properly shut down before exiting.

Declared at: libs/pika/runtime/include/pika/runtime/runtime.hpp:91