pub unsafe extern "C" fn cuMemAllocPitch_v2(
dptr: *mut CUdeviceptr,
pPitch: *mut usize,
WidthInBytes: usize,
Height: usize,
ElementSizeBytes: c_uint,
) -> CUresult
Expand description
\brief Allocates pitched device memory
Allocates at least \p WidthInBytes * \p Height bytes of linear memory on the device and returns in \p dptr 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. \p ElementSizeBytes specifies the size of the largest reads and writes that will be performed on the memory range. \p ElementSizeBytes may be 4, 8 or 16 (since coalesced memory transactions are not possible on other data sizes). If \p ElementSizeBytes is smaller than the actual read/write size of a kernel, the kernel will run correctly, but possibly at reduced speed. The pitch returned in \p pPitch by ::cuMemAllocPitch() is the width in bytes of the allocation. The intended usage of 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 \b T, the address is computed as: \code T pElement = (T)((char*)BaseAddress + Row * Pitch) + Column; \endcode
The pitch returned by ::cuMemAllocPitch() is guaranteed to work with ::cuMemcpy2D() under all circumstances. For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations using ::cuMemAllocPitch(). Due to 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).
The byte alignment of the pitch returned by ::cuMemAllocPitch() is guaranteed to match or exceed the alignment requirement for texture binding with ::cuTexRefSetAddress2D().
\param dptr - Returned device pointer \param pPitch - Returned pitch of allocation in bytes \param WidthInBytes - Requested allocation width in bytes \param Height - Requested allocation height in rows \param ElementSizeBytes - Size of largest reads/writes for range
\return ::CUDA_SUCCESS, ::CUDA_ERROR_DEINITIALIZED, ::CUDA_ERROR_NOT_INITIALIZED, ::CUDA_ERROR_INVALID_CONTEXT, ::CUDA_ERROR_INVALID_VALUE, ::CUDA_ERROR_OUT_OF_MEMORY \notefnerr
\sa ::cuArray3DCreate, ::cuArray3DGetDescriptor, ::cuArrayCreate, ::cuArrayDestroy, ::cuArrayGetDescriptor, ::cuMemAlloc, ::cuMemAllocHost, ::cuMemcpy2D, ::cuMemcpy2DAsync, ::cuMemcpy2DUnaligned, ::cuMemcpy3D, ::cuMemcpy3DAsync, ::cuMemcpyAtoA, ::cuMemcpyAtoD, ::cuMemcpyAtoH, ::cuMemcpyAtoHAsync, ::cuMemcpyDtoA, ::cuMemcpyDtoD, ::cuMemcpyDtoDAsync, ::cuMemcpyDtoH, ::cuMemcpyDtoHAsync, ::cuMemcpyHtoA, ::cuMemcpyHtoAAsync, ::cuMemcpyHtoD, ::cuMemcpyHtoDAsync, ::cuMemFree, ::cuMemFreeHost, ::cuMemGetAddressRange, ::cuMemGetInfo, ::cuMemHostAlloc, ::cuMemHostGetDevicePointer, ::cuMemsetD2D8, ::cuMemsetD2D16, ::cuMemsetD2D32, ::cuMemsetD8, ::cuMemsetD16, ::cuMemsetD32, ::cudaMallocPitch