Function init
hpx::init — Main entry point for launching the HPX runtime system.
Synopsis
int init(std::function< int(boost::program_options::variables_map &vm)> const & f,
boost::program_options::options_description const & desc_cmdline,
int argc, char ** argv, std::vector< std::string > const & cfg,
std::function< void()> const & startup = std::function< void()>(),
std::function< void()> const & shutdown = std::function< void()>(),
hpx::runtime_mode mode = hpx::runtime_mode_default);
Description
This is the main entry point for any HPX application. This function (or one of its overloads below) should be called from the users main()
function. It will set up the HPX runtime environment and schedule the function given by f
as a HPX thread.
![[Note]](../images/note.png) |
Note |
If the parameter mode is not given (defaulted), the created runtime system instance will be executed in console or worker mode depending on the command line arguments passed in argc /argv . Otherwise it will be executed as specified by the parametermode . |
Parameters: |
argc
|
[in] The number of command line arguments passed in argv . This is usually the unchanged value as passed by the operating system (to main() ). |
argv
|
[in] The command line arguments for this application, usually that is the value as passed by the operating system (to main() ). |
cfg
|
A list of configuration settings which will be added to the system configuration before the runtime instance is run. Each of the entries in this list must have the format of a fully defined key/value pair from an ini-file (for instance 'hpx.component.enabled=1') |
desc_cmdline
|
[in] This parameter may hold the description of additional command line arguments understood by the application. These options will be prepended to the default command line options understood by hpx::init (see description below). |
f
|
[in] The function to be scheduled as an HPX thread. Usually this function represents the main entry point of any HPX application. |
mode
|
[in] The mode the created runtime environment should be initialized in. There has to be exactly one locality in each HPX application which is executed in console mode (hpx::runtime_mode_console), all other localities have to be run in worker mode (hpx::runtime_mode_worker). Normally this is set up automatically, but sometimes it is necessary to explicitly specify the mode. |
shutdown
|
[in] A function to be executed inside an HPX thread while hpx::finalize is executed. If this parameter is not given no function will be executed. |
startup
|
[in] A function to be executed inside a HPX thread before f is called. If this parameter is not given no function will be executed. |
|
Returns: |
The function returns the value, which has been returned from the user supplied f . |