Skip to content

Added pinned_vector as a std::vector with a pinned allocator

Daniel Hugo Campora Perez requested to merge dcampora_pinned_vector into master

This MR adds a pinned_allocator that can be used with STL types. It also adds the type pinned_vector that uses the pinned_allocator to allocate its memory. In addition:

  • The function make_vector now requires an additional argument context, and returns a pinned vector. Therefore, make_vector is now usable in places where throughput matters.
  • A new function copy_vector has been created. It copies the contents of an std::vector onto an argument. Note that for copy_vector to not degrade performance, it should be used with a pinned_vector.

When transmitting data between host and device, if the data is pinned on the host the transmission can happen simultaneously to other data processing / other data transmissions on the GPU. However, if the data is not pinned, the entire GPU execution will halt until the processing is done. HOST_ datatypes are pinned by default, but having a pinned std::vector type is useful to eg. make a temporary in an algorithm where data can be transferred with no performance penalty.

Edited by Daniel Hugo Campora Perez

Merge request reports