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

Reorganize src, tests, and benchmarks #1115

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,27 @@ endif()
# - library targets -------------------------------------------------------------------------------

add_library(cuspatial
src/bounding_boxes/linestring_bounding_boxes.cu
src/bounding_boxes/polygon_bounding_boxes.cu
src/column/geometry_column_view.cpp
src/indexing/construction/point_quadtree.cu
src/distance/hausdorff.cu
src/distance/haversine.cu
src/distance/linestring_distance.cu
src/distance/linestring_polygon_distance.cu
src/distance/point_distance.cu
src/distance/point_linestring_distance.cu
src/distance/point_polygon_distance.cu
src/distance/polygon_distance.cu
src/equality/pairwise_multipoint_equals_count.cu
src/indexing/point_quadtree.cu
src/intersection/linestring_intersection.cu
src/join/quadtree_point_in_polygon.cu
src/join/quadtree_point_to_nearest_linestring.cu
src/join/quadtree_bbox_filtering.cu
src/spatial/linestring_bounding_boxes.cu
src/spatial/polygon_bounding_boxes.cu
src/spatial/pairwise_multipoint_equals_count.cu
src/spatial/point_in_polygon.cu
src/spatial/points_in_range.cu
src/spatial/haversine.cu
src/spatial/hausdorff.cu
src/spatial/linestring_distance.cu
src/spatial/linestring_intersection.cu
src/spatial/point_distance.cu
src/spatial/point_linestring_distance.cu
src/spatial/point_polygon_distance.cu
src/spatial/linestring_polygon_distance.cu
src/spatial/polygon_distance.cu
src/spatial/point_linestring_nearest_points.cu
src/spatial/sinusoidal_projection.cu
src/nearest_points/point_linestring_nearest_points.cu
src/point_in_polygon/point_in_polygon.cu
src/points_in_range/points_in_range.cu
src/projection/sinusoidal_projection.cu
src/trajectory/derive_trajectories.cu
src/trajectory/trajectory_bounding_boxes.cu
src/trajectory/trajectory_distances_and_speeds.cu
Expand Down
19 changes: 8 additions & 11 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,20 @@ endfunction()
### benchmark sources #############################################################################
###################################################################################################

###################################################################################################
# - hausdorff benchmark ---------------------------------------------------------------------------

ConfigureBench(HAUSDORFF_BENCH
hausdorff_benchmark.cpp)
distance/hausdorff_benchmark.cpp)

ConfigureNVBench(DISTANCES_BENCH
pairwise_linestring_distance.cu)
distance/pairwise_linestring_distance.cu)

ConfigureNVBench(POINTS_IN_RANGE_BENCH
points_in_range.cu)
ConfigureNVBench(QUADTREE_ON_POINTS_BENCH
indexing/quadtree_on_points.cu)

ConfigureNVBench(POINT_IN_POLYGON_BENCH
point_in_polygon.cu)
point_in_polygon/point_in_polygon.cu)

ConfigureNVBench(QUADTREE_ON_POINTS_BENCH
quadtree_on_points.cu)
ConfigureNVBench(POINTS_IN_RANGE_BENCH
points_in_range/points_in_range.cu)

ConfigureNVBench(FLOATING_POINT_EQUALITY_BENCH
floating_point_equality.cu)
utility/floating_point_equality.cu)
7 changes: 3 additions & 4 deletions cpp/doxygen/developer_guide/BENCHMARKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ benchmarks in `cpp/benchmarks` to understand the options.
## Directory and File Naming

The naming of unit benchmark directories and source files should be consistent with the feature
being benchmarked. For example, the benchmarks for APIs in `point_in_polygon.hpp` should live in
`cpp/benchmarks/point_in_polygon.cu`. Each feature (or set of related features) should have its own
benchmark source file named `<feature>{.cu,cpp}`.
being benchmarked. For example, the benchmarks for APIs in `distance.hpp` should live in
`cpp/benchmarks/distance/`. Each feature (or set of related features) should have its own
benchmark source file named `<feature>{.cu,cpp}`.

## CUDA Asynchrony and benchmark accuracy

Expand Down Expand Up @@ -46,7 +46,6 @@ sets larger than this point is generally not helpful, except in specific cases w
exercises different code and can therefore uncover regressions that smaller benchmarks will not
(this should be rare).


Generally we should benchmark public APIs. Benchmarking detail functions and/or internal utilities
should only be done if detecting regressions in them would be sufficiently difficult to do from
public API benchmarks.
11 changes: 6 additions & 5 deletions cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ TODO: add terms

External/public libcuspatial APIs are grouped based on functionality into an appropriately titled
header file in `cuspatial/cpp/include/cuspatial/`. For example,
`cuspatial/cpp/include/cuspatial/projection.hpp` contains the declarations of public API
functions related to coordinate projection transforms. Note the `.hpp` file extension used to
`cuspatial/cpp/include/cuspatial/distance.hpp` contains the declarations of public API
functions related to distance computations. Note the `.hpp` file extension used to
indicate a C++ header file that can be included from a `.cpp` source file.

Header files should use the `#pragma once` include guard.

The folder that contains the source files that implement an API should be named consistently with
the name of the of the header for the API. For example, the implementation of the APIs found in
`cuspatial/cpp/include/cuspatial/trajectory.hpp` are located in `cuspatial/src/trajectory`. This
`cuspatial/cpp/include/cuspatial/trajectory.hpp` are located in `cuspatial/cpp/src/trajectory`. This
rule obviously does not apply to the header-only API, since the headers are the source files.

Likewise, unit tests reside in folders corresponding to the names of the API headers, e.g.
trajectory.hpp tests are in `cuspatial/tests/trajectory/`.
Likewise, unit tests and benchmarks reside in folders corresponding to the names of the API headers,
e.g. distance.hpp tests are in `cuspatial/cpp/tests/distance/` and benchmarks are in
`cuspatial/cpp/benchmarks/distance/`.

Internal API headers containing `detail` namespace definitions that are used across translation
units inside libcuspatial should be placed in `include/cuspatial/detail`.
Expand Down
5 changes: 2 additions & 3 deletions cpp/doxygen/developer_guide/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ rather than throwing exceptions.
## Directory and File Naming

The naming of unit test directories and source files should be consistent with the feature being
tested. For example, the tests for APIs in `point_in_polygon.hpp` should live in
`cuspatial/cpp/tests/point_in_polygon_test.cpp`. Each feature (or set of related features) should
have its own test source file named `<feature>_test.cu/cpp`.
tested. For example, the tests for APIs in `distance.hpp` should live in files in
`cuspatial/cpp/tests/distance/`.

In the interest of improving compile time, whenever possible, test source files should be `.cpp`
files because `nvcc` is slower than `gcc` in compiling host code. Note that `thrust::device_vector`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial/detail/utility/device_atomics.cuh>
#include <cuspatial/detail/utility/linestring.cuh>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <cuspatial/cuda_utils.hpp>
#include <cuspatial/iterator_factory.cuh>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2023, 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/cuda_utils.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial/detail/intersection/linestring_intersection_count.cuh>
#include <cuspatial/detail/utility/linestring.cuh>
#include <cuspatial/detail/utility/zero_data.cuh>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial/detail/algorithm/is_point_in_polygon.cuh>
#include <cuspatial/detail/join/get_quad_and_local_point_indices.cuh>
#include <cuspatial/error.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial/detail/algorithm/point_linestring_distance.cuh>
#include <cuspatial/detail/join/get_quad_and_local_point_indices.cuh>
#include <cuspatial/detail/utility/zero_data.cuh>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial/error.hpp>
#include <cuspatial/traits.hpp>

Expand Down
17 changes: 17 additions & 0 deletions cpp/include/cuspatial/distance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,23 @@ std::unique_ptr<cudf::column> pairwise_linestring_polygon_distance(
geometry_column_view const& multipolygons,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/**
* @brief Compute pairwise (multi)polygon-to-(multi)polygon Cartesian distance
*
* Computes the cartesian distance between each pair of the multipolygons.
*
* @param lhs Geometry column of the multipolygons to compute distance from
* @param rhs Geometry column of the multipolygons to compute distance to
* @param mr Device memory resource used to allocate the returned column.
*
* @return Column of distances between each pair of input geometries, same type as input coordinate
* types.
*/
std::unique_ptr<cudf::column> pairwise_polygon_distance(
geometry_column_view const& lhs,
geometry_column_view const& rhs,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/**
* @} // end of doxygen group
*/
Expand Down
44 changes: 0 additions & 44 deletions cpp/include/cuspatial/distance/polygon_distance.hpp

This file was deleted.

2 changes: 2 additions & 0 deletions cpp/include/cuspatial_test/column_factories.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial/types.hpp>

#include <cudf/column/column_factories.hpp>
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/cuspatial_test/geometry_generator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial_test/vector_factories.cuh>

#include <cuspatial/cuda_utils.hpp>
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/cuspatial_test/vector_factories.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <cuspatial_test/test_util.cuh>

#include <cuspatial/geometry/vec_2d.hpp>
Expand Down
File renamed without changes.
File renamed without changes.
43 changes: 0 additions & 43 deletions cpp/src/indexing/construction/detail/utilities.cuh

This file was deleted.

Loading