Skip to content

HPP: refresh Machine class and MachineQueryIterator class#336

Open
ebendler wants to merge 1 commit intoStanfordLegion:mainfrom
ebendler:proc_query
Open

HPP: refresh Machine class and MachineQueryIterator class#336
ebendler wants to merge 1 commit intoStanfordLegion:mainfrom
ebendler:proc_query

Conversation

@ebendler
Copy link
Copy Markdown
Collaborator

No description provided.

@ebendler ebendler requested review from Copilot and muraj October 22, 2025 19:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refreshes the Machine class and MachineQueryIterator class in the HPP interface. It implements previously unimplemented methods, refactors callback functions for better clarity, and adds comprehensive unit tests.

  • Implements Machine::get_machine() and iterator functionality for MachineQueryIterator
  • Refactors callback templates to be more explicit about handle types
  • Improves error messages to include status codes

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/unit_tests/hpp_machine_tests.cc Adds comprehensive unit tests for Machine class functionality including processor/memory queries
tests/CMakeLists.txt Registers the new test file in the build system
src/realm.hpp Implements Machine::get_machine(), refactors callback templates, implements MachineQueryIterator operators, and improves error messages

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


// Verify all processors exist
for(const auto &proc : processors) {
EXPECT_TRUE(proc.exists());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should verify that all the processors returned match the specification (one gpu, which node they're on, etc). It's not enough to just iterate through the given list and ensure they all exist.

@ebendler ebendler force-pushed the proc_query branch 3 times, most recently from c5096c3 to e2e9d9f Compare October 27, 2025 16:53
@ebendler ebendler requested a review from muraj October 27, 2025 16:56
// ============================================================================

INSTANTIATE_TEST_SUITE_P(MachineModelVariations, HPPMachineTest,
::testing::Values(createBasicSingleNodeConfig(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Try taking a look at topology_test.cc for a slightly better way to lay this out.

}
}

TEST_P(HPPMachineTest, QueryLocalProcessorsByCPUKind)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can be made more data driven as well. For example, you can loop over all kinds and perform the query. Or you can pass in, as an extra test parameter, the kind to look for, taking to make sure to test either kinds that can't exist (like an invalid enum value) as well as ones that don't happen to exist in the current machine model (e.g. asking for gpus when there aren't any in the machine model). All of these should verify not only that the returned processors are valid and have the appropriate kind, but also return all the processors specified that meet the appropriate kind. Additionally, since this is a query for only the local processors, it should follow that we much also verify that all processors have the same address space as the one specified to be local in the machine config, and a test case needs to be made such that there are more than one address space / node to verify these are not returned. By doing this, you'll see that you incrementally improve coverage with each data test case without having to modify the actual logic of the test, making the test easily scale to all sorts of different corner cases.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've updated the test to do more with instantiated topologies

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

EXPECT_EQ(proc.address_space(), 0)
<< "Processor should be in local address space (0), but is in "
<< proc.address_space();
actualProcessorIds.insert(proc.id);
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Inserting proc.id (the raw processor ID) instead of the processor index (proc_id.proc_proc_idx()) creates a mismatch with expectedProcessorIds which contains processor indices from the configuration. This will cause the comparison at line 504 to fail. Should use Realm::ID(proc.id).proc_proc_idx() to extract the processor index.

Suggested change
actualProcessorIds.insert(proc.id);
actualProcessorIds.insert(Realm::ID(proc.id).proc_proc_idx());

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 88.46154% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.16%. Comparing base (ca926d3) to head (e730ed0).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
tests/unit_tests/hpp_machine_tests.cc 88.69% 26 Missing ⚠️
src/realm.hpp 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #336      +/-   ##
==========================================
+ Coverage   27.74%   28.16%   +0.42%     
==========================================
  Files         191      192       +1     
  Lines       39499    39805     +306     
  Branches    14382    14252     -130     
==========================================
+ Hits        10960    11213     +253     
+ Misses      28147    27145    -1002     
- Partials      392     1447    +1055     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

3 participants