-
Notifications
You must be signed in to change notification settings - Fork 154
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
Adds load balanced kernel for point-point, point-linestring and linestring-linestring #1144
Draft
isVoid
wants to merge
33
commits into
rapidsai:branch-23.08
Choose a base branch
from
isVoid:improvement/load_balanced_distance_kernel
base: branch-23.08
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
ac872e7
[skip ci] initial segment_counter working
isVoid 84f317c
segment iterator works with empty linestrings
isVoid ce28b3c
enable polygon segment count test
isVoid cd2d229
add polygon segment methods
isVoid fcbe105
remove incomplete validations and add implicit assumptions in documen…
isVoid ee3576e
enable multipolygon range tests
isVoid 7a53d05
improve doc of validators
isVoid 2181e96
replace all multilinestring range tests with segment method test
isVoid 5e3a45a
updates multipolygon tests to make use the new segment methods view
isVoid 53e3ce0
remove segment methods from ranges and update all usage to `segment_m…
isVoid 789f7a2
Cleanup: Remove all debug prints
isVoid 2390acc
Cleanup: Remove segment functions in multilinestring_range and dead c…
isVoid 728caa4
remove num_segments
isVoid 5df7ea0
rename segment_methods -> multilinestring_segment
isVoid e030449
Updates segment_range and tests to make sure APIs exposed are all mul…
isVoid 771f340
Refactors `linestring_polygon_distance` and add tests to include empt…
isVoid 81e05bd
Move all segment range only functors to local file
isVoid 9d00b41
Documentation for segment_range
isVoid f6255b8
typo
isVoid 9ec9882
Merge branch 'branch-23.06' into fix/segment_iterator
isVoid 0f151a5
Cleanups & doc improvement
isVoid 57a2327
Merge branch 'fix/segment_iterator' of github.com:isVoid/cuspatial in…
isVoid a45f2c7
[skip ci] initial addition of the load balanced kernel
isVoid e6cd5d8
Merge branch 'fix/segment_iterator' into improvement/load_balanced_di…
isVoid 8475fe8
Move detail iterator factory into detail folder
isVoid c463978
Remove functors.cuh, make iterator factory for it.
isVoid b442f7c
Remove every functors usage
isVoid 8d76d0a
Impelement load balanced linestring distance
isVoid 242987d
Merge branch 'branch-23.06' into improvement/load_balanced_distance_k…
isVoid 64b638f
Merge branch 'branch-23.06' of https://github.com/rapidsai/cuspatial …
isVoid 3621efd
optimize load_balanced_kernel
isVoid 4633224
minor updates to balanced kernel
isVoid b8099d7
Merge branch 'improvement/load_balanced_distance_kernel' of github.co…
isVoid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,11 @@ | |
#pragma once | ||
|
||
#include <cuspatial/detail/algorithm/linestring_distance.cuh> | ||
#include <cuspatial/detail/distance/distance_utils.cuh> | ||
#include <cuspatial/error.hpp> | ||
#include <cuspatial/geometry/vec_2d.hpp> | ||
#include <cuspatial/traits.hpp> | ||
#include <cuspatial/range/range.cuh> | ||
|
||
#include <rmm/cuda_stream_view.hpp> | ||
#include <rmm/exec_policy.hpp> | ||
|
@@ -33,8 +35,8 @@ | |
namespace cuspatial { | ||
|
||
template <class MultiLinestringRange1, class MultiLinestringRange2, class OutputIt> | ||
OutputIt pairwise_linestring_distance(MultiLinestringRange1 multilinestrings1, | ||
MultiLinestringRange2 multilinestrings2, | ||
OutputIt pairwise_linestring_distance(MultiLinestringRange1 lhs, | ||
MultiLinestringRange2 rhs, | ||
OutputIt distances_first, | ||
rmm::cuda_stream_view stream) | ||
{ | ||
|
@@ -48,25 +50,43 @@ OutputIt pairwise_linestring_distance(MultiLinestringRange1 multilinestrings1, | |
typename MultiLinestringRange2::point_t>(), | ||
"All input types must be cuspatial::vec_2d with the same value type"); | ||
|
||
CUSPATIAL_EXPECTS(multilinestrings1.size() == multilinestrings2.size(), | ||
"Inputs must have the same number of rows."); | ||
CUSPATIAL_EXPECTS(lhs.size() == rhs.size(), "Inputs must have the same number of rows."); | ||
|
||
if (multilinestrings1.size() == 0) return distances_first; | ||
if (lhs.size() == 0) return distances_first; | ||
|
||
// Make views to the segments in the multilinestring | ||
auto lhs_segments = lhs._segments(stream); | ||
auto lhs_segments_range = lhs_segments.view(); | ||
|
||
// Make views to the segments in the multilinestring | ||
auto rhs_segments = rhs._segments(stream); | ||
auto rhs_segments_range = rhs_segments.view(); | ||
|
||
auto thread_bounds = | ||
detail::compute_segment_thread_bounds(lhs_segments_range.multigeometry_count_begin(), | ||
lhs_segments_range.multigeometry_count_end(), | ||
rhs_segments_range.multigeometry_count_begin(), | ||
stream); | ||
// Initialize the output range | ||
thrust::fill(rmm::exec_policy(stream), | ||
distances_first, | ||
distances_first + multilinestrings1.size(), | ||
distances_first + lhs.size(), | ||
std::numeric_limits<T>::max()); | ||
|
||
std::size_t constexpr threads_per_block = 256; | ||
std::size_t const num_blocks = | ||
(multilinestrings1.num_points() + threads_per_block - 1) / threads_per_block; | ||
std::size_t num_threads = 1e8; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than hard coding, this may be a job for the occupancy API... |
||
std::size_t const num_blocks = (num_threads + threads_per_block - 1) / threads_per_block; | ||
|
||
detail::linestring_distance<<<num_blocks, threads_per_block, 0, stream.value()>>>( | ||
multilinestrings1, multilinestrings2, thrust::nullopt, distances_first); | ||
detail::linestring_distance_load_balanced<T, threads_per_block> | ||
<<<num_blocks, threads_per_block, 0, stream.value()>>>( | ||
lhs_segments_range, | ||
rhs_segments_range, | ||
range(thread_bounds.begin(), thread_bounds.end()), | ||
thrust::nullopt, | ||
distances_first); | ||
|
||
CUSPATIAL_CUDA_TRY(cudaGetLastError()); | ||
return distances_first + multilinestrings1.size(); | ||
return distances_first + lhs.size(); | ||
} | ||
|
||
} // namespace cuspatial |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any advantage to this over
if (threadIdx.x == 0)
? What code does this produce? It's impossible for threadIdx.x == 0 to have exited before any other threads in its block in this code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot think of any advantage comparing to
threadIdx.x == 0
. I originally had hopped writing modularized kernel with cg but but later regressed. This is probably a remnant from prototyping.