CUDPP 1.1
typeToVector< T, N > Struct Template Reference

Utility template struct for generating small vector types from scalar types. More...

#include <cudpp_util.h>

List of all members.


Detailed Description

template<typename T, int N>
struct typeToVector< T, N >

Utility template struct for generating small vector types from scalar types.

Given a base scalar type (int, float, etc.) and a vector length (1 through 4) as template parameters, this struct defines a vector type (float3, int4, etc.) of the specified length and base type. For example:

 template <class T>
 __device__ void myKernel(T *data)
 {
     typeToVector<T,4>::Result myVec4;             // create a vec4 of type T
     myVec4 = (typeToVector<T,4>::Result*)data[0]; // load first element of data as a vec4
 }

This functionality is implemented using template specialization. Currently specializations for int, float, and unsigned int vectors of lengths 2-4 are defined. Note that this results in types being generated at compile time -- there is no runtime cost. typeToVector is used by the optimized scan __device__ functions in scan_cta.cu.


The documentation for this struct was generated from the following file:
 All Classes Files Functions Variables Enumerations Enumerator Defines