Search code examples
cudathrust

What is the difference between thrust::host_vector and std::vector?


Both allocate memory on the host and I can copy contents to device_vector and back using iterators. Why was host_vector necessary to include in the API? Does it have something to do with pinned memory?


Solution

  • No, it doesn't implement pinned memory.

    I suspect it exists to implement a few overrides, such as assignment from a device_vector.

    Also, unlike, the std::vector implementation in MSVC, Thrust's host_vector doesn't check iterator validity which leads to much faster performance on debug builds (by default).