cuspatial
cuspatial copied to clipboard
[BUG] New header-only tests should compare with host vectors
I noticed the new tests are comparing device vectors: https://github.com/rapidsai/cuspatial/blob/8dd2d9307259b741a7fcac3378606c2c7e69dde5/cpp/tests/experimental/spatial/hausdorff_test.cu#L50 https://github.com/rapidsai/cuspatial/blob/8dd2d9307259b741a7fcac3378606c2c7e69dde5/cpp/tests/experimental/spatial/haversine_test.cu#L67
These should probably compare host data since the device_vector operator[]
does a DtoH copy per element.
Actually I don't think it's an issue. Gtests' EXPECT_EQ
resorts to operator==
between two arguments:
https://github.com/google/googletest/blob/bf66935e07825318ae519675d73d0f3e313b3ec6/googletest/include/gtest/gtest.h#L1353-L1363
For device_vector
, if ==
are called on vectors from different devices, they always get block copied to host first before comparing.
https://github.com/NVIDIA/thrust/blob/39368d74ce125f617ce723d4b110a8844c686b43/thrust/detail/vector_base.inl#L1229-L1249
Wow, I didn't know that. We are kind of relying on pretty deeply hidden implementation details of Thrust here, which makes me a tiny bit nervous.
I'm open to be more explicit about copying to host before comparing. Considering the behavior above isn't documented on thrust doc. A suggestion is that make a CUSPATIAL_EXPECT_EQ
to wrap the d2h copy.
This issue has been labeled inactive-30d
due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d
if there is no activity in the next 60 days.
#669 made it so that this isn't an issue as long as we use expect_vector_equivalent
.