-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize cuSpatial headers (#1097)
Fixes #1080 based on the discussion in #1087 - Consolidate each major set of features within common headers, e.g. `distance.hpp/.cuh`, `intersection.hpp/.cuh`. - Consolidate point-in-polygon APIs / headers and DRY up implementation - Rename some headers/APIS that were inconsistent across the header-only and column-based APIs, e.g. `points_in_spatial_window` vs. `points_in_range`. - Update Cython where needed to account for above changes. This PR does NOT yet reorganize source code. Update: Compilation Time Results --------------------------------------------- Compilation time is not changed appreciably by this PR (<0.5% faster). This test was performed by disabling `sccache`, erasing everything in the build directory, configuring cmake (including building tests and benchmarks), and then running `time ninja`. My machine has a "AMD Ryzen 7 3700X 8-Core Processor", and I'm using Ninja's default parallelism. #### Disabling `sccache` when using the cuSpatial devcontainer ``` (rapids) coder ➜ ~/cuspatial/ $ cd cpp/build/release (rapids) coder ➜ ~/cuspatial/cpp/build/release $ rm -rf ./* (rapids) coder ➜ ~/cuspatial/cpp/build/release $ unset RUSTC_WRAPPER (rapids) coder ➜ ~/cuspatial/cpp/build/release $ unset CMAKE_C_COMPILER_LAUNCHER (rapids) coder ➜ ~/cuspatial/cpp/build/release $ unset CMAKE_CXX_COMPILER_LAUNCHER (rapids) coder ➜ ~/cuspatial/cpp/build/release $ unset CMAKE_CUDA_COMPILER_LAUNCHER (rapids) coder ➜ ~/cuspatial/cpp/build/release $ cmake ~/cuspatial/cpp -GNinja -DBUILD_TESTS=ON -DBUILD_BENCHMARKS=ON (rapids) coder ➜ ~/cuspatial/cpp/build/release $ time ninja ``` ### This branch: ``` [201/201] Linking CXX executable gtests/LINESTRING_INTERSECTION_TEST_EXP real 10m42.845s user 122m28.077s sys 6m7.935s ``` ### `branch-23.06`: ``` [202/202] Linking CXX executable gtests/LINESTRING_INTERSECTION_TEST_EXP real 10m45.573s user 122m52.896s sys 6m9.357s ``` Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Wang (https://github.com/isVoid) - Paul Taylor (https://github.com/trxcllnt) - H. Thomson Comer (https://github.com/thomcom) URL: #1097
- Loading branch information
Showing
166 changed files
with
1,780 additions
and
2,471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cuspatial/traits.hpp> | ||
|
||
#include <rmm/cuda_stream_view.hpp> | ||
|
||
namespace cuspatial { | ||
|
||
/** | ||
* @addtogroup spatial_relationship | ||
* @{ | ||
*/ | ||
|
||
/** | ||
* @brief Compute the spatial bounding boxes of sequences of points. | ||
* | ||
* Computes a bounding box around all points within each group (consecutive points with the same | ||
* ID). This function can be applied to trajectory data, polygon vertices, linestring vertices, or | ||
* any grouped point data. | ||
* | ||
* Before merging bounding boxes, each point may be expanded into a bounding box using an | ||
* optional @p expansion_radius. The point is expanded to a box with coordinates | ||
* `(point.x - expansion_radius, point.y - expansion_radius)` and | ||
* `(point.x + expansion_radius, point.y + expansion_radius)`. | ||
* | ||
* @note Assumes Object IDs and points are presorted by ID. | ||
* | ||
* @tparam IdInputIt Iterator over object IDs. Must meet the requirements of | ||
* [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. | ||
* @tparam PointInputIt Iterator over points. Must meet the requirements of | ||
* [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. | ||
* @tparam BoundingBoxOutputIt Iterator over output bounding boxes. Each element is a tuple of two | ||
* points representing corners of the axis-aligned bounding box. The type of the points is the same | ||
* as the `value_type` of PointInputIt. Must meet the requirements of | ||
* [LegacyRandomAccessIterator][LinkLRAI] and be device-writeable. | ||
* | ||
* @param ids_first beginning of the range of input object ids | ||
* @param ids_last end of the range of input object ids | ||
* @param points_first beginning of the range of input point (x,y) coordinates | ||
* @param bounding_boxes_first beginning of the range of output bounding boxes, one per trajectory | ||
* @param expansion_radius radius to add to each point when computing its bounding box. | ||
* @param stream the CUDA stream on which to perform computations. | ||
* | ||
* @return An iterator to the end of the range of output bounding boxes. | ||
* | ||
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator | ||
* "LegacyRandomAccessIterator" | ||
*/ | ||
template <typename IdInputIt, | ||
typename PointInputIt, | ||
typename BoundingBoxOutputIt, | ||
typename T = iterator_vec_base_type<PointInputIt>> | ||
BoundingBoxOutputIt point_bounding_boxes(IdInputIt ids_first, | ||
IdInputIt ids_last, | ||
PointInputIt points_first, | ||
BoundingBoxOutputIt bounding_boxes_first, | ||
T expansion_radius = T{0}, | ||
rmm::cuda_stream_view stream = rmm::cuda_stream_default); | ||
|
||
/** | ||
* @brief Compute minimum bounding box for each linestring. | ||
* | ||
* @tparam LinestringOffsetIterator Iterator type to linestring offsets. Must meet the requirements | ||
* of [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. | ||
* @tparam VertexIterator Iterator type to linestring vertices. Must meet the requirements of | ||
* [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. | ||
* @tparam BoundingBoxIterator Iterator type to bounding boxes. Must be writable using data of type | ||
* `cuspatial::box<T>`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be | ||
* device-writeable. | ||
* @tparam T The coordinate data value type. | ||
* @tparam IndexT The offset data value type. | ||
* @param linestring_offsets_first Iterator to beginning of the range of input polygon offsets. | ||
* @param linestring_offsets_last Iterator to end of the range of input polygon offsets. | ||
* @param linestring_vertices_first Iterator to beginning of the range of input polygon vertices. | ||
* @param linestring_vertices_last Iterator to end of the range of input polygon vertices. | ||
* @param bounding_boxes_first Iterator to beginning of the range of output bounding boxes. | ||
* @param expansion_radius Optional radius to expand each vertex of the output bounding boxes. | ||
* @param stream the CUDA stream on which to perform computations and allocate memory. | ||
* | ||
* @return An iterator to the end of the range of output bounding boxes. | ||
* | ||
* @pre For compatibility with GeoArrow, the number of linestring offsets | ||
* `std::distance(linestring_offsets_first, linestring_offsets_last)` should be one more than the | ||
* number of linestrings. The final offset is not used by this function, but the number of offsets | ||
* determines the output size. | ||
* | ||
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator | ||
* "LegacyRandomAccessIterator" | ||
*/ | ||
template <class LinestringOffsetIterator, | ||
class VertexIterator, | ||
class BoundingBoxIterator, | ||
class T = iterator_vec_base_type<VertexIterator>, | ||
class IndexT = iterator_value_type<LinestringOffsetIterator>> | ||
BoundingBoxIterator linestring_bounding_boxes( | ||
LinestringOffsetIterator linestring_offsets_first, | ||
LinestringOffsetIterator linestring_offsets_last, | ||
VertexIterator linestring_vertices_first, | ||
VertexIterator linestring_vertices_last, | ||
BoundingBoxIterator bounding_boxes_first, | ||
T expansion_radius = T{0}, | ||
rmm::cuda_stream_view stream = rmm::cuda_stream_default); | ||
|
||
/** | ||
* @brief Compute minimum bounding box for each polygon. | ||
* | ||
* @tparam PolygonOffsetIterator Iterator type to polygon offsets. Must meet the requirements of | ||
* [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. | ||
* @tparam RingOffsetIterator Iterator type to polygon ring offsets. Must meet the requirements of | ||
* [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. | ||
* @tparam VertexIterator Iterator type to polygon vertices. Must meet the requirements of | ||
* [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. | ||
* @tparam BoundingBoxIterator Iterator type to bounding boxes. Must be writable using data of type | ||
* `cuspatial::box<T>`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be | ||
* device-writeable. | ||
* @tparam T The coordinate data value type. | ||
* @tparam IndexT The offset data value type. | ||
* @param polygon_offsets_first Iterator to beginning of the range of input polygon offsets. | ||
* @param polygon_offsets_last Iterator to end of the range of input polygon offsets. | ||
* @param polygon_ring_offsets_first Iterator to beginning of the range of input polygon ring | ||
* offsets. | ||
* @param polygon_ring_offsets_last Iterator to end of the range of input polygon ring offsets. | ||
* @param polygon_vertices_first Iterator to beginning of the range of input polygon vertices. | ||
* @param polygon_vertices_last Iterator to end of the range of input polygon vertices. | ||
* @param bounding_boxes_first Iterator to beginning of the range of output bounding boxes. | ||
* @param expansion_radius Optional radius to expand each vertex of the output bounding boxes. | ||
* @param stream the CUDA stream on which to perform computations and allocate memory. | ||
* | ||
* @return An iterator to the end of the range of output bounding boxes. | ||
* | ||
* @pre For compatibility with GeoArrow, the number of polygon offsets | ||
* `std::distance(polygon_offsets_first, polygon_offsets_last)` should be one more than the number | ||
* of polygons. The number of ring offsets `std::distance(polygon_ring_offsets_first, | ||
* polygon_ring_offsets_last)` should be one more than the number of total rings. The | ||
* final offset in each range is not used by this function, but the number of polygon offsets | ||
* determines the output size. | ||
* | ||
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator | ||
* "LegacyRandomAccessIterator" | ||
*/ | ||
template <class PolygonOffsetIterator, | ||
class RingOffsetIterator, | ||
class VertexIterator, | ||
class BoundingBoxIterator, | ||
class T = iterator_vec_base_type<VertexIterator>, | ||
class IndexT = iterator_value_type<PolygonOffsetIterator>> | ||
BoundingBoxIterator polygon_bounding_boxes(PolygonOffsetIterator polygon_offsets_first, | ||
PolygonOffsetIterator polygon_offsets_last, | ||
RingOffsetIterator polygon_ring_offsets_first, | ||
RingOffsetIterator polygon_ring_offsets_last, | ||
VertexIterator polygon_vertices_first, | ||
VertexIterator polygon_vertices_last, | ||
BoundingBoxIterator bounding_boxes_first, | ||
T expansion_radius = T{0}, | ||
rmm::cuda_stream_view stream = rmm::cuda_stream_default); | ||
|
||
/** | ||
* @} // end of doxygen group | ||
*/ | ||
|
||
} // namespace cuspatial | ||
|
||
#include <cuspatial/detail/bounding_boxes.cuh> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.