NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vector Arrays

This module implements the notion of vector array, i.e. an array of dynamically-allocated vectors. The ideas is that one can allocate some shared arena, and then carve N vectors from the arena in parallel. This data-structure provides methods to perform the carving and remember the binding between the i-th array and its slot in the arena.

At a Glance

There's two flavors of this class, one for the host and one for the device:

The DeviceVectorArray is a container meant to be used from the host; the corresponding view:

can be obtained with a call to the plain_view() function.

Example

__global__ void my_alloc_kernel(VectorArrayView<uint32> vector_array)
{
const uint32 idx = threadIdx.x + blockIdx.x * blockDim.x;
const uint32 size = threadIdx.x+1;
// alloc this thread's vector
vector_array.alloc(
idx, // vector to allocate
size ); // vector size
}
__global__ void my_other_kernel(VectorArrayView<uint32> vector_array)
{
const uint32 idx = threadIdx.x + blockIdx.x * blockDim.x;
// and do something with it
do_something( vector_array[i] );
}
DeviceVectorArray<uint32> vector_array( 32, 32*32 );
my_alloc_kernel<<<1,32>>>( plain_view( vector_array ) );
my_other_kernel<<<1,32>>>( plain_view( vector_array ) );

Technical Overview

See the Vector Arrays module documentation.