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

Header-only refactoring of derive_trajectories #628

Merged

Conversation

harrism
Copy link
Member

@harrism harrism commented Aug 4, 2022

Contributes to #563 .

@harrism harrism added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change c++ labels Aug 4, 2022
@harrism harrism added this to the header-only C++ API milestone Aug 4, 2022
@harrism harrism self-assigned this Aug 4, 2022
@github-actions github-actions bot added the libcuspatial Relates to the cuSpatial C++ library label Aug 4, 2022
@github-actions github-actions bot added the cmake Related to CMake code or build configuration label Aug 9, 2022
@harrism harrism marked this pull request as ready for review August 23, 2022 01:56
@harrism harrism requested review from a team as code owners August 23, 2022 01:56
@harrism harrism requested review from trxcllnt, jrhemstad and isVoid and removed request for jrhemstad August 23, 2022 01:56
@harrism harrism added the 3 - Ready for Review Ready for review by team label Aug 28, 2022
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.

To me, I don't see a fundamental difference between trajectories_utilities.cuh and trajectory_test_utils.cuh. After we do more refactoring we might be able to replace trajectories_utilities.cuh completely.

@harrism
Copy link
Member Author

harrism commented Sep 7, 2022

To me, I don't see a fundamental difference between trajectories_utilities.cuh and trajectory_test_utils.cuh. After we do more refactoring we might be able to replace trajectories_utilities.cuh completely.

Yes, my idea is to eliminate it. It is still used by trajectory_distance_and_speed and trajectory_bounding_boxes which will be refactored in separate PRs.

@harrism harrism requested review from thomcom and removed request for trxcllnt September 19, 2022 23:13
/**
* @brief Derive trajectories from object ids, points, and timestamps.
*
* Groups the input object ids to determine unique trajectories, and reorders all input data to be
Copy link
Contributor

Choose a reason for hiding this comment

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

This reads like the input data will be reordered in-place.

stream,
mr);

auto const num_points = std::distance(ids_first, ids_last);
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed here that you're computing the number of points based on the number of ids. I suggest that you error check here that the number of ids, points, and trajectories are all equal.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's not possible -- we only get a last iterator for ids. Assuming (not asserting) the iterator ranges are equal is standard practice in iterator-based APIs like this (and Thrust, and STL).

Copy link
Member Author

@harrism harrism Sep 21, 2022

Choose a reason for hiding this comment

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

Also, the beauty of an iterator-based API is flexibility / fusability. The caller is free to pass anything that looks like an iterator -- it might be, for example, a counting iterator, or some other dynamic iterator type that generates an open-ended sequence. There is no end. :)

cpp/tests/base_fixture.hpp Outdated Show resolved Hide resolved
cpp/tests/base_fixture.hpp Outdated Show resolved Hide resolved
}
};

void make_data(std::size_t num_trajectories, std::size_t max_trajectory_size)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
void make_data(std::size_t num_trajectories, std::size_t max_trajectory_size)
void trajectory_test_data(std::size_t num_trajectories, std::size_t max_trajectory_size)

cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size / 2, rmm::cuda_stream_default));
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Judging from these tests, I missed the spot above where you are in fact checking that all lengths are the same?

Copy link
Member Author

Choose a reason for hiding this comment

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

We check in the column-based API, but we can't check in the header-only API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Columns have a defined size. Iterators don't.

@harrism
Copy link
Member Author

harrism commented Sep 27, 2022

rerun tests

@harrism
Copy link
Member Author

harrism commented Sep 27, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 2080ab1 into rapidsai:branch-22.10 Sep 27, 2022
rapids-bot bot pushed a commit that referenced this pull request Oct 24, 2022
Contributes to #563 

Header-only refactoring of `cuspatial::trajectory_bounding_boxes`

Note the commit list is messy because it was originally based off of #628 which was merged into 22.10.

Authors:
  - Mark Harris (https://github.com/harrism)

Approvers:
  - Michael Wang (https://github.com/isVoid)
  - Paul Taylor (https://github.com/trxcllnt)

URL: #741
@harrism harrism removed the c++ label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team cmake Related to CMake code or build configuration improvement Improvement / enhancement to an existing function libcuspatial Relates to the cuSpatial C++ library non-breaking Non-breaking change
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants