All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
Vectorized String Loading

Detailed Description

The functions in this module define a vector loading API for strings: strings, are usually made up of tiny characters, often a byte each, or just a few bits. Loading them byte by byte stresses the memory bus, and often results in bad memory utilization. Loading them in bigger chunks, when possible (e.g. when the string is properly aligned), can be very favourable. This API defines:
// the size of the vector which can be used to load many symbols at once
// the range of the string which is amenable to vectorized loading
uint2 vectorized_string_range(const string_type& string);
// a function to retrieve a vector
void vectorized_string_load(const string_type& string, const uint32 i, value_type* v);
The following example shows how the API could be used:
const char* string = "this is a long enough ASCII string - let's see if this stuff works...";
// determine the vectorization width
printf("w = %u\n", VECW);
// determine the vectorized string range
const uint2 vec_range = vectorized_string_range( string );
printf("range(%u,%u)\n", vec_range.x, vec_range.y);
// loop through the scalar range
for (uint32 i = 0; i < vec_range.x; ++i)
printf("%c", string[i]);
// loop through the vectorized range
for (uint32 i = vec_range.x; i < vec_range.y; i += VECW)
char v[VECW];
// load a vector
vectorized_string_load( string, i, v );
for (uint32 j = 0; j < VECW; ++j)
printf("%c", v[j]);
// loop through the scalar range
for (uint32 i = vec_range.y; i < length( string ); ++i)
printf("%c", string[i]);


struct  nvbio::vectorized_string< string_type >
struct  nvbio::vectorized_string< const char * >
struct  nvbio::vectorized_string< vector_view< const T *, IndexType > >
struct  nvbio::vectorized_string< vector_view< PackedStream< InputStream, Symbol, SYMBOL_SIZE_T, BIG_ENDIAN_T, IndexType > > >


template<typename string_type >
nvbio::vectorized_string_range (const string_type &string)
template<typename string_type >
nvbio::vectorized_string_load (const string_type &string, const uint32 i, typename string_traits< string_type >::value_type *vector)

Function Documentation

template<typename string_type >
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE void nvbio::vectorized_string_load ( const string_type &  string,
const uint32  i,
typename string_traits< string_type >::value_type *  vector 

load a vector using the maximum vector width

Definition at line 172 of file vectorized_string.h.

template<typename string_type >
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE uint2 nvbio::vectorized_string_range ( const string_type &  string)

determine the vectorized range of a string using the maximum vector width

Definition at line 163 of file vectorized_string.h.