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

Experiment on pulling NVTX3 via CPM #1002

Draft
wants to merge 79 commits into
base: branch-23.08
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
965b80a
initial
isVoid Feb 28, 2023
38af8e6
Merge branch 'branch-23.04' of https://github.com/rapidsai/cuspatial …
isVoid Mar 1, 2023
02f61fe
add pragma once for floating_point.cuh
isVoid Mar 7, 2023
7bd797f
add polygon_ref structure
isVoid Mar 7, 2023
0968c15
add multipolygon_ref class
isVoid Mar 7, 2023
a659eab
update multipolygon_range class
isVoid Mar 7, 2023
c274070
update multipoint_range class
isVoid Mar 7, 2023
12ffa53
update is_point_in_polygon usage with polygon_ref
isVoid Mar 7, 2023
7490333
update multilinestring_range
isVoid Mar 7, 2023
f665287
add point to polygon kernel
isVoid Mar 7, 2023
291f6e6
add segment deduction guide
isVoid Mar 7, 2023
efa6883
add owning object type to vector factories
isVoid Mar 7, 2023
23146ef
add tests
isVoid Mar 7, 2023
ead160a
add helper files
isVoid Mar 7, 2023
09bd35f
add more tests
isVoid Mar 8, 2023
92760d1
bug fixes
isVoid Mar 8, 2023
8acb5dc
cleanups
isVoid Mar 8, 2023
a2b94fe
fix tests
isVoid Mar 8, 2023
46a67fe
optimize single point range input
isVoid Mar 8, 2023
b725b52
docs, type checks in range ctor
isVoid Mar 8, 2023
cb5706a
Merge branch 'branch-23.04' into feature/polygon_distances
isVoid Mar 8, 2023
ab59e7d
use range based for loop in is_point_in_polygon
isVoid Mar 8, 2023
b136c0b
Apply suggestions from code review
isVoid Mar 9, 2023
744f32f
add docs
isVoid Mar 9, 2023
bb6c637
style
isVoid Mar 9, 2023
756650b
Merge branch 'branch-23.04' of https://github.com/rapidsai/cuspatial …
isVoid Mar 9, 2023
8319e7c
fix bug in PiP tests
isVoid Mar 10, 2023
86d36d9
updates with test docs and API docs, address review
isVoid Mar 14, 2023
7bf8cbf
update offsets_to_keys
isVoid Mar 14, 2023
ff48dc7
update floating_point docs
isVoid Mar 14, 2023
b4420a7
use any_of
isVoid Mar 14, 2023
44e2843
add large (multigrid) tests, address reviews
isVoid Mar 14, 2023
57e6196
Merge branch 'branch-23.04' of https://github.com/rapidsai/cuspatial …
isVoid Mar 15, 2023
49972d4
add upper_bound_index.cuh
isVoid Mar 15, 2023
f000e00
remove upper_bound_index
isVoid Mar 15, 2023
57504e6
update geometry id factory
isVoid Mar 15, 2023
4865922
add get gtest scripts in cmake
isVoid Mar 15, 2023
ab52bc2
Merge branch 'branch-23.04' of https://github.com/rapidsai/cuspatial …
isVoid Mar 16, 2023
eff0e43
add generators and generator tests
isVoid Mar 17, 2023
6d14d69
add parameterized test fixture
isVoid Mar 17, 2023
5f347fd
adopt single kernel launch device multipolygon generation
isVoid Mar 18, 2023
bd78dfd
Merge branch 'branch-23.04' of https://github.com/rapidsai/cuspatial …
isVoid Mar 18, 2023
293ee0f
documentation
isVoid Mar 20, 2023
00a6728
document function
isVoid Mar 20, 2023
d910a7c
enable value parameterized test
isVoid Mar 20, 2023
bd6a4eb
revert distance benchmark
isVoid Mar 20, 2023
9e74468
mixin doc
isVoid Mar 20, 2023
fabc5ad
add point-polygon distance benchmark
isVoid Mar 20, 2023
de5a663
add benchmark file
isVoid Mar 21, 2023
5c67a80
address review comments
isVoid Mar 21, 2023
757057c
Merge branch 'benchmark/point_polygon_distance' into benchmark/point_…
isVoid Mar 21, 2023
2b46f18
Merge branch 'branch-23.04' into benchmark/point_polygon_distance_dev
isVoid Mar 21, 2023
eab8089
update sides->edge
isVoid Mar 21, 2023
dea6568
Merge branch 'branch-23.04' of https://github.com/rapidsai/cuspatial …
isVoid Mar 22, 2023
7b19c45
Merge branch 'benchmark/point_polygon_distance_dev' of github.com:isV…
isVoid Mar 22, 2023
1143977
add nvtx range and fix fixtures
isVoid Mar 23, 2023
72fc085
Merge branch 'branch-23.04' into benchmark/point_polygon_distance_dev
isVoid Mar 28, 2023
1c1fbc4
rename plural->singular form
isVoid Apr 14, 2023
4e56fe8
Merge branch 'branch-23.06' of https://github.com/rapidsai/cuspatial …
isVoid Apr 14, 2023
e662f1b
Merge branch 'benchmark/point_polygon_distance_dev' of github.com:isV…
isVoid Apr 14, 2023
80d92e4
style
isVoid Apr 14, 2023
c2e4390
Merge branch 'branch-23.06' into benchmark/point_polygon_distance_dev
harrism Apr 18, 2023
2ecb8d5
use cpm to pull nvtx
isVoid Apr 25, 2023
79416e8
Merge branch 'benchmark/point_polygon_distance_dev' of github.com:isV…
isVoid Apr 25, 2023
2688284
Merge branch 'branch-23.06' of https://github.com/rapidsai/cuspatial …
isVoid Apr 25, 2023
76b26ab
fixes broken API usage
isVoid Apr 25, 2023
8d34780
using rapids-cpm-find
isVoid Apr 25, 2023
0e66450
style
isVoid Apr 26, 2023
b089297
add build export set arg
isVoid Apr 26, 2023
172055e
Merge branch 'branch-23.06' of https://github.com/rapidsai/cuspatial …
isVoid May 3, 2023
545fdc2
update cmakelists.txt
isVoid May 3, 2023
e8e2dbe
Merge branch 'branch-23.06' of https://github.com/rapidsai/cuspatial …
isVoid May 4, 2023
aa8169b
Move
isVoid May 4, 2023
db628be
Fix bad renames
isVoid May 4, 2023
cc6ff27
Record progress
isVoid May 5, 2023
ae9fe35
Merge branch 'branch-23.06' of https://github.com/rapidsai/cuspatial …
isVoid May 9, 2023
4d4cf28
revert non nvtx3 cmake releated changes
isVoid May 10, 2023
1b978cd
add file that got removed
isVoid May 10, 2023
960d921
remove file
isVoid May 10, 2023
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
18 changes: 18 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ include(cmake/Modules/ConfigureCUDA.cmake)
rapids_cpm_init()
# find or add cuDF
include(cmake/thirdparty/CUSPATIAL_GetCUDF.cmake)

# # install nvtx3
# CPMAddPackage(
# NAME NVTX
# GITHUB_REPOSITORY NVIDIA/NVTX
# GIT_TAG v3.1.0-c-cpp
# GIT_SHALLOW TRUE)

rapids_cpm_find(
NVTX3 3.1.0
GLOBAL_TARGETS nvtx3-cpp
CPM_ARGS
GITHUB_REPOSITORY NVIDIA/NVTX
GIT_TAG v3.1.0-c-cpp
GIT_SHALLOW TRUE
)

# find or install GoogleTest
if (CUSPATIAL_BUILD_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
Expand Down Expand Up @@ -198,6 +215,7 @@ target_compile_definitions(cuspatial PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${

# Specify the target module library dependencies
target_link_libraries(cuspatial PUBLIC cudf::cudf)
target_link_libraries(cuspatial PUBLIC nvtx3-cpp)

add_library(cuspatial::cuspatial ALIAS cuspatial)

Expand Down
3 changes: 2 additions & 1 deletion cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ ConfigureBench(HAUSDORFF_BENCH
hausdorff_benchmark.cpp)

ConfigureNVBench(DISTANCES_BENCH
pairwise_linestring_distance.cu)
pairwise_linestring_distance.cu
pairwise_point_polygon_distance.cu)

ConfigureNVBench(POINTS_IN_RANGE_BENCH
points_in_range.cu)
Expand Down
134 changes: 134 additions & 0 deletions cpp/benchmarks/pairwise_point_polygon_distance.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* 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.
*/

#include <benchmarks/fixture/rmm_pool_raii.hpp>
#include <nvbench/nvbench.cuh>

#include <cuspatial_test/geometry_generator.cuh>

#include <cuspatial/experimental/point_polygon_distance.cuh>
#include <cuspatial/vec_2d.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>

using namespace cuspatial;
using namespace cuspatial::test;

template <typename T>
void pairwise_point_polygon_distance_benchmark(nvbench::state& state, nvbench::type_list<T>)
{
// TODO: to be replaced by nvbench fixture once it's ready
cuspatial::rmm_pool_raii rmm_pool;
rmm::cuda_stream_view stream{rmm::cuda_stream_default};

auto const num_pairs{static_cast<std::size_t>(state.get_int64("num_pairs"))};

auto const num_polygons_per_multipolygon{
static_cast<std::size_t>(state.get_int64("num_polygons_per_multipolygon"))};
auto const num_holes_per_polygon{
static_cast<std::size_t>(state.get_int64("num_holes_per_polygon"))};
auto const num_edges_per_ring{static_cast<std::size_t>(state.get_int64("num_edges_per_ring"))};

auto const num_points_per_multipoint{
static_cast<std::size_t>(state.get_int64("num_points_per_multipoint"))};

auto mpoly_generator_param = multipolygon_generator_parameter<T>{
num_pairs, num_polygons_per_multipolygon, num_holes_per_polygon, num_edges_per_ring};

auto mpoint_generator_param = multipoint_generator_parameter<T>{
num_pairs, num_points_per_multipoint, vec_2d<T>{-1, -1}, vec_2d<T>{0, 0}};

auto multipolygons = generate_multipolygon_array<T>(mpoly_generator_param, stream);
auto multipoints = generate_multipoint_array<T>(mpoint_generator_param, stream);

auto distances = rmm::device_vector<T>(num_pairs);
auto out_it = distances.begin();

auto mpoly_view = multipolygons.range();
auto mpoint_view = multipoints.range();

state.add_element_count(num_pairs, "NumPairs");
state.add_element_count(mpoly_generator_param.num_polygons(), "NumPolygons");
state.add_element_count(mpoly_generator_param.num_rings(), "NumRings");
state.add_element_count(mpoly_generator_param.num_coords(), "NumPoints (in mpoly)");
state.add_element_count(static_cast<std::size_t>(mpoly_generator_param.num_coords() *
mpoly_generator_param.num_rings() *
mpoly_generator_param.num_polygons()),
"Multipolygon Complexity");
state.add_element_count(mpoint_generator_param.num_points(), "NumPoints (in multipoints)");

state.add_global_memory_reads<T>(
mpoly_generator_param.num_coords() + mpoint_generator_param.num_points(),
"CoordinatesReadSize");
state.add_global_memory_reads<std::size_t>(
(mpoly_generator_param.num_rings() + 1) + (mpoly_generator_param.num_polygons() + 1) +
(mpoly_generator_param.num_multipolygons + 1) + (mpoint_generator_param.num_multipoints + 1),
"OffsetsDataSize");

state.add_global_memory_writes<T>(num_pairs);

state.exec(nvbench::exec_tag::sync,
[&mpoly_view, &mpoint_view, &out_it, &stream](nvbench::launch& launch) {
pairwise_point_polygon_distance(mpoint_view, mpoly_view, out_it, stream);
});
}

using floating_point_types = nvbench::type_list<float, double>;

// Benchmark scalability with simple multipolygon (3 sides, 0 hole, 1 poly)
NVBENCH_BENCH_TYPES(pairwise_point_polygon_distance_benchmark,
NVBENCH_TYPE_AXES(floating_point_types))
.set_type_axes_names({"CoordsType"})
.add_int64_axis("num_pairs", {1, 1'00, 10'000, 1'000'000, 100'000'000})
.add_int64_axis("num_polygons_per_multipolygon", {1})
.add_int64_axis("num_holes_per_polygon", {0})
.add_int64_axis("num_edges_per_ring", {3})
.add_int64_axis("num_points_per_multipoint", {1})
.set_name("point_polygon_distance_benchmark_simple_polygon");

// Benchmark scalability with complex multipolygon (100 sides, 10 holes, 3 polys)
NVBENCH_BENCH_TYPES(pairwise_point_polygon_distance_benchmark,
NVBENCH_TYPE_AXES(floating_point_types))
.set_type_axes_names({"CoordsType"})
.add_int64_axis("num_pairs", {1'000, 10'000, 100'000, 1'000'000})
.add_int64_axis("num_polygons_per_multipolygon", {2})
.add_int64_axis("num_holes_per_polygon", {3})
.add_int64_axis("num_edges_per_ring", {50})
.add_int64_axis("num_points_per_multipoint", {1})
.set_name("point_polygon_distance_benchmark_complex_polygon");

// // Benchmark impact of rings (100K pairs, 1 polygon, 3 sides)
NVBENCH_BENCH_TYPES(pairwise_point_polygon_distance_benchmark,
NVBENCH_TYPE_AXES(floating_point_types))
.set_type_axes_names({"CoordsType"})
.add_int64_axis("num_pairs", {10'000})
.add_int64_axis("num_polygons_per_multipolygon", {1})
.add_int64_axis("num_holes_per_polygon", {0, 10, 100, 1000})
.add_int64_axis("num_edges_per_ring", {3})
.add_int64_axis("num_points_per_multipoint", {1})
.set_name("point_polygon_distance_benchmark_ring_numbers");

// Benchmark impact of rings (1M pairs, 1 polygon, 0 holes, 3 sides)
NVBENCH_BENCH_TYPES(pairwise_point_polygon_distance_benchmark,
NVBENCH_TYPE_AXES(floating_point_types))
.set_type_axes_names({"CoordsType"})
.add_int64_axis("num_pairs", {100})
.add_int64_axis("num_polygons_per_multipolygon", {1})
.add_int64_axis("num_holes_per_polygon", {0})
.add_int64_axis("num_edges_per_ring", {3})
.add_int64_axis("num_points_per_multipoint", {50, 5'00, 5'000, 50'000, 500'000})
.set_name("point_polygon_distance_benchmark_points_in_multipoint");
Loading