HPX - High Performance ParalleX


The HPX I/O-streams Component

The HPX I/O-streams subsystem extends the standard C++ output streams std::cout and std::cerr to work in the distributed setting of an HPX application. All of the output streamed to hpx::cout will be dispatched to std::cout on the console locality. Likewise, all output generated from hpx::cerr will be dispatched to std::cerr on the console locality.

[Note] Note

All existing standard manipulators can be used in conjunction with hpx::cout and hpx::cerr. Historically, HPX also defines hpx::endl and hpx::flush, but those are just aliases for the corresponding standard manipulators.

In order to use either hpx::cout or hpx::cerr, application codes need to #include <hpx/include/iostreams.hpp>. For an example, please see the simplest possible 'Hello world' program as included as an example with HPX:

// Including 'hpx/hpx_main.hpp' instead of the usual 'hpx/hpx_init.hpp' enables
// to use the plain C-main below as the direct main HPX entry point.
#include <hpx/hpx_main.hpp>
#include <hpx/include/iostreams.hpp>

int main()
    // Say hello to the world!
    hpx::cout << "Hello World!\n" << hpx::flush;
    return 0;

Additionally those applications need to link with the iostreams component. When using cmake this can be achieved by using the COMPONENT_DEPENDENCIES parameter, for instance:


    SOURCES simplest_hello_world.cpp
[Note] Note

The hpx::cout and hpx::cerr streams buffer all output locally until a std::endl of std::flush is encountered. That means that no output will appear on the console as long as either of those is explicitly used.