cuspatial icon indicating copy to clipboard operation
cuspatial copied to clipboard

[BUG] New header-only tests should compare with host vectors

Open trxcllnt opened this issue 2 years ago • 5 comments

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.

trxcllnt avatar Aug 11 '22 00:08 trxcllnt

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

isVoid avatar Aug 15 '22 19:08 isVoid

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.

harrism avatar Aug 15 '22 21:08 harrism

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.

isVoid avatar Aug 15 '22 21:08 isVoid

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.

github-actions[bot] avatar Sep 23 '22 12:09 github-actions[bot]

#669 made it so that this isn't an issue as long as we use expect_vector_equivalent.

harrism avatar Sep 28 '22 11:09 harrism