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

Fix multipolygon geometry iterator. #1402

Merged

Conversation

bdice
Copy link
Contributor

@bdice bdice commented Jul 7, 2024

Description

This PR fixes a bug in the multipolygon geometry iterator. The geometry iterator was returning part iterators by mistake, which masked an issue that we were patching out in rapids-cmake's CCCL. See rapidsai/rapids-cmake#511.

With this fix, we can remove that patch from rapids-cmake's CCCL: rapidsai/rapids-cmake#640

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@bdice bdice requested a review from a team as a code owner July 7, 2024 19:07
@bdice bdice requested review from trxcllnt and harrism July 7, 2024 19:07
@github-actions github-actions bot added the libcuspatial Relates to the cuSpatial C++ library label Jul 7, 2024
<< "Part Offsets:\n\t{" << part_offsets << "}\n"
<< "Ring Offsets: \n\t{" << ring_offsets << "}\n"
<< "Coordinates: \n\t{" << coordinates << "}\n";
auto print_vector = [&](auto const& vec) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without these changes, I was seeing errors that no operator<< overload existed for thrust::host_vector.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did thrust remove this overload from host_vector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't aware that such an overload ever existed. I don't see that implemented: https://github.com/search?q=repo%3ANVIDIA%2Fcccl%20operator%3C%3C&type=code

Comment on lines +118 to +121
CUSPATIAL_HOST_DEVICE auto geometry_offset_begin() { return _geometry_begin; }

/// Return the iterator to the one past the last geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto geometry_offset_end() { return _part_end; }
CUSPATIAL_HOST_DEVICE auto geometry_offset_end() { return _geometry_end; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the core bug: the thrust::copy call using the geometry offsets was getting the wrong size because the wrong iterator was being returned.

This only became visible in the one test case where a multipolygon contained more than one polygon.

@@ -1069,7 +1069,7 @@ class MultipolygonRangeOneTest : public MultipolygonRangeTestBase<T> {
void test_geometry_offsets_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_geometry_offsets();
auto expected = make_device_vector<std::size_t>({0, 1});
auto expected = make_device_vector<std::size_t>({0, 2});
Copy link
Contributor Author

@bdice bdice Jul 7, 2024

Choose a reason for hiding this comment

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

The geometry offsets are {0, 2}. This test silently passed because the part iterators are {0, 1, 2} and somehow thrust::copy was silently copying only the first two values. CCCL's current behavior (without the patch) of erroring is appropriate, but I mistakenly thought it was a CCCL bug instead of a cuSpatial bug at that time.

@bdice bdice added bug Something isn't working non-breaking Non-breaking change labels Jul 7, 2024
@bdice bdice self-assigned this Jul 7, 2024
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Thanks for fixing! @isVoid should review too.

Copy link
Contributor

@isVoid isVoid left a comment

Choose a reason for hiding this comment

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

Thanks for fixing! This is indeed a core bug.

@bdice
Copy link
Contributor Author

bdice commented Jul 8, 2024

Thanks for the reviews. There are some failing tests but I think they are related to #1400 and not this PR. I pinged @mroeschke to look into that PR, and I'll merge the upstream into this PR once that goes in. Then we can remove the CCCL patches from cuDF and rapids-cmake.

@jameslamb jameslamb mentioned this pull request Jul 8, 2024
@bdice
Copy link
Contributor Author

bdice commented Jul 9, 2024

/merge

@rapids-bot rapids-bot bot merged commit 20ef0e7 into rapidsai:branch-24.08 Jul 9, 2024
69 checks passed
rapids-bot bot pushed a commit to rapidsai/cudf that referenced this pull request Jul 9, 2024
While upgrading CCCL, we ran into a test failure in cuSpatial. We added a patch to revert some changes from CCCL but the root cause was a bug in cuSpatial. I have fixed that bug here: rapidsai/cuspatial#1402

Once that PR is merged, we can remove this CCCL patch.

See also:
- rapids-cmake patch removal: rapidsai/rapids-cmake#640
- Original rapids-cmake patch: rapidsai/rapids-cmake#511
- CCCL epic to remove RAPIDS patches: NVIDIA/cccl#1939

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)

URL: #16207
rapids-bot bot pushed a commit to rapidsai/rapids-cmake that referenced this pull request Jul 9, 2024
While upgrading CCCL, we ran into a test failure in cuSpatial. We added a patch to revert some changes from CCCL but the root cause was a bug in cuSpatial. I have fixed that bug here: rapidsai/cuspatial#1402

Once that PR is merged, we can remove this CCCL patch.

See also:
- #511
- NVIDIA/cccl#1939

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)

URL: #640
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libcuspatial Relates to the cuSpatial C++ library non-breaking Non-breaking change
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

5 participants