Allocates and returns a pointer to device memory. More...

template<typename T >
static T * alloc (size_t elements)
 Allocate device memory array of elements. More...
 
static void * alloc (size_t elements, dtype type)
 Allocate device memory array of elements of type. More...
 

Detailed Description

Allocates and returns a pointer to device memory.

This function will allocate memory on the device and return a pointer to the memory location. This data is not managed by the array and therefor needs to be deallocated using the array::free() function. The pointer can be used to create an array object using one of the Constructors.

Function Documentation

static T* alloc ( size_t  elements)
static

Allocate device memory array of elements.

float *dptr = array::alloc<float>(10); // actually 4*10=40 bytes
array X = array(10, dptr, afDevice);
print(X); // print (uninitialized) values
See Also
free() pinned()
static void* alloc ( size_t  elements,
dtype  type 
)
static

Allocate device memory array of elements of type.

float *dptr = array::alloc(10, f32); // actually 4*10=40 bytes
array X = array(10, dptr, afDevice);
print(X); // print (uninitialized) values