Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cout defect #1180

Closed
Finomnis opened this issue Jul 5, 2014 · 2 comments
Closed

cout defect #1180

Finomnis opened this issue Jul 5, 2014 · 2 comments

Comments

@Finomnis
Copy link
Contributor

Finomnis commented Jul 5, 2014

I have the problem that cout outputs get delayed for some reason.

I managed to break the problem down to a minimal example:

// Copyright (c)       2014 Martin Stumpf
//
// 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)

#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/include/iostreams.hpp>

void print_stuff()
{
    hpx::this_thread::sleep_for(boost::posix_time::milliseconds(1000));
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
    hpx::this_thread::sleep_for(boost::posix_time::milliseconds(1000));
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
}

int hpx_main(boost::program_options::variables_map & vm)
{

    // The main scope
    {
            print_stuff();
            hpx::this_thread::sleep_for(boost::posix_time::milliseconds(5000));
    }

    // End the program
    return hpx::finalize();
}



//////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
    // Configure application-specific options
    boost::program_options::options_description cmdline(
                                "Usage: " HPX_APPLICATION_STRING " [options]");

    return hpx::init(cmdline, argc, argv);
}

which produces the following output:

Adding workloads to queue ...
        Adding workload 10:10 ...
Adding workloads to queue ...
        Adding workload 10:10 ...
Adding workloads to queue ...
        Adding workload 10:10 ...
Adding workloads to queue ...
  <waits for 6 seconds>
        Adding workload 10:10 ...
        Adding workload 10:10 ...

The 6 seconds delay should be 1 second delay, followed by 5 seconds after printing the last two lines.

If tried changing the output text to different things, but as soon as I change it, it works.
Any ideas?

@Finomnis
Copy link
Contributor Author

Finomnis commented Jul 5, 2014

I ran it with both -t16 and -t1, the result is the same.

@hkaiser hkaiser added this to the 0.9.9 milestone Jul 5, 2014
@hkaiser hkaiser self-assigned this Jul 5, 2014
@Finomnis
Copy link
Contributor Author

Finomnis commented Jul 5, 2014

I changed the print function to that:

void print_stuff()
{

    hpx::this_thread::sleep_for(boost::posix_time::milliseconds(1000));
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 20 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 30 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 40 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 50 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 60 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 70 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 80 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 90 << ":" << 10 << " ..." << hpx::endl;
    hpx::this_thread::sleep_for(boost::posix_time::milliseconds(1000));
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;
    hpx::cout << "Adding workloads to queue ..." << hpx::endl;
    hpx::cout << "\tAdding workload " << 10 << ":" << 10 << " ..." << hpx::endl;

}

which produced this output:

Adding workloads to queue ...
        Adding workload 10:10 ...
Adding workloads to queue ...
        Adding workload 20:10 ...
Adding workloads to queue ...
        Adding workload 30:10 ...
Adding workloads to queue ...
        Adding workload 40:10 ...
Adding workloads to queue ...
        Adding workload 50:10 ...
Adding workloads to queue ...
        Adding workload 60:10 ...
Adding workloads to queue ...
        Adding workload 70:10 ...
Adding workloads to queue ...
        Adding workload 80:10 ...
Adding workloads to queue ...
<1 second delay>
        Adding workload 90:10 ...
Adding workloads to queue ...
        Adding workload 10:10 ...
Adding workloads to queue ...
        Adding workload 10:10 ...
Adding workloads to queue ...
<5 seconds delay>
        Adding workload 10:10 ...

Which doesn't make ANY sense to me.

@hkaiser hkaiser closed this as completed in 7fb58b5 Jul 5, 2014
hkaiser added a commit that referenced this issue Jul 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants