thrust::device_malloc
Defined in thrust/device_malloc.h
- 
inline thrust::device_ptr<void> thrust::device_malloc(const std::size_t n)
- This version of - device_mallocallocates sequential device storage for bytes.- The following code snippet demonstrates how to use - device_mallocto allocate a range of device memory.- #include <thrust/device_malloc.h> #include <thrust/device_free.h> ... // allocate some memory with device_malloc const int N = 100; thrust::device_ptr<void> void_ptr = thrust::device_malloc(N); // manipulate memory ... // deallocate with device_free thrust::device_free(void_ptr); - This version of - device_mallocallocates sequential device storage for new objects of the given type.- See also - See also - device_free - The following code snippet demonstrates how to use - device_mallocto allocate a range of device memory.- #include <thrust/device_malloc.h> #include <thrust/device_free.h> ... // 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 - See also - device_free - Parameters
- n – The number of bytes to allocate sequentially in device memory. 
- n – The number of objects of type T to allocate sequentially in device memory. 
 
- Returns
- A - device_ptrto the newly allocated memory.
- Returns
- A - device_ptrto the newly allocated memory.