Skip to content

Add parallelSearchInner#337

Open
mwarusz wants to merge 3 commits intoE3SM-Project:developfrom
mwarusz:omega/par-search
Open

Add parallelSearchInner#337
mwarusz wants to merge 3 commits intoE3SM-Project:developfrom
mwarusz:omega/par-search

Conversation

@mwarusz
Copy link
Member

@mwarusz mwarusz commented Feb 5, 2026

Adds a function for searching an index range in parallel at the inner level of hierarchical parallelism. It is going to be useful in implementing the submesoscale eddy parametrization.

Checklist

  • Documentation:
  • Linting
  • Building
    • CMake build does not produce any new warnings from changes in this PR
  • Testing
    • Add a comment to the PR titled Testing with the following:
      • Which machines CTest unit tests
        have been run on and indicate that are all passing.
      • The Polaris omega_pr test suite
        has passed, using the Polaris e3sm_submodules/Omega baseline
      • Document machine(s), compiler(s), and the build path(s) used for -p for both the baseline (Polaris e3sm_submodules/Omega) and the PR build
      • Indicate "All tests passed" or document failing tests
      • Document testing used to verify the changes including any tests that are added/modified/impacted.
      • Performance related PRs: Please include a relevant PACE experiment link documenting performance before and after.
    • New tests:
      • CTest unit tests for new features have been added per the approved design.
      • Polaris tests for new features have been added per the approved design (and included in a test suite)

Copy link

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

Adds a new hierarchical-parallel helper to search an inner index range in parallel, intended to support upcoming physics (e.g., submesoscale eddy parameterization) by enabling “find first match” behavior inside team-level kernels.

Changes:

  • Added parallelSearchInner to the Kokkos hierarchical-parallel wrappers (returns first index matching a predicate, or -1).
  • Added a unit test covering full-range and sub-range search behavior.
  • Updated the developer guide to document the new inner-loop pattern.

Reviewed changes

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

File Description
components/omega/src/infra/OmegaKokkos.h Implements parallelSearchInner with host/device-specific behavior.
components/omega/test/infra/OmegaKokkosHiParTest.cpp Adds coverage validating correctness of the new search primitive.
components/omega/doc/devGuide/ParallelLoops.md Documents parallelSearchInner and provides an example usage snippet.

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

KOKKOS_FUNCTION void parallelSearchInner(const TeamMember &Team, int UpperBound,
F &&Functor, int &Idx) {
static_assert(std::is_same_v<std::invoke_result_t<F, int>, bool>,
"paralleSearchInner requires a functor that takes an int and "
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The static_assert message misspells the API name as paralleSearchInner, which makes diagnostics harder to search for. Please correct it to parallelSearchInner.

Suggested change
"paralleSearchInner requires a functor that takes an int and "
"parallelSearchInner requires a functor that takes an int and "

Copilot uses AI. Check for mistakes.
Comment on lines +294 to +297
int Idx;
parallelSearchInner(Team, N2, INNER_LAMBDA(Int J2) {
return M(J1, J2) > Threshold;
}, Idx);
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

In the new parallelSearchInner documentation example, the inner lambda parameter type is written as Int (capital I), but it should be int to match the actual API usage and avoid a non-compiling snippet.

Copilot uses AI. Check for mistakes.
Comment on lines +283 to +284
To search an index range in parallel for the first index where a given condition occurs Omega
provides the `parallelSearchInner` function.
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

This sentence reads as though a word is missing: “...where a given condition occurs Omega provides...”. Adding a comma after “occurs” (or rephrasing) would fix the grammar.

Suggested change
To search an index range in parallel for the first index where a given condition occurs Omega
provides the `parallelSearchInner` function.
To search an index range in parallel for the first index at which a given condition occurs,
Omega provides the `parallelSearchInner` function.

Copilot uses AI. Check for mistakes.
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.

1 participant

Comments