Function rcudnn_sys::cudaMallocPitch[][src]

pub unsafe extern "C" fn cudaMallocPitch(
    devPtr: *mut *mut c_void,
    pitch: *mut usize,
    width: usize,
    height: usize
) -> cudaError_t
Expand description

\brief Allocates pitched memory on the device

Allocates at least \p width (in bytes) * \p height bytes of linear memory on the device and returns in \p devPtr a pointer to the allocated memory. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The pitch returned in \p pitch by ::cudaMallocPitch() is the width in bytes of the allocation. The intended usage of \p pitch is as a separate parameter of the allocation, used to compute addresses within the 2D array. Given the row and column of an array element of type \p T, the address is computed as: \code T pElement = (T)((char*)BaseAddress + Row * pitch) + Column; \endcode

For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations using ::cudaMallocPitch(). Due to pitch alignment restrictions in the hardware, this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or CUDA arrays).

\param devPtr - Pointer to allocated pitched device memory \param pitch - Pitch for allocation \param width - Requested pitched allocation width (in bytes) \param height - Requested pitched allocation height

\return ::cudaSuccess, ::cudaErrorInvalidValue, ::cudaErrorMemoryAllocation \notefnerr \note_init_rt \note_callback

\sa ::cudaMalloc, ::cudaFree, ::cudaMallocArray, ::cudaFreeArray, \ref ::cudaMallocHost(void**, size_t) “cudaMallocHost (C API)”, ::cudaFreeHost, ::cudaMalloc3D, ::cudaMalloc3DArray, ::cudaHostAlloc, ::cuMemAllocPitch