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

Why does thrust use is_pod to implement has_trivial_destructor? #722

Open
trivialfis opened this issue Dec 2, 2019 · 1 comment
Open
Labels
thrust For all items related to Thrust.

Comments

@trivialfis
Copy link

trivialfis commented Dec 2, 2019

Hi all,

In https://github.com/thrust/thrust/blob/324243f6bb70687aeaeb2419193a335648c5869d/thrust/detail/type_traits.h#L177

The trait has_trivial_destructor is implemented as is_pod. But in c++11 there's dedicated function for it called std::is_trivially_destructible: https://en.cppreference.com/w/cpp/types/is_destructible . Being POD is a stricter requirement than being trivially destructible.

In my case I expect thrust::detail::destroy_range as a no-op when input type is trivially destructible but with a user defined constructor. This way I can have a library (XGBoost) compiled with CUDA and uses thrust::device_vector, but run on CPU without error as long as I don't call any cuda function in the code path. But with thrust shipped with CUDA 10.1 I got the following error in device_vector's destructor:

terminate called after throwing an instance of 'thrust::system::system_error'
  what():  for_each: failed to synchronize: cudaErrorNoDevice: no CUDA-capable device is detected
Aborted (core dumped)

It maybe worth mentioning that data size is 0.

@jrhemstad jrhemstad added the thrust For all items related to Thrust. label Feb 22, 2023
@jarmak-nv jarmak-nv transferred this issue from NVIDIA/thrust Nov 8, 2023
elstehle pushed a commit to elstehle/cccl that referenced this issue Nov 16, 2023
@bernhardmgruber
Copy link
Contributor

@miscco This was addressed in #1721 as a drive-by fix, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
thrust For all items related to Thrust.
Projects
Status: No status
Development

No branches or pull requests

3 participants