Skip to content

Make CommunicationInfo printable#5968

Merged
wujingyue merged 1 commit intomainfrom
wjy/info
Feb 18, 2026
Merged

Make CommunicationInfo printable#5968
wujingyue merged 1 commit intomainfrom
wjy/info

Conversation

@wujingyue
Copy link
Collaborator

No description provided.

@wujingyue wujingyue requested a review from Priya2698 February 18, 2026 02:05
@wujingyue
Copy link
Collaborator Author

!test

@github-actions
Copy link

Description

  • Add stream output operator for CommunicationInfo struct

  • Enables printing CommunicationInfo objects for debugging

  • Prints type, p_sharded_id, and c_sharded_id fields

  • Separates declaration in header and implementation in cpp file

Changes walkthrough

Relevant files
Enhancement
lower_to_communication.h
Add CommunicationInfo stream operator declaration               

csrc/host_ir/lower_to_communication.h

  • Added operator<< declaration for CommunicationInfo struct
  • Enables stream output functionality for debugging
  • +2/-0     
    lower_to_communication.cpp
    Implement CommunicationInfo stream operator                           

    csrc/host_ir/lower_to_communication.cpp

  • Implemented operator<< for CommunicationInfo struct
  • Prints type and sharded ID information
  • Returns output stream for chaining
  • +7/-0     

    PR Reviewer Guide

    Here are some key observations to aid the review process:

    🧪 No relevant tests
    ⚡ Recommended focus areas for review
    Null Pointer Safety

    The operator<< function directly dereferences info.p_sharded_id and info.c_sharded_id without checking if they are null. This could cause segmentation faults if these pointers are null when the operator is called. Consider adding null checks or using safe pointer printing methods.

    std::ostream& operator<<(std::ostream& os, const CommunicationInfo& info) {
      os << "CommunicationInfo(" << info.type
         << ", p_sharded_id=" << info.p_sharded_id
         << ", c_sharded_id=" << info.c_sharded_id << ")";
      return os;
    }
    Missing Include

    The header file declares operator<< with std::ostream& parameter but doesn't include or . This may cause compilation issues depending on what includes are already present in the file.

    std::ostream& operator<<(std::ostream& os, const CommunicationInfo& info);

    @greptile-apps
    Copy link
    Contributor

    greptile-apps bot commented Feb 18, 2026

    Greptile Summary

    Added a std::ostream operator<< overload for the CommunicationInfo struct to enable printing for debugging purposes.

    • Declared the operator in lower_to_communication.h
    • Implemented the operator in lower_to_communication.cpp to print the communication type and producer/consumer sharded IDs
    • The implementation correctly leverages existing operator<< for CommunicationType and Statement* (which IterDomain* inherits from)

    Confidence Score: 5/5

    • This PR is safe to merge with minimal risk
    • This is a simple debugging utility addition that adds a stream operator for a struct. The implementation is correct, follows existing patterns in the codebase (using existing operator<< for CommunicationType and Statement*), and has no side effects on functionality.
    • No files require special attention

    Important Files Changed

    Filename Overview
    csrc/host_ir/lower_to_communication.h Added operator<< declaration for CommunicationInfo struct
    csrc/host_ir/lower_to_communication.cpp Implemented operator<< for CommunicationInfo struct to print type and sharded IDs

    Last reviewed commit: e2c35ca

    Copy link
    Contributor

    @greptile-apps greptile-apps bot left a comment

    Choose a reason for hiding this comment

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

    2 files reviewed, no comments

    Edit Code Review Agent Settings | Greptile

    @wujingyue wujingyue merged commit b796efa into main Feb 18, 2026
    50 of 51 checks passed
    @wujingyue wujingyue deleted the wjy/info branch February 18, 2026 03:50
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants