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

Add variance to the number of geometries/components in multipoint/multilinestring/multipolygon generator #1173

Draft
wants to merge 4 commits into
base: branch-23.08
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
21 changes: 11 additions & 10 deletions cpp/benchmarks/distance/pairwise_linestring_distance.cu
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ void pairwise_linestring_distance_benchmark(nvbench::state& state, nvbench::type
auto const num_segments_per_linestring{
static_cast<std::size_t>(state.get_int64("NumSegmentsPerLineString"))};

auto params1 = test::multilinestring_generator_parameter<T>{
auto params1 = test::multilinestring_fixed_generator_parameter<T>{
num_pairs, num_linestrings_per_multilinestring, num_segments_per_linestring, 1.0, {0., 0.}};
auto params2 = test::multilinestring_generator_parameter<T>{num_pairs,
num_linestrings_per_multilinestring,
num_segments_per_linestring,
1.0,
{100000., 100000.}};
auto params2 =
test::multilinestring_fixed_generator_parameter<T>{num_pairs,
num_linestrings_per_multilinestring,
num_segments_per_linestring,
1.0,
{100000., 100000.}};

auto ls1 = generate_multilinestring_array(params1, stream);
auto ls2 = generate_multilinestring_array(params2, stream);
Expand All @@ -55,15 +56,15 @@ void pairwise_linestring_distance_benchmark(nvbench::state& state, nvbench::type
auto output = rmm::device_uvector<T>(num_pairs, stream);
auto out_it = output.begin();

auto const total_points = params1.num_points() + params2.num_points();
auto const total_points = ls1range.num_points() + ls2range.num_points();

state.add_element_count(num_pairs, "NumPairs");
state.add_element_count(total_points, "NumPoints");

state.add_global_memory_reads<T>(total_points * 2, "CoordinatesDataSize");
state.add_global_memory_reads<int32_t>(params1.num_multilinestrings +
params2.num_multilinestrings +
params1.num_linestrings() + params2.num_linestrings(),
state.add_global_memory_reads<int32_t>(ls1range.num_multilinestrings() +
ls2range.num_multilinestrings() +
ls1range.num_linestrings() + ls2range.num_linestrings(),
"OffsetsDataSize");
state.add_global_memory_writes<T>(num_pairs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void pairwise_linestring_polygon_distance_benchmark(nvbench::state& state, nvben
auto const num_ring_per_polygon{static_cast<std::size_t>(state.get_int64("NumRingsPerPolygon"))};
auto const num_points_per_ring{static_cast<std::size_t>(state.get_int64("NumPointsPerRing"))};

auto params1 = test::multilinestring_generator_parameter<T>{
auto params1 = test::multilinestring_fixed_generator_parameter<T>{
num_pairs, num_linestrings_per_multilinestring, num_segments_per_linestring, 1.0, {0., 0.}};
auto params2 = test::multipolygon_generator_parameter<T>{num_pairs,
num_polygon_per_multipolygon,
Expand All @@ -66,10 +66,10 @@ void pairwise_linestring_polygon_distance_benchmark(nvbench::state& state, nvben
state.add_element_count(num_pairs, "NumPairs");
state.add_element_count(total_points, "NumPoints");
state.add_global_memory_reads<T>(total_points * 2, "CoordinatesDataSize");
state.add_global_memory_reads<int32_t>(params1.num_multilinestrings + params1.num_linestrings() +
params2.num_multipolygons + params2.num_polygons() +
params2.num_rings() + 5,
"OffsetsDataSize");
state.add_global_memory_reads<int32_t>(
lines_range.num_multilinestrings() + lines_range.num_linestrings() +
poly_range.num_multipolygons() + poly_range.num_polygons() + poly_range.num_rings() + 5,
"OffsetsDataSize");
state.add_global_memory_writes<T>(num_pairs);

state.exec(nvbench::exec_tag::sync,
Expand Down
20 changes: 10 additions & 10 deletions cpp/benchmarks/distance/pairwise_point_polygon_distance.cu
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void pairwise_point_polygon_distance_benchmark(nvbench::state& state, nvbench::t
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>{
auto mpoint_generator_param = multipoint_fixed_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);
Expand All @@ -69,15 +69,15 @@ void pairwise_point_polygon_distance_benchmark(nvbench::state& state, nvbench::t
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_element_count(mpoint_view.num_points(), "NumPoints (in multipoints)");

state.add_global_memory_reads<T>(mpoly_generator_param.num_coords() + mpoint_view.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);

Expand Down
8 changes: 8 additions & 0 deletions cpp/include/cuspatial/iterator_factory.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#pragma once

#include <cuspatial/detail/functors.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/box.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
Expand Down Expand Up @@ -424,6 +425,13 @@ auto make_geometry_id_iterator(GeometryIter geometry_offsets_begin,
std::distance(geometry_offsets_begin, geometry_offsets_end)));
}

template <typename OffsetIter>
auto make_element_count_iterator_from_offset(OffsetIter offset_begin)
{
auto zipped = thrust::make_zip_iterator(offset_begin, thrust::next(offset_begin));
return thrust::make_transform_iterator(zipped, detail::offset_pair_to_count_functor{});
}

/**
* @} // end of doxygen group
*/
Expand Down
Loading