Added pinned_vector as a std::vector with a pinned allocator
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_vectornow requires an additional argumentcontext, and returns a pinned vector. Therefore,make_vectoris now usable in places where throughput matters. - A new function
copy_vectorhas been created. It copies the contents of anstd::vectoronto an argument. Note that forcopy_vectorto not degrade performance, it should be used with apinned_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