-
Notifications
You must be signed in to change notification settings - Fork 157
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
Header-only Refactor of point_in_polygon
#587
Changes from 4 commits
6cb6180
7133e34
4efbe67
a6209e1
c8afc71
f7ab8c2
aef327d
acef20e
b3d5b7a
e1d0e30
0432721
27fb73c
794f6ad
d4fd3dc
56fdbd8
fe9c220
f192862
ae44ef3
0c5298c
61366d0
399e80d
041d722
1db2574
c5eaa2d
f015f28
047551d
e3a2134
faaf9a3
8a7b34b
841b69d
901a4d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,137 @@ TYPED_TEST(PointInPolygonTest, Empty) | |
|
||
expect_columns_equal(expected, actual->view(), verbosity); | ||
} | ||
|
||
template <typename T> | ||
struct PointInPolygonUnsupportedTypesTest : public BaseFixture { | ||
}; | ||
|
||
using UnsupportedTestTypes = RemoveIf<ContainedIn<TestTypes>, NumericTypes>; | ||
TYPED_TEST_CASE(PointInPolygonUnsupportedTypesTest, UnsupportedTestTypes); | ||
|
||
TYPED_TEST(PointInPolygonUnsupportedTypesTest, UnsupportedPointType) | ||
{ | ||
using T = TypeParam; | ||
|
||
auto test_point_xs = wrapper<T>({0.0, 0.0}); | ||
auto test_point_ys = wrapper<T>({0.0}); | ||
auto poly_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_ring_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0, -1.0}); | ||
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::point_in_polygon( | ||
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys), | ||
cuspatial::logic_error); | ||
} | ||
|
||
template <typename T> | ||
struct PointInPolygonUnsupportedChronoTypesTest : public BaseFixture { | ||
}; | ||
|
||
TYPED_TEST_CASE(PointInPolygonUnsupportedChronoTypesTest, ChronoTypes); | ||
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. I can't remember why we have unsupported types tests specifically for Chrono types but not for other non-numerical types (e.g. nested types). Is it necessary to test these at all? Every type we test increases compile time, so I wonder if we can just test one unsupported type as a proxy for all the others? Don't necessarily need to decide this in the present PR! |
||
|
||
TYPED_TEST(PointInPolygonUnsupportedChronoTypesTest, UnsupportedPointChronoType) | ||
{ | ||
using T = TypeParam; | ||
using R = typename T::rep; | ||
|
||
auto test_point_xs = wrapper<T, R>({R{0}, R{0}}); | ||
auto test_point_ys = wrapper<T, R>({R{0}}); | ||
auto poly_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_ring_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_point_xs = wrapper<T, R>({R{0}, R{1}, R{0}, R{-1}}); | ||
auto poly_point_ys = wrapper<T, R>({R{1}, R{0}, R{-1}, R{0}}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::point_in_polygon( | ||
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys), | ||
cuspatial::logic_error); | ||
} | ||
|
||
struct PointInPolygonErrorTest : public BaseFixture { | ||
}; | ||
|
||
TEST_F(PointInPolygonErrorTest, MismatchTestPointXYLength) | ||
{ | ||
using T = double; | ||
|
||
auto test_point_xs = wrapper<T>({0.0, 0.0}); | ||
auto test_point_ys = wrapper<T>({0.0}); | ||
auto poly_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_ring_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0, -1.0}); | ||
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::point_in_polygon( | ||
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys), | ||
cuspatial::logic_error); | ||
} | ||
|
||
TEST_F(PointInPolygonErrorTest, MismatchTestPointType) | ||
{ | ||
using T = double; | ||
|
||
auto test_point_xs = wrapper<T>({0.0, 0.0}); | ||
auto test_point_ys = wrapper<float>({0.0, 0.0}); | ||
auto poly_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_ring_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0}); | ||
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::point_in_polygon( | ||
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys), | ||
cuspatial::logic_error); | ||
} | ||
|
||
TEST_F(PointInPolygonErrorTest, MismatchPolyPointXYLength) | ||
{ | ||
using T = double; | ||
|
||
auto test_point_xs = wrapper<T>({0.0, 0.0}); | ||
auto test_point_ys = wrapper<T>({0.0, 0.0}); | ||
auto poly_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_ring_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0}); | ||
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::point_in_polygon( | ||
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys), | ||
cuspatial::logic_error); | ||
} | ||
|
||
TEST_F(PointInPolygonErrorTest, MismatchPolyPointType) | ||
{ | ||
using T = double; | ||
|
||
auto test_point_xs = wrapper<T>({0.0, 0.0}); | ||
auto test_point_ys = wrapper<T>({0.0, 0.0}); | ||
auto poly_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_ring_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0}); | ||
auto poly_point_ys = wrapper<float>({1.0, 0.0, -1.0, 0.0}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::point_in_polygon( | ||
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys), | ||
cuspatial::logic_error); | ||
} | ||
|
||
TEST_F(PointInPolygonErrorTest, MismatchPointTypes) | ||
{ | ||
auto test_point_xs = wrapper<float>({0.0, 0.0}); | ||
auto test_point_ys = wrapper<float>({0.0, 0.0}); | ||
auto poly_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_ring_offsets = wrapper<cudf::size_type>({0}); | ||
auto poly_point_xs = wrapper<double>({0.0, 1.0, 0.0, -1.0}); | ||
auto poly_point_ys = wrapper<double>({1.0, 0.0, -1.0, 0.0}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::point_in_polygon( | ||
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys), | ||
cuspatial::logic_error); | ||
} |
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.
It would be nice to know how much of the speedup came just from eliminating the division vs. all the other changes. Because there is potential for more thread divergence in the new 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.
I will include the comparison data of division in the PR description. I will also include a comment stating the assumption we have here is that the cycles it costs on division is greater than that of warp syncs. It's apparently dependent on many factors such as whether user compiles the code with
fast-math
, or how fast the hardware synchronizes divergence.That said, I don't think it's appropriate to mention benchmark results in the comments as it's hardware dependent and will get stale very quickly.