Skip to content

Add local-runtime fallback for hpx/iostream.hpp#7130

Merged
hkaiser merged 3 commits intoTheHPXProject:masterfrom
abhishek593:iostream-local-runtime
Apr 11, 2026
Merged

Add local-runtime fallback for hpx/iostream.hpp#7130
hkaiser merged 3 commits intoTheHPXProject:masterfrom
abhishek593:iostream-local-runtime

Conversation

@abhishek593
Copy link
Copy Markdown
Contributor

Fixes #4565

Proposed Changes

This PR adds a local-runtime fallback implementation for hpx/iostream.hpp when HPX_WITH_DISTRIBUTED_RUNTIME=OFF. The fallback is intentionally narrower than the distributed implementation.

  • Added local-only implementations for:
    • hpx::cout, hpx::cerr, hpx::consolestream, hpx::get_consolestream
    • hpx::flush, hpx::endl, hpx::async_flush, hpx::async_endl
  • Added tests for local-runtime in iostreams_local_fallback.cpp

Checklist

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

@abhishek593 abhishek593 requested a review from hkaiser as a code owner March 30, 2026 11:25
@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For purely local operations, wouldn't the following be sufficient:

namespace hpx {
    using cout = std::cout;
    // similar definitions for the other facilities
}

?

Also, instead of re-introducing flush and the other manipulators, I think we should deprecate them in the HPX namespace as they don't do anything special anymore (IIRC, needs verification).

@abhishek593
Copy link
Copy Markdown
Contributor Author

Yes, this would be sufficient where std equivalents are present. But for hpx::consolestream, we still need the full local implementation. So, just to be consistent, I added for others in a similar way.

For the manipulators, the distributed implementation still gives hpx::flush, hpx::endl, hpx::async_flush, and hpx::async_endl special semantics, so we likely want to keep that API surface. In the local runtime fallback, however, hpx::async_flush and hpx::async_endl do not currently provide any special behavior, so we can deprecate those. Should I go ahead with that?

I recently refreshed the codebase to resolve merge conflicts and found an unrelated local-only wrap build issue exposed by the recent hpx::init local fallback work(#7103). wrap had been partially updated for local-only builds in CMake, but two source files still depended on distributed-only init headers, giving compilation errors. I can push once we've decided on the deprecation.

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Mar 30, 2026

Yes, this would be sufficient where std equivalents are present. But for hpx::consolestream, we still need the full local implementation. So, just to be consistent, I added for others in a similar way.

hpx::consolestream can be defined as being equivalent to std::cerr.

For the manipulators, the distributed implementation still gives hpx::flush, hpx::endl, hpx::async_flush, and hpx::async_endl special semantics, so we likely want to keep that API surface. In the local runtime fallback, however, hpx::async_flush and hpx::async_endl do not currently provide any special behavior, so we can deprecate those. Should I go ahead with that?

I wil have closer look at those manpulators. All I remember is that we don't use those in any serious way anywhere as the std manipulators are good enough (tm) for our purposes.

If you would like to go ahead and deprecate them, please do it in a separate PR.

I recently refreshed the codebase to resolve merge conflicts and found an unrelated local-only wrap build issue exposed by the recent hpx::init local fallback work(#7103). wrap had been partially updated for local-only builds in CMake, but two source files still depended on distributed-only init headers, giving compilation errors. I can push once we've decided on the deprecation.

Yes, please, however let's keep this separate as well.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 1, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage ∅ diff coverage

Metric Results
Coverage variation Report missing for 517cf721
Diff coverage diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (517cf72) Report Missing Report Missing Report Missing
Head commit (dc39fcb) 83639 0 0.00%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7130) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

TIP This summary will be updated as you push new changes. Give us feedback

@abhishek593 abhishek593 force-pushed the iostream-local-runtime branch 2 times, most recently from a090200 to 9ea9352 Compare April 1, 2026 19:13
Comment thread libs/core/include_local/include/hpx/iostream.hpp.in Outdated
Comment thread libs/core/include_local/CMakeLists.txt Outdated
Comment thread libs/core/include_local/CMakeLists.txt Outdated
@abhishek593
Copy link
Copy Markdown
Contributor Author

@hkaiser I have made the changes. All the modifications you suggested are right.

hkaiser
hkaiser previously approved these changes Apr 5, 2026
Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Let's get #7133 merged first. That would allow for the new test to be actually run on the CIs.

@hkaiser hkaiser added this to the 2.0.0 milestone Apr 5, 2026
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 8, 2026

@abhishek593 #7133 has been merged now. Could you please rebase onto master to trigger the tests for this PR on the CIs?

Signed-off-by: Abhishek Bansal <abhibansal593@gmail.com>
Signed-off-by: Abhishek Bansal <abhibansal593@gmail.com>
@abhishek593 abhishek593 force-pushed the iostream-local-runtime branch from 8f0f815 to 6c14fbf Compare April 8, 2026 18:49
@abhishek593
Copy link
Copy Markdown
Contributor Author

@hkaiser I messed up the git rebase somehow, but it's correct now.

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 8, 2026

@hkaiser I messed up the git rebase somehow, but it's correct now.

Let's wait for the CIs to cycle.

Signed-off-by: Abhishek Bansal <abhibansal593@gmail.com>
@abhishek593 abhishek593 force-pushed the iostream-local-runtime branch from 6c14fbf to dc39fcb Compare April 8, 2026 19:58
@hkaiser hkaiser merged commit 30a21c1 into TheHPXProject:master Apr 11, 2026
106 of 108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make iostreams component work locally

3 participants