thrust

◆ device_malloc()

device_ptr< T > thrust::device_malloc ( const std::size_t  n)
inline

This version of device_malloc allocates sequential device storage for bytes.

Parameters
nThe number of bytes to allocate sequentially in device memory.
Returns
A device_ptr to the newly allocated memory.

The following code snippet demonstrates how to use device_malloc to allocate a range of device memory.

...
// allocate some memory with device_malloc
const int N = 100;
// manipulate memory
...
// deallocate with device_free
thrust::device_free(void_ptr);
See also
device_ptr
device_free

This version of device_malloc allocates sequential device storage for new objects of the given type.

Parameters
nThe number of objects of type T to allocate sequentially in device memory.
Returns
A device_ptr to the newly allocated memory.

The following code snippet demonstrates how to use device_malloc to allocate a range of device memory.

...
// allocate some integers with device_malloc
const int N = 100;
thrust::device_ptr<int> int_array = thrust::device_malloc<int>(N);
// manipulate integers
...
// deallocate with device_free
thrust::device_free(int_array);
See also
device_ptr
device_free