Cuda Reference Manual
Cuda Reference Manual
Reference Manual
Version 2.3
July 2009
Contents
1 Module Index 1
1.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3 Module Documentation 5
3.1 CUDA Runtime API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Thread Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.2.1 cudaThreadExit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.2.2 cudaThreadSynchronize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.2.1 cudaGetErrorString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3.2.2 cudaGetLastError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.4 Device Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4.2.1 cudaChooseDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4.2.2 cudaGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.2.3 cudaGetDeviceCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.2.4 cudaGetDeviceProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.4.2.5 cudaSetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4.2.6 cudaSetDeviceFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4.2.7 cudaSetValidDevices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
ii CONTENTS
3.8.2.9 cudaMalloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.8.2.10 cudaMalloc3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.8.2.11 cudaMalloc3DArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.8.2.12 cudaMallocArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.8.2.13 cudaMallocHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8.2.14 cudaMallocPitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.8.2.15 cudaMemcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.8.2.16 cudaMemcpy2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.8.2.17 cudaMemcpy2DArrayToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.8.2.18 cudaMemcpy2DAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.8.2.19 cudaMemcpy2DFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.8.2.20 cudaMemcpy2DFromArrayAsync . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.8.2.21 cudaMemcpy2DToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.8.2.22 cudaMemcpy2DToArrayAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.8.2.23 cudaMemcpy3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.8.2.24 cudaMemcpy3DAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.8.2.25 cudaMemcpyArrayToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.8.2.26 cudaMemcpyAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.8.2.27 cudaMemcpyFromArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.8.2.28 cudaMemcpyFromArrayAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.8.2.29 cudaMemcpyFromSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.8.2.30 cudaMemcpyFromSymbolAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.8.2.31 cudaMemcpyToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.8.2.32 cudaMemcpyToArrayAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.8.2.33 cudaMemcpyToSymbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.8.2.34 cudaMemcpyToSymbolAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.8.2.35 cudaMemset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.8.2.36 cudaMemset2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.8.2.37 cudaMemset3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.9 OpenGL Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.9.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.9.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.9.2.1 cudaGLMapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.9.2.2 cudaGLMapBufferObjectAsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.9.2.3 cudaGLRegisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.9.2.4 cudaGLSetBufferObjectMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.9.2.5 cudaGLSetGLDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.9.2.6 cudaGLUnmapBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.9.2.7 cudaGLUnmapBufferObjectAsync . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.9.2.8 cudaGLUnregisterBufferObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.9.2.9 cudaWGLGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.10 Direct3D 9 Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.10.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.10.2 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.10.2.1 cudaD3D9MapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.10.2.2 cudaD3D9RegisterFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.10.3 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.10.3.1 cudaD3D9GetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.10.3.2 cudaD3D9GetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.10.3.3 cudaD3D9MapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.10.3.4 cudaD3D9RegisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.10.3.5 cudaD3D9ResourceGetMappedArray . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.10.3.6 cudaD3D9ResourceGetMappedPitch . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.10.3.7 cudaD3D9ResourceGetMappedPointer . . . . . . . . . . . . . . . . . . . . . . . . 63
3.10.3.8 cudaD3D9ResourceGetMappedSize . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.10.3.9 cudaD3D9ResourceGetSurfaceDimensions . . . . . . . . . . . . . . . . . . . . . . 64
3.10.3.10 cudaD3D9ResourceSetMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.10.3.11 cudaD3D9SetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.10.3.12 cudaD3D9UnmapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.10.3.13 cudaD3D9UnregisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.11 Direct3D 10 Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.11.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.11.2 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.11.2.1 cudaD3D10MapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.11.2.2 cudaD3D10RegisterFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.11.3 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.11.3.1 cudaD3D10GetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.11.3.2 cudaD3D10MapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.11.3.3 cudaD3D10RegisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.11.3.4 cudaD3D10ResourceGetMappedArray . . . . . . . . . . . . . . . . . . . . . . . . 72
3.11.3.5 cudaD3D10ResourceGetMappedPitch . . . . . . . . . . . . . . . . . . . . . . . . 72
3.11.3.6 cudaD3D10ResourceGetMappedPointer . . . . . . . . . . . . . . . . . . . . . . . 73
3.11.3.7 cudaD3D10ResourceGetMappedSize . . . . . . . . . . . . . . . . . . . . . . . . . 74
3.11.3.8 cudaD3D10ResourceGetSurfaceDimensions . . . . . . . . . . . . . . . . . . . . . 74
3.11.3.9 cudaD3D10ResourceSetMapFlags . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.11.3.10 cudaD3D10SetDirect3DDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.11.3.11 cudaD3D10UnmapResources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.11.3.12 cudaD3D10UnregisterResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.12 Texture Reference Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.12.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.12.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.12.2.1 cudaBindTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.12.2.2 cudaBindTexture2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.12.2.3 cudaBindTextureToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.12.2.4 cudaCreateChannelDesc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.12.2.5 cudaGetChannelDesc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.12.2.6 cudaGetTextureAlignmentOffset . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.12.2.7 cudaGetTextureReference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.12.2.8 cudaUnbindTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.13 Version Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.13.1 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.13.1.1 cudaDriverGetVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.13.1.2 cudaRuntimeGetVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.14 C++ API Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3.14.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.14.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.14.2.1 cudaBindTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.14.2.2 cudaBindTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.14.2.3 cudaBindTexture2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.14.2.4 cudaBindTextureToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.14.2.5 cudaBindTextureToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.14.2.6 cudaCreateChannelDesc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
3.14.2.7 cudaFuncGetAttributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
3.14.2.8 cudaGetSymbolAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.14.2.9 cudaGetSymbolSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.14.2.10 cudaGetTextureAlignmentOffset . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.14.2.11 cudaLaunch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.14.2.12 cudaSetupArgument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.14.2.13 cudaUnbindTexture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
3.15 Data types used by CUDA Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.15.1 Typedef Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.15.1.1 cudaError_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.15.1.2 cudaEvent_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.15.1.3 cudaStream_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.15.2 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.15.2.1 cudaChannelFormatKind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.15.2.2 cudaComputeMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
3.15.2.3 cudaError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
3.15.2.4 cudaMemcpyKind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
3.16 CUDA Driver API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
3.16.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
3.17 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.17.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.17.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.17.2.1 cuInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.18 Device Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.18.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.18.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.18.2.1 cuDeviceComputeCapability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.18.2.2 cuDeviceGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.18.2.3 cuDeviceGetAttribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.18.2.4 cuDeviceGetCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.18.2.5 cuDeviceGetName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.18.2.6 cuDeviceGetProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.18.2.7 cuDeviceTotalMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
3.19 Version Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.19.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.19.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.19.2.1 cuDriverGetVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.20 Context Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.20.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.20.2 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.20.2.1 cuCtxAttach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.20.2.2 cuCtxCreate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.20.2.3 cuCtxDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.20.2.4 cuCtxDetach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.20.2.5 cuCtxGetDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
3.20.2.6 cuCtxPopCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Module Index
1.1 Modules
Here is a list of all modules:
CUDA Runtime API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Thread Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Device Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Stream Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Event Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Execution Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
OpenGL Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Direct3D 9 Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Direct3D 10 Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Texture Reference Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Version Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
C++ API Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Data types used by CUDA Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
CUDA Driver API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Device Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Version Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Context Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Module Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Stream Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Event Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Execution Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Texture Reference Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
OpenGL Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Direct3D 9 Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Direct3D 10 Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Data types used by CUDA driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
2 Module Index
Module Documentation
Modules
• Thread Management
• Error Handling
• Device Management
• Stream Management
• Event Management
• Execution Control
• Memory Management
• OpenGL Interoperability
• Direct3D 9 Interoperability
• Direct3D 10 Interoperability
• Texture Reference Management
• Version Management
• C++ API Routines
C++-style interface built on top of CUDA runtime API.
Functions
• cudaError_t cudaThreadExit (void)
Exit and clean up from CUDA launches.
This section describes the thread management functions of the CUDA runtime application programming interface.
Explicitly cleans up all runtime-related resources associated with the calling host thread. Any subsequent API call
reinitializes the runtime. cudaThreadExit() is implicitly called on host thread exit.
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaThreadSynchronize
Blocks until the device has completed all preceding requested tasks. cudaThreadSynchronize() returns an error if one
of the preceding tasks has failed.
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaThreadExit
Functions
• const char ∗ cudaGetErrorString (cudaError_t error)
Returns the message string from an error code.
This section describes the error handling functions of the CUDA runtime application programming interface.
Parameters:
error - Error code to convert to string
Returns:
char∗ pointer to a NULL-terminated string
See also:
cudaGetLastError, cudaError
Returns the last error that has been produced by any of the runtime calls in the same host thread and resets it to
cudaSuccess.
Returns:
cudaSuccess, cudaErrorMissingConfiguration, cudaErrorMemoryAllocation, cudaErrorInitializationError, cu-
daErrorLaunchFailure, cudaErrorPriorLaunchFailure, cudaErrorLaunchTimeout, cudaErrorLaunchOutOfRe-
sources, cudaErrorInvalidDeviceFunction, cudaErrorInvalidConfiguration, cudaErrorInvalidDevice cudaError-
InvalidValue cudaErrorInvalidPitchValue cudaErrorInvalidSymbol cudaErrorMapBufferObjectFailed cudaEr-
rorUnmapBufferObjectFailed cudaErrorInvalidHostPointer cudaErrorInvalidDevicePointer cudaErrorInvalidTex-
ture cudaErrorInvalidTextureBinding cudaErrorInvalidChannelDescriptor cudaErrorInvalidMemcpyDirection cu-
daErrorAddressOfConstant cudaErrorTextureFetchFailed cudaErrorTextureNotBound cudaErrorSynchroniza-
tionError cudaErrorInvalidFilterSetting cudaErrorInvalidNormSetting cudaErrorMixedDeviceExecution cudaEr-
rorCudartUnloading cudaErrorUnknown cudaErrorNotYetImplemented cudaErrorMemoryValueTooLarge cu-
daErrorInvalidResourceHandle cudaErrorNotReady cudaErrorInsufficientDriver cudaErrorSetOnActiveProcess
cudaErrorStartupFailure cudaErrorApiFailureBase
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetErrorString, cudaError
Functions
• cudaError_t cudaChooseDevice (int ∗device, const struct cudaDeviceProp ∗prop)
Select compute-device which best matches criteria.
This section describes the device management functions of the CUDA runtime application programming interface.
Returns in ∗device the device which has properties that best match ∗prop.
Parameters:
device - Device with best match
prop - Desired device properties
Returns:
cudaSuccess, cudaErrorInvalidValue
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetDeviceCount, cudaGetDevice, cudaSetDevice, cudaGetDeviceProperties
Returns in ∗device the device on which the active host thread executes the device code.
Parameters:
device - Returns the device on which the active host thread executes the device code.
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetDeviceCount, cudaSetDevice, cudaGetDeviceProperties, cudaChooseDevice
Returns in ∗count the number of devices with compute capability greater or equal to 1.0 that are available for
execution. If there is no such device, cudaGetDeviceCount() returns 1 and device 0 only supports device
emulation mode. Since this device will be able to emulate all hardware features, this device will report major and
minor compute capability versions of 9999.
Parameters:
count - Returns the number of devices with compute capability greater or equal to 1.0
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetDevice, cudaSetDevice, cudaGetDeviceProperties, cudaChooseDevice
Returns in ∗prop the properties of device dev. The cudaDeviceProp structure is defined as:
struct cudaDeviceProp {
char name[256];
size_t totalGlobalMem;
size_t sharedMemPerBlock;
int regsPerBlock;
int warpSize;
size_t memPitch;
int maxThreadsPerBlock;
int maxThreadsDim[3];
int maxGridSize[3];
size_t totalConstMem;
int major;
int minor;
int clockRate;
size_t textureAlignment;
int deviceOverlap;
int multiProcessorCount;
int kernelExecTimeoutEnabled;
int integrated;
int canMapHostMemory;
int computeMode;
}
where:
• totalGlobalMem is the total amount of global memory available on the device in bytes;
• sharedMemPerBlock is the maximum amount of shared memory available to a thread block in bytes; this
amount is shared by all thread blocks simultaneously resident on a multiprocessor;
• regsPerBlock is the maximum number of 32-bit registers available to a thread block; this number is shared
by all thread blocks simultaneously resident on a multiprocessor;
• memPitch is the maximum pitch in bytes allowed by the memory copy functions that involve memory regions
allocated through cudaMallocPitch();
• totalConstMem is the total amount of constant memory available on the device in bytes;
• major, minor are the major and minor revision numbers defining the device’s compute capability;
• textureAlignment is the alignment requirement; texture base addresses that are aligned to
textureAlignment bytes do not need an offset applied to texture fetches;
• deviceOverlap is 1 if the device can concurrently copy memory between host and device while executing a
kernel, or 0 if not;
• kernelExecTimeoutEnabled is 1 if there is a run time limit for kernels executed on the device, or 0 if
not.
• integrated is 1 if the device is an integrated (motherboard) GPU and 0 if it is a discrete (card) component
• canMapHostMemory is 1 if the device can map host memory into the CUDA address space for use with
cudaHostAlloc()/cudaHostGetDevicePointer(), or 0 if not;
• computeMode is the compute mode that the device is currently in. Available modes are as follows:
– cudaComputeModeDefault: Default mode - Device is not restricted and multiple threads can use cudaSet-
Device() with this device.
– cudaComputeModeExclusive: Compute-exclusive mode - Only one thread will be able to use cudaSetDe-
vice() with this device.
– cudaComputeModeProhibited: Compute-prohibited mode - No threads can use cudaSetDevice() with this
device. Any errors from calling cudaSetDevice() with an exclusive (and occupied) or prohibited device will
only show up after a non-device management runtime function is called. At that time, cudaErrorNoDevice
will be returned.
Parameters:
prop - Properties for the specified device
device - Device number to get properties for
Returns:
cudaSuccess, cudaErrorInvalidDevice
See also:
cudaGetDeviceCount, cudaGetDevice, cudaSetDevice, cudaChooseDevice
Records device as the device on which the active host thread executes the device code. If the host thread has already
initialized the CUDA runtime by calling non-device management runtime functions, this call returns cudaErrorSetOn-
ActiveProcess.
Parameters:
device - Device on which the active host thread should execute the device code.
Returns:
cudaSuccess, cudaErrorInvalidDevice, cudaErrorSetOnActiveProcess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetDeviceCount, cudaGetDevice, cudaGetDeviceProperties, cudaChooseDevice
Records flags as the flags to use when the active host thread executes device code. If the host thread has already
initialized the CUDA runtime by calling non-device management runtime functions, this call returns cudaErrorSetOn-
ActiveProcess.
The two LSBs of the flags parameter can be used to control how the CPU thread interacts with the OS scheduler
when waiting for results from the device.
• cudaDeviceScheduleAuto: The default value if the flags parameter is zero, uses a heuristic based on the
number of active CUDA contexts in the process C and the number of logical processors in the system P. If C >
P, then CUDA will yield to other OS threads when waiting for the device, otherwise CUDA will not yield while
waiting for results and actively spin on the processor.
• cudaDeviceScheduleSpin: Instruct CUDA to actively spin when waiting for results from the device. This can
decrease latency when waiting for the device, but may lower the performance of CPU threads if they are per-
forming work in parallel with the CUDA thread.
• cudaDeviceScheduleYield: Instruct CUDA to yield its thread when waiting for results from the device. This
can increase latency when waiting for the device, but can increase the performance of CPU threads performing
work in parallel with the device.
• cudaDeviceBlockingSync: Instruct CUDA to block the CPU thread on a synchronization primitive when waiting
for the device to finish work.
• cudaDeviceMapHost: This flag must be set in order to allocate pinned host memory that is accessible to the
device. If this flag is not set, cudaHostGetDevicePointer() will always return a failure code.
Parameters:
flags - Parameters for device operation
Returns:
cudaSuccess, cudaErrorInvalidDevice, cudaErrorSetOnActiveProcess
See also:
cudaGetDeviceCount, cudaGetDevice, cudaGetDeviceProperties, cudaSetDevice, cudaSetValidDevices, cuda-
ChooseDevice
Sets a list of devices for CUDA execution in priority order using device_arr. The parameter len specifies the
number of elements in the list. CUDA will try devices from the list sequentially until it finds one that works. If this
function is not called, or if it is called with a len of 0, then CUDA will go back to its default behavior of trying devices
sequentially from a default list containing all of the available CUDA devices in the system. If a specified device ID in
the list does not exist, this function will return cudaErrorInvalidDevice. If len is not 0 and device_arr is NULL
or if len is greater than the number of devices in the system, then cudaErrorInvalidValue is returned.
Parameters:
device_arr - List of devices to try
len - Number of devices in specified list
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevice
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetDeviceCount, cudaSetDevice, cudaGetDeviceProperties, cudaSetDeviceFlags, cudaChooseDevice
Functions
• cudaError_t cudaStreamCreate (cudaStream_t ∗pStream)
Create an asynchronous stream.
This section describes the stream management functions of the CUDA runtime application programming interface.
Parameters:
pStream - Pointer to new stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaStreamQuery, cudaStreamSynchronize, cudaStreamDestroy
Parameters:
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaStreamCreate, cudaStreamQuery, cudaStreamSynchronize
Parameters:
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorNotReady cudaErrorInvalidResourceHandle
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaStreamCreate, cudaStreamSynchronize, cudaStreamDestroy
Parameters:
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaStreamCreate, cudaStreamQuery, cudaStreamDestroy
Functions
• cudaError_t cudaEventCreate (cudaEvent_t ∗event)
Creates an event object.
This section describes the event management functions of the CUDA runtime application programming interface.
Parameters:
event - Newly created event
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorPriorLaunchFailure, cudaErrorInvalidValue, cudaEr-
rorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaEventCreateWithFlags, cudaEventRecord, cudaEventQuery, cudaEventSynchronize, cudaEventDestroy, cu-
daEventElapsedTime
Parameters:
event - Newly created event
flags - Flags for new event
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorPriorLaunchFailure, cudaErrorInvalidValue, cudaEr-
rorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaEventCreate, cudaEventRecord, cudaEventQuery, cudaEventSynchronize, cudaEventDestroy, cudaEventE-
lapsedTime
Parameters:
event - Event to destroy
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorPriorLaunchFailure, cudaErrorInvalidValue
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaEventCreate, cudaEventCreateWithFlags, cudaEventQuery, cudaEventSynchronize, cudaEventRecord, cud-
aEventElapsedTime
Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). If
either event has not been recorded yet, this function returns cudaErrorInvalidValue. If either event has been recorded
with a non-zero stream, the result is undefined.
Parameters:
ms - Time between start and stop in ms
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInitializationError, cudaErrorPriorLaunchFailure, cudaErrorIn-
validResourceHandle
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaEventCreate, cudaEventCreateWithFlags, cudaEventQuery, cudaEventSynchronize, cudaEventDestroy, cu-
daEventRecord
Returns cudaSuccess if the event has actually been recorded, or cudaErrorNotReady if not. If cudaEventRecord() has
not been called on this event, the function returns cudaErrorInvalidValue.
Parameters:
event - Event to query
Returns:
cudaSuccess, cudaErrorNotReady, cudaErrorInitializationError, cudaErrorPriorLaunchFailure, cudaErrorInvalid-
Value cudaErrorInvalidResourceHandle
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaEventCreate, cudaEventCreateWithFlags, cudaEventRecord, cudaEventSynchronize, cudaEventDestroy, cu-
daEventElapsedTime
Records an event. If stream is non-zero, the event is recorded after all preceding operations in the stream have been
completed; otherwise, it is recorded after all preceding operations in the CUDA context have been completed. Since
this operation is asynchronous, cudaEventQuery() and/or cudaEventSynchronize() must be used to determine when
the event has actually been recorded.
If cudaEventRecord() has previously been called and the event has not been recorded yet, this function returns cud-
aErrorInvalidValue.
Parameters:
event - Event to record
stream - Stream in which to record event
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInitializationError, cudaErrorPriorLaunchFailure, cudaErrorIn-
validResourceHandle
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaEventCreate, cudaEventCreateWithFlags, cudaEventQuery, cudaEventSynchronize, cudaEventDestroy, cu-
daEventElapsedTime
Blocks until the event has actually been recorded. If cudaEventRecord() has not been called on this event, the function
returns cudaErrorInvalidValue.
Parameters:
event - Event to wait for
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorPriorLaunchFailure, cudaErrorInvalidValue cudaErrorIn-
validResourceHandle
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaEventCreate, cudaEventCreateWithFlags, cudaEventRecord, cudaEventQuery, cudaEventDestroy, cud-
aEventElapsedTime
Functions
• cudaError_t cudaConfigureCall (dim3 gridDim, dim3 blockDim, size_t sharedMem, cudaStream_t stream)
Configure a device-launch.
This section describes the execution control functions of the CUDA runtime application programming interface.
3.7.2.1 cudaError_t cudaConfigureCall (dim3 gridDim, dim3 blockDim, size_t sharedMem, cudaStream_t
stream)
Specifies the grid and block dimensions for the device call to be executed similar to the execution configuration
syntax. cudaConfigureCall() is stack based. Each call pushes data on top of an execution stack. This data contains the
dimension for the grid and thread blocks, together with any arguments for the call.
Parameters:
gridDim - Grid dimensions
blockDim - Block dimensions
sharedMem - Shared memory
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidConfiguration
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaFuncGetAttributes (C API), cudaLaunch (C API), cudaSetDoubleForDevice, cudaSetDoubleForHost, cud-
aSetupArgument (C API),
This function obtains the attributes of a function specified via func. The fetched attributes are placed in attr. If the
specified function does not exist, then cudaErrorInvalidDeviceFunction is returned.
Parameters:
attr - Return pointer to function’s attributes
func - Function to get attributes of
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorInvalidDeviceFunction
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C++ API), cudaLaunch (C API), cudaSetDoubleForDevice, cudaSet-
DoubleForHost, cudaSetupArgument (C API)
Launches the function entry on the device. The parameter entry must be a character string naming a function
that executes on the device. The parameter specified by entry must be declared as a __global__ function. cud-
aLaunch() must be preceded by a call to cudaConfigureCall() since it pops the data that was pushed by cudaConfig-
ureCall() from the execution stack.
Parameters:
entry - Device char string naming device function to execute
Returns:
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidConfiguration, cudaErrorLaunchFailure, cud-
aErrorPriorLaunchFailure, cudaErrorLaunchTimeout, cudaErrorLaunchOutOfResources
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C API), cudaLaunch (C++ API), cudaSetDoubleForDevice, cudaSet-
DoubleForHost, cudaSetupArgument (C API)
Parameters:
d - Double to convert
Converts the double value of d to an internal float representation if the device does not support double arithmetic. If
the device does natively support doubles, then this function does nothing.
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C API), cudaLaunch (C API), cudaSetDoubleForHost, cudaSetupAr-
gument (C API)
Converts the double value of d from a potentially internal float representation if the device does not support double
arithmetic. If the device does natively support doubles, then this function does nothing.
Parameters:
d - Double to convert
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C API), cudaLaunch (C API), cudaSetDoubleForDevice, cudaSetu-
pArgument (C API)
3.7.2.6 cudaError_t cudaSetupArgument (const void ∗ arg, size_t size, size_t offset)
Pushes size bytes of the argument pointed to by arg at offset bytes from the start of the parameter passing area,
which starts at offset 0. The arguments are stored in the top of the execution stack. cudaSetupArgument() must be
preceded by a call to cudaConfigureCall().
Parameters:
arg - Argument to push for a kernel launch
size - Size of argument
offset - Offset in argument stack to push new arg
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C API), cudaLaunch (C API), cudaSetDoubleForDevice, cudaSet-
DoubleForHost, cudaSetupArgument (C++ API),
Functions
• cudaError_t cudaFree (void ∗devPtr)
Frees memory on the device.
• cudaError_t cudaMallocArray (struct cudaArray ∗∗arrayPtr, const struct cudaChannelFormatDesc ∗desc, size_t
width, size_t height)
Allocate an array on the device.
• cudaError_t cudaMallocPitch (void ∗∗devPtr, size_t ∗pitch, size_t width, size_t height)
Allocates pitched memory on the device.
• cudaError_t cudaMemcpy (void ∗dst, const void ∗src, size_t count, enum cudaMemcpyKind kind)
Copies data between host and device.
• cudaError_t cudaMemcpy2D (void ∗dst, size_t dpitch, const void ∗src, size_t spitch, size_t width, size_t height,
enum cudaMemcpyKind kind)
Copies data between host and device.
• cudaError_t cudaMemcpy2DArrayToArray (struct cudaArray ∗dst, size_t wOffsetDst, size_t hOffsetDst, const
struct cudaArray ∗src, size_t wOffsetSrc, size_t hOffsetSrc, size_t width, size_t height, enum cudaMemcpyKind
kind)
Copies data between host and device.
• cudaError_t cudaMemcpy2DAsync (void ∗dst, size_t dpitch, const void ∗src, size_t spitch, size_t width, size_t
height, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies data between host and device.
• cudaError_t cudaMemcpy2DFromArray (void ∗dst, size_t dpitch, const struct cudaArray ∗src, size_t wOffset,
size_t hOffset, size_t width, size_t height, enum cudaMemcpyKind kind)
Copies data between host and device.
• cudaError_t cudaMemcpy2DFromArrayAsync (void ∗dst, size_t dpitch, const struct cudaArray ∗src, size_t
wOffset, size_t hOffset, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies data between host and device.
• cudaError_t cudaMemcpy2DToArray (struct cudaArray ∗dst, size_t wOffset, size_t hOffset, const void ∗src,
size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind)
Copies data between host and device.
• cudaError_t cudaMemcpy2DToArrayAsync (struct cudaArray ∗dst, size_t wOffset, size_t hOffset, const void
∗src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies data between host and device.
• cudaError_t cudaMemcpyArrayToArray (struct cudaArray ∗dst, size_t wOffsetDst, size_t hOffsetDst, const
struct cudaArray ∗src, size_t wOffsetSrc, size_t hOffsetSrc, size_t count, enum cudaMemcpyKind kind)
Copies data between host and device.
• cudaError_t cudaMemcpyAsync (void ∗dst, const void ∗src, size_t count, enum cudaMemcpyKind kind,
cudaStream_t stream)
Copies data between host and device.
• cudaError_t cudaMemcpyFromArray (void ∗dst, const struct cudaArray ∗src, size_t wOffset, size_t hOffset,
size_t count, enum cudaMemcpyKind kind)
Copies data between host and device.
• cudaError_t cudaMemcpyFromArrayAsync (void ∗dst, const struct cudaArray ∗src, size_t wOffset, size_t hOff-
set, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies data between host and device.
• cudaError_t cudaMemcpyFromSymbol (void ∗dst, const char ∗symbol, size_t count, size_t offset, enum cud-
aMemcpyKind kind)
Copies data from the given symbol on the device.
• cudaError_t cudaMemcpyFromSymbolAsync (void ∗dst, const char ∗symbol, size_t count, size_t offset, enum
cudaMemcpyKind kind, cudaStream_t stream)
Copies data from the given symbol on the device.
• cudaError_t cudaMemcpyToArray (struct cudaArray ∗dst, size_t wOffset, size_t hOffset, const void ∗src, size_t
count, enum cudaMemcpyKind kind)
Copies data between host and device.
• cudaError_t cudaMemcpyToArrayAsync (struct cudaArray ∗dst, size_t wOffset, size_t hOffset, const void ∗src,
size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies data between host and device.
• cudaError_t cudaMemcpyToSymbol (const char ∗symbol, const void ∗src, size_t count, size_t offset, enum
cudaMemcpyKind kind)
Copies data to the given symbol on the device.
• cudaError_t cudaMemcpyToSymbolAsync (const char ∗symbol, const void ∗src, size_t count, size_t offset,
enum cudaMemcpyKind kind, cudaStream_t stream)
Copies data to the given symbol on the device.
• cudaError_t cudaMemset2D (void ∗devPtr, size_t pitch, int value, size_t width, size_t height)
Initializes or sets device memory to a value.
• cudaError_t cudaMemset3D (struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent)
Initializes or sets device memory to a value.
This section describes the memory management functions of the CUDA runtime application programming interface.
Frees the memory space pointed to by devPtr, which must have been returned by a previous call to cudaMalloc()
or cudaMallocPitch(). Otherwise, or if cudaFree(devPtr) has already been called before, an error is returned. If
devPtr is 0, no operation is performed. cudaFree() returns cudaErrorInvalidDevicePointer in case of failure.
Parameters:
devPtr - Device pointer to memory to free
Returns:
cudaSuccess, cudaErrorInvalidDevicePointer, cudaErrorInitializationError
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc, cudaMallocPitch, cudaMallocArray, cudaFreeArray, cudaMallocHost, cudaFreeHost, cudaMal-
loc3D, cudaMalloc3DArray, cudaHostAlloc
Frees the CUDA array array, which must have been ∗ returned by a previous call to cudaMallocArray(). If cud-
aFreeArray(array) has already been called before, cudaErrorInvalidValue is returned. If devPtr is 0, no operation
is performed.
Parameters:
array - Pointer to array to free
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInitializationError
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc, cudaMallocPitch, cudaFree, cudaMallocArray, cudaMallocHost, cudaFreeHost, cudaHostAlloc
Frees the memory space pointed to by hostPtr, which must have been returned by a previous call to cudaMallo-
cHost() or cudaHostAlloc().
Parameters:
ptr - Pointer to memory to free
Returns:
cudaSuccess, cudaErrorInitializationError
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc, cudaMallocPitch, cudaFree, cudaMallocArray, cudaFreeArray, cudaMallocHost, cudaMalloc3D, cu-
daMalloc3DArray, cudaHostAlloc
Returns in ∗devPtr the address of symbol symbol on the device. symbol can either be a variable that resides
in global memory space, or it can be a character string, naming a variable that resides in global memory space. If
symbol cannot be found, or if symbol is not declared in the global memory space, ∗devPtr is unchanged and the
error cudaErrorInvalidSymbol is returned.
Parameters:
devPtr - Return device pointer associated with symbol
symbol - Global variable or string symbol to search for
Returns:
cudaSuccess, cudaErrorInvalidSymbol, cudaErrorAddressOfConstant
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetSymbolAddress (C++ API) cudaGetSymbolSize (C API)
Returns in ∗size the size of symbol symbol. symbol can either be a variable that resides in global or constant
memory space, or it can be a character string, naming a variable that resides in global or constant memory space. If
symbol cannot be found, or if symbol is not declared in global or constant memory space, ∗size is unchanged
and the error cudaErrorInvalidSymbol is returned.
Parameters:
size - Size of object associated with symbol
symbol - Global variable or string symbol to find size of
Returns:
cudaSuccess, cudaErrorInvalidSymbol
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetSymbolAddress (C API) cudaGetSymbolSize (C++ API)
3.8.2.6 cudaError_t cudaHostAlloc (void ∗∗ ptr, size_t size, unsigned int flags)
Allocates count bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual
memory ranges allocated with this function and automatically accelerates calls to functions such as cudaMemcpy().
Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than
pageable memory obtained with functions such as malloc(). Allocating excessive amounts of pinned memory may
degrade system performance, since it reduces the amount of memory available to the system for paging. As a result,
this function is best used sparingly to allocate staging areas for data exchange between host and device.
The flags parameter enables different options to be specified that affect the allocation, as follows.
• cudaHostAllocDefault: This flag’s value is defined to be 0 and causes cudaHostAlloc() to emulate cudaMallo-
cHost().
• cudaHostAllocPortable: The memory returned by this call will be considered as pinned memory by all CUDA
contexts, not just the one that performed the allocation.
• cudaHostAllocMapped: Maps the allocation into the CUDA address space. The device pointer to the memory
may be obtained by calling cudaHostGetDevicePointer().
All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or
write-combined with no restrictions.
cudaSetDeviceFlags() must have been called with the cudaDeviceMapHost flag in order for the cudaHostAllocMapped
flag to have any effect.
The cudaHostAllocMapped flag may be specified on CUDA contexts for devices that do not support mapped pinned
memory. The failure is deferred to cudaHostGetDevicePointer() because the memory may be mapped into other
CUDA contexts via the cudaHostAllocPortable flag.
Memory allocated by this function must be freed with cudaFreeHost().
Parameters:
ptr - Device pointer to allocated memory
size - Requested allocation size in bytes
flags - Requested properties of allocated memory
Returns:
cudaSuccess, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaSetDeviceFlags, cudaMallocHost, cudaFreeHost
3.8.2.7 cudaError_t cudaHostGetDevicePointer (void ∗∗ pDevice, void ∗ pHost, unsigned int flags)
Passes back the device pointer corresponding to the mapped, pinned host buffer allocated by cudaHostAlloc().
cudaHostGetDevicePointer() will fail if the cudaDeviceMapHost flag was not specified before deferred context cre-
ation occurred, or if called on a device that does not support mapped, pinned memory.
flags provides for future releases. For now, it must be set to 0.
Parameters:
pDevice - Returned device pointer for mapped memory
pHost - Requested host pointer mapping
flags - Flags for extensions (must be 0 for now)
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaSetDeviceFlags, cudaHostAlloc
cudaHostGetFlags() will fail if the input pointer does not reside in an address range allocated by cudaHostAlloc().
Parameters:
pFlags - Returned flags word
pHost - Host pointer
Returns:
cudaSuccess, cudaErrorInvalidValue
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaHostAlloc
Allocates size bytes of linear memory on the device and returns in ∗devPtr a pointer to the allocated memory.
The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. cudaMalloc() returns
cudaErrorMemoryAllocation in case of failure.
Parameters:
devPtr - Pointer to allocated device memory
size - Requested allocation size in bytes
Returns:
cudaSuccess, cudaErrorMemoryAllocation
See also:
cudaMallocPitch, cudaFree, cudaMallocArray, cudaFreeArray, cudaMalloc3D, cudaMalloc3DArray, cudaMallo-
cHost, cudaFreeHost, cudaHostAlloc
Allocates at least width ∗ height ∗ depth bytes of linear memory on the device and returns a cudaPitchedPtr in
which ptr is a pointer to the allocated memory. The function may pad the allocation to ensure hardware alignment
requirements are met. The pitch returned in the pitch field of pitchedDevPtr is the width in bytes of the
allocation.
The returned cudaPitchedPtr contains additional fields xsize and ysize, the logical width and height of the allo-
cation, which are equivalent to the width and height extent parameters provided by the programmer during
allocation.
For allocations of 2D and 3D objects, it is highly recommended that programmers perform allocations using cudaMal-
loc3D() or cudaMallocPitch(). Due to alignment restrictions in the hardware, this is especially true if the application
will be performing memory copies involving 2D or 3D objects (whether linear memory or CUDA arrays).
Parameters:
pitchedDevPtr - Pointer to allocated pitched device memory
extent - Requested allocation size
Returns:
cudaSuccess, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMallocPitch, cudaFree, cudaMemcpy3D, cudaMemset3D, cudaMalloc3DArray, cudaMallocArray, cud-
aFreeArray, cudaMallocHost, cudaFreeHost, cudaHostAlloc, make_cudaPitchedPtr, make_cudaExtent
Allocates a CUDA array according to the cudaChannelFormatDesc structure desc and returns a handle to the new
CUDA array in ∗arrayPtr.
The cudaChannelFormatDesc is defined as:
struct cudaChannelFormatDesc {
int x, y, z, w;
enum cudaChannelFormatKind f;
};
• A 1D array is allocated if the height and depth extent are both zero. For 1D arrays valid extent ranges are {(1,
8192), 0, 0}.
• A 2D array is allocated if only the depth extent is zero. For 2D arrays valid extent ranges are {(1, 65536), (1,
32768), 0}.
• A 3D array is allocated if all three extents are non-zero. For 3D arrays valid extent ranges are {(1, 2048), (1,
2048), (1, 2048)}.
Note:
Due to the differing extent limits, it may be advantageous to use a degenerate array (with unused dimensions set
to one) of higher dimensionality. For instance, a degenerate 2D array allows for significantly more linear storage
than a 1D array.
Parameters:
arrayPtr - Pointer to allocated array in device memory
desc - Requested channel format
extent - Requested allocation size
Returns:
cudaSuccess, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc3D, cudaMalloc, cudaMallocPitch, cudaFree, cudaFreeArray, cudaMallocHost, cudaFreeHost, cuda-
HostAlloc, make_cudaExtent
Allocates a CUDA array according to the cudaChannelFormatDesc structure desc and returns a handle to the new
CUDA array in ∗array.
The cudaChannelFormatDesc is defined as:
struct cudaChannelFormatDesc {
int x, y, z, w;
enum cudaChannelFormatKind f;
};
Parameters:
arrayPtr - Pointer to allocated array in device memory
desc - Requested channel format
width - Requested array allocation width
height - Requested array allocation height
Returns:
cudaSuccess, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc, cudaMallocPitch, cudaFree, cudaFreeArray, cudaMallocHost, cudaFreeHost, cudaMalloc3D, cud-
aMalloc3DArray, cudaHostAlloc
Allocates size bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual
memory ranges allocated with this function and automatically accelerates calls to functions such as cudaMemcpy∗().
Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth
than pageable memory obtained with functions such as malloc(). Allocating excessive amounts of memory with
cudaMallocHost() may degrade system performance, since it reduces the amount of memory available to the system
for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between host
and device.
Parameters:
ptr - Pointer to allocated host memory
size - Requested allocation size in bytes
Returns:
cudaSuccess, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc, cudaMallocPitch, cudaMallocArray, cudaMalloc3D, cudaMalloc3DArray, cudaHostAlloc, cud-
aFree, cudaFreeArray, cudaFreeHost, cudaHostAlloc
3.8.2.14 cudaError_t cudaMallocPitch (void ∗∗ devPtr, size_t ∗ pitch, size_t width, size_t height)
Allocates at least widthInBytes ∗ height bytes of linear memory on the device and returns in ∗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 ∗pitch by cudaMallocPitch() 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 T, the address is computed as:
For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations using cud-
aMallocPitch(). 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).
Parameters:
devPtr - Pointer to allocated pitched device memory
Returns:
cudaSuccess, cudaErrorMemoryAllocation
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc, cudaFree, cudaMallocArray, cudaFreeArray, cudaMallocHost, cudaFreeHost, cudaMalloc3D, cud-
aMalloc3DArray, cudaHostAlloc
3.8.2.15 cudaError_t cudaMemcpy (void ∗ dst, const void ∗ src, size_t count, enum cudaMemcpyKind kind)
Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind is
one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDevice-
ToDevice, and specifies the direction of the copy. The memory areas may not overlap. Calling cudaMemcpy() with
dst and src pointers that do not match the direction of the copy results in an undefined behavior.
Parameters:
dst - Destination memory address
src - Source memory address
count - Size in bytes to copy
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMem-
cpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol,
cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cud-
aMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpy-
ToSymbolAsync, cudaMemcpyFromSymbolAsync
3.8.2.16 cudaError_t cudaMemcpy2D (void ∗ dst, size_t dpitch, const void ∗ src, size_t spitch, size_t width,
size_t height, enum cudaMemcpyKind kind)
Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area
pointed to by dst, where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDe-
viceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy. dpitch and spitch are the
widths in memory in bytes of the 2D arrays pointed to by dst and src, including any padding added to the end of
each row. The memory areas may not overlap. Calling cudaMemcpy2D() with dst and src pointers that do not
match the direction of the copy results in an undefined behavior. cudaMemcpy2D() returns an error if dpitch or
spitch is greater than the maximum allowed.
Parameters:
dst - Destination memory address
dpitch - Pitch of destination memory
src - Source memory address
spitch - Pitch of source memory
width - Width of matrix transfer (columns in bytes)
height - Height of matrix transfer (rows)
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidPitchValue, cudaErrorInvalidDevicePointer, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMem-
cpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol,
cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cud-
aMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpy-
ToSymbolAsync, cudaMemcpyFromSymbolAsync
Copies a matrix (height rows of width bytes each) from the CUDA array srcArray starting at the upper left
corner (wOffsetSrc, hOffsetSrc) to the CUDA array dst starting at the upper left corner (wOffsetDst,
hOffsetDst), where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDevice-
ToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy.
Parameters:
dst - Destination memory address
wOffsetDst - Destination starting X offset
hOffsetDst - Destination starting Y offset
src - Source memory address
wOffsetSrc - Source starting X offset
hOffsetSrc - Source starting Y offset
width - Width of matrix transfer (columns in bytes)
height - Height of matrix transfer (rows)
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cu-
daMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync, cu-
daMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.18 cudaError_t cudaMemcpy2DAsync (void ∗ dst, size_t dpitch, const void ∗ src, size_t spitch, size_t
width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area
pointed to by dst, where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDe-
viceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy. dpitch and spitch are the
widths in memory in bytes of the 2D arrays pointed to by dst and src, including any padding added to the end
of each row. The memory areas may not overlap. Calling cudaMemcpy2DAsync() with dst and src pointers that
do not match the direction of the copy results in an undefined behavior. cudaMemcpy2DAsync() returns an error if
dpitch or spitch is greater than the maximum allowed.
cudaMemcpy2DAsync() is asynchronous with respect to the host, so the call may return before the copy is complete.
It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input.
The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is cudaMem-
cpyHostToDevice or cudaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in
other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
dst - Destination memory address
dpitch - Pitch of destination memory
src - Source memory address
spitch - Pitch of source memory
width - Width of matrix transfer (columns in bytes)
height - Height of matrix transfer (rows)
kind - Type of transfer
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidPitchValue, cudaErrorInvalidDevicePointer, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol,
cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.19 cudaError_t cudaMemcpy2DFromArray (void ∗ dst, size_t dpitch, const struct cudaArray ∗ src,
size_t wOffset, size_t hOffset, size_t width, size_t height, enum cudaMemcpyKind kind)
Copies a matrix (height rows of width bytes each) from the CUDA array srcArray starting at the upper left
corner (wOffset, hOffset) to the memory area pointed to by dst, where kind is one of cudaMemcpyHost-
ToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the
direction of the copy. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any
padding added to the end of each row. cudaMemcpy2DFromArray() returns an error if dpitch is greater than the
maximum allowed.
Parameters:
dst - Destination memory address
dpitch - Pitch of destination memory
src - Source memory address
wOffset - Source starting X offset
hOffset - Source starting Y offset
width - Width of matrix transfer (columns in bytes)
height - Height of matrix transfer (rows)
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidPitchValue, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray,
cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSym-
bol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.20 cudaError_t cudaMemcpy2DFromArrayAsync (void ∗ dst, size_t dpitch, const struct cudaArray
∗ src, size_t wOffset, size_t hOffset, size_t width, size_t height, enum cudaMemcpyKind kind,
cudaStream_t stream)
Copies a matrix (height rows of width bytes each) from the CUDA array srcArray starting at the upper left
corner (wOffset, hOffset) to the memory area pointed to by dst, where kind is one of cudaMemcpyHost-
ToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the
direction of the copy. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any
padding added to the end of each row. cudaMemcpy2DFromArrayAsync() returns an error if dpitch is greater than
the maximum allowed.
cudaMemcpy2DFromArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is
complete. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind
is cudaMemcpyHostToDevice or cudaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with
operations in other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
dst - Destination memory address
dpitch - Pitch of destination memory
src - Source memory address
wOffset - Source starting X offset
hOffset - Source starting Y offset
width - Width of matrix transfer (columns in bytes)
height - Height of matrix transfer (rows)
kind - Type of transfer
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidPitchValue, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSym-
bol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cud-
aMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMemcpyFrom-
SymbolAsync
3.8.2.21 cudaError_t cudaMemcpy2DToArray (struct cudaArray ∗ dst, size_t wOffset, size_t hOffset, const
void ∗ src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind)
Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the CUDA array
dst starting at the upper left corner (wOffset, hOffset) where kind is one of cudaMemcpyHostToHost, cud-
aMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of
the copy. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added
to the end of each row. cudaMemcpy2DToArray() returns an error if spitch is greater than the maximum allowed.
Parameters:
dst - Destination memory address
wOffset - Destination starting X offset
hOffset - Destination starting Y offset
src - Source memory address
spitch - Pitch of source memory
width - Width of matrix transfer (columns in bytes)
height - Height of matrix transfer (rows)
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidPitchValue, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpyFromArray, cudaMemcpy2DFromArray,
cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSym-
bol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the CUDA array
dst starting at the upper left corner (wOffset, hOffset) where kind is one of cudaMemcpyHostToHost, cud-
aMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of
the copy. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added
to the end of each row. cudaMemcpy2DToArrayAsync() returns an error if spitch is greater than the maximum
allowed.
cudaMemcpy2DToArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is
complete. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind
is cudaMemcpyHostToDevice or cudaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with
operations in other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
dst - Destination memory address
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidPitchValue, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSym-
bol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
struct cudaExtent {
size_t width;
size_t height;
size_t depth;
};
struct cudaExtent make_cudaExtent(size_t w, size_t h, size_t d);
struct cudaPos {
size_t x;
size_t y;
size_t z;
};
struct cudaPos make_cudaPos(size_t x, size_t y, size_t z);
struct cudaMemcpy3DParms {
struct cudaArray *srcArray;
struct cudaPos srcPos;
struct cudaPitchedPtr srcPtr;
struct cudaArray *dstArray;
struct cudaPos dstPos;
struct cudaPitchedPtr dstPtr;
struct cudaExtent extent;
enum cudaMemcpyKind kind;
};
cudaMemcpy3D() copies data betwen two 3D objects. The source and destination objects may be in either host
memory, device memory, or a CUDA array. The source, destination, extent, and kind of copy performed is specified
by the cudaMemcpy3DParms struct which should be initialized to zero before use:
The struct passed to cudaMemcpy3D() must specify one of srcArray or srcPtr and one of dstArray or
dstPtr. Passing more than one non-zero source or destination will cause cudaMemcpy3D() to return an error.
The srcPos and dstPos fields are optional offsets into the source and destination objects and are defined in units of
each object’s elements. The element for a host or device pointer is assumed to be unsigned char. For CUDA arrays,
positions must be in the range [0, 2048) for any dimension.
The extent field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the
copy, the extent is defined in terms of that array’s elements. If no CUDA array is participating in the copy then the
extents are defined in elements of unsigned char.
The kind field defines the direction of the copy. It must be one of cudaMemcpyHostToHost, cudaMemcpyHostToDe-
vice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice.
If the source and destination are both arrays, cudaMemcpy3D() will return an error if they do not have the same
element size.
The source and destination object may not overlap. If overlapping source and destination objects are specified, unde-
fined behavior will result.
cudaMemcpy3D() returns an error if the pitch of srcPtr or dstPtr is greater than the maximum allowed. The
pitch of a cudaPitchedPtr allocated with cudaMalloc3D() will always be valid.
Parameters:
p - 3D memory copy parameters
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidPitchValue, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc3D, cudaMalloc3DArray, cudaMemset3D, cudaMemcpy3DAsync, cudaMemcpy, cudaMemcpy2D,
cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMemcpy2DFromArray, cu-
daMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSym-
bol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync, make_cudaExtent, make_cudaPos
struct cudaExtent {
size_t width;
size_t height;
size_t depth;
};
struct cudaExtent make_cudaExtent(size_t w, size_t h, size_t d);
struct cudaPos {
size_t x;
size_t y;
size_t z;
};
struct cudaPos make_cudaPos(size_t x, size_t y, size_t z);
struct cudaMemcpy3DParms {
struct cudaArray *srcArray;
struct cudaPos srcPos;
struct cudaPitchedPtr srcPtr;
struct cudaArray *dstArray;
struct cudaPos dstPos;
struct cudaPitchedPtr dstPtr;
struct cudaExtent extent;
enum cudaMemcpyKind kind;
};
cudaMemcpy3DAsync() copies data betwen two 3D objects. The source and destination objects may be in either host
memory, device memory, or a CUDA array. The source, destination, extent, and kind of copy performed is specified
by the cudaMemcpy3DParms struct which should be initialized to zero before use:
The struct passed to cudaMemcpy3DAsync() must specify one of srcArray or srcPtr and one of dstArray or
dstPtr. Passing more than one non-zero source or destination will cause cudaMemcpy3DAsync() to return an error.
The srcPos and dstPos fields are optional offsets into the source and destination objects and are defined in units of
each object’s elements. The element for a host or device pointer is assumed to be unsigned char. For CUDA arrays,
positions must be in the range [0, 2048) for any dimension.
The extent field defines the dimensions of the transferred area in elements. If a CUDA array is participating in the
copy, the extent is defined in terms of that array’s elements. If no CUDA array is participating in the copy then the
extents are defined in elements of unsigned char.
The kind field defines the direction of the copy. It must be one of cudaMemcpyHostToHost, cudaMemcpyHostToDe-
vice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice.
If the source and destination are both arrays, cudaMemcpy3DAsync() will return an error if they do not have the same
element size.
The source and destination object may not overlap. If overlapping source and destination objects are specified, unde-
fined behavior will result.
cudaMemcpy3DAsync() returns an error if the pitch of srcPtr or dstPtr is greater than the maximum allowed.
The pitch of a cudaPitchedPtr allocated with cudaMalloc3D() will always be valid.
cudaMemcpy3DAsync() is asynchronous with respect to the host, so the call may return before the copy is complete.
It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input.
The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is cudaMem-
cpyHostToDevice or cudaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in
other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
p - 3D memory copy parameters
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidPitchValue, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMalloc3D, cudaMalloc3DArray, cudaMemset3D, cudaMemcpy3D, cudaMemcpy, cudaMemcpy2D, cud-
aMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMemcpy2DFromArray, cudaMem-
cpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSymbol, cu-
daMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync, cu-
daMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync, make_cudaExtent, make_cudaPos
Copies count bytes from the CUDA array src starting at the upper left corner (wOffsetSrc, hOffsetSrc)
to the CUDA array dst starting at the upper left corner (wOffsetDst, hOffsetDst) where kind is one of cu-
daMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice,
and specifies the direction of the copy.
Parameters:
dst - Destination memory address
wOffsetDst - Destination starting X offset
hOffsetDst - Destination starting Y offset
src - Source memory address
wOffsetSrc - Source starting X offset
hOffsetSrc - Source starting Y offset
count - Size in bytes to copy
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray,
cudaMemcpy2DFromArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSym-
bol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.26 cudaError_t cudaMemcpyAsync (void ∗ dst, const void ∗ src, size_t count, enum cudaMemcpyKind
kind, cudaStream_t stream)
Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind is
one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDevice-
ToDevice, and specifies the direction of the copy. The memory areas may not overlap. Calling cudaMemcpyAsync()
with dst and src pointers that do not match the direction of the copy results in an undefined behavior.
cudaMemcpyAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. It
only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. The
copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is cudaMemcpy-
HostToDevice or cudaMemcpyDeviceToHost and the stream is non-zero, the copy may overlap with operations in
other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
dst - Destination memory address
src - Source memory address
count - Size in bytes to copy
kind - Type of transfer
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray,
cudaMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpy-
ToSymbol, cudaMemcpyFromSymbol, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMem-
cpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSym-
bolAsync, cudaMemcpyFromSymbolAsync
3.8.2.27 cudaError_t cudaMemcpyFromArray (void ∗ dst, const struct cudaArray ∗ src, size_t wOffset,
size_t hOffset, size_t count, enum cudaMemcpyKind kind)
Copies count bytes from the CUDA array src starting at the upper left corner (wOffset, hOffset) to the memory
area pointed to by dst, where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpy-
DeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy.
Parameters:
dst - Destination memory address
src - Source memory address
wOffset - Source starting X offset
hOffset - Source starting Y offset
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpy2DFromArray,
cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol, cudaMemcpyFromSym-
bol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.28 cudaError_t cudaMemcpyFromArrayAsync (void ∗ dst, const struct cudaArray ∗ src, size_t
wOffset, size_t hOffset, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies count bytes from the CUDA array src starting at the upper left corner (wOffset, hOffset) to the memory
area pointed to by dst, where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpy-
DeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy.
cudaMemcpyFromArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is
complete. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind
is cudaMemcpyHostToDevice or cudaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with
operations in other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
dst - Destination memory address
src - Source memory address
wOffset - Source starting X offset
hOffset - Source starting Y offset
count - Size in bytes to copy
kind - Type of transfer
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSym-
bol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync,
cudaMemcpy2DToArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.29 cudaError_t cudaMemcpyFromSymbol (void ∗ dst, const char ∗ symbol, size_t count, size_t offset,
enum cudaMemcpyKind kind)
Copies count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the
memory area pointed to by dst. The memory areas may not overlap. symbol can either be a variable that resides in
global or constant memory space, or it can be a character string, naming a variable that resides in global or constant
memory space. kind can be either cudaMemcpyDeviceToHost or cudaMemcpyDeviceToDevice.
Parameters:
dst - Destination memory address
symbol - Symbol source from device
count - Size in bytes to copy
offset - Offset from start of symbol in bytes
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidDevicePointer, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSym-
bol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.30 cudaError_t cudaMemcpyFromSymbolAsync (void ∗ dst, const char ∗ symbol, size_t count, size_t
offset, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the
memory area pointed to by dst. The memory areas may not overlap. symbol can either be a variable that resides in
global or constant memory space, or it can be a character string, naming a variable that resides in global or constant
memory space. kind can be either cudaMemcpyDeviceToHost or cudaMemcpyDeviceToDevice.
cudaMemcpyFromSymbolAsync() is asynchronous with respect to the host, so the call may return before the copy is
complete. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is
cudaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
dst - Destination memory address
symbol - Symbol source from device
count - Size in bytes to copy
offset - Offset from start of symbol in bytes
kind - Type of transfer
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidDevicePointer, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSym-
bol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cu-
daMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpy-
ToSymbolAsync
3.8.2.31 cudaError_t cudaMemcpyToArray (struct cudaArray ∗ dst, size_t wOffset, size_t hOffset, const
void ∗ src, size_t count, enum cudaMemcpyKind kind)
Copies count bytes from the memory area pointed to by src to the CUDA array dst starting at the upper left corner
(wOffset, hOffset), where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpy-
DeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy.
Parameters:
dst - Destination memory address
wOffset - Destination starting X offset
hOffset - Destination starting Y offset
src - Source memory address
count - Size in bytes to copy
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpy2DToArray, cudaMemcpyFromArray, cudaMem-
cpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSymbol,
cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cud-
aMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpy-
ToSymbolAsync, cudaMemcpyFromSymbolAsync
3.8.2.32 cudaError_t cudaMemcpyToArrayAsync (struct cudaArray ∗ dst, size_t wOffset, size_t hOffset,
const void ∗ src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies count bytes from the memory area pointed to by src to the CUDA array dst starting at the upper left corner
(wOffset, hOffset), where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpy-
DeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy.
cudaMemcpyToArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is
complete. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind
is cudaMemcpyHostToDevice or cudaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with
operations in other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
dst - Destination memory address
wOffset - Destination starting X offset
hOffset - Destination starting Y offset
src - Source memory address
count - Size in bytes to copy
kind - Type of transfer
stream - Stream identifier
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSym-
bol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.33 cudaError_t cudaMemcpyToSymbol (const char ∗ symbol, const void ∗ src, size_t count, size_t
offset, enum cudaMemcpyKind kind)
Copies count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from
the start of symbol symbol. The memory areas may not overlap. symbol can either be a variable that resides in
global or constant memory space, or it can be a character string, naming a variable that resides in global or constant
memory space. kind can be either cudaMemcpyHostToDevice or cudaMemcpyDeviceToDevice.
Parameters:
symbol - Symbol destination on device
src - Source memory address
count - Size in bytes to copy
offset - Offset from start of symbol in bytes
kind - Type of transfer
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidDevicePointer, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyFromSym-
bol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cudaMemcpy2DToArrayAsync,
cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMemcpyToSymbolAsync, cudaMem-
cpyFromSymbolAsync
3.8.2.34 cudaError_t cudaMemcpyToSymbolAsync (const char ∗ symbol, const void ∗ src, size_t count,
size_t offset, enum cudaMemcpyKind kind, cudaStream_t stream)
Copies count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from
the start of symbol symbol. The memory areas may not overlap. symbol can either be a variable that resides in
global or constant memory space, or it can be a character string, naming a variable that resides in global or constant
memory space. kind can be either cudaMemcpyHostToDevice or cudaMemcpyDeviceToDevice.
cudaMemcpyToSymbolAsync() is asynchronous with respect to the host, so the call may return before the copy is
complete. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is
cudaMemcpyHostToDevice and stream is non-zero, the copy may overlap with operations in other streams.
IMPORTANT NOTE: Copies with kind == cudaMemcpyDeviceToDevice are asynchronous with respect to the
host, but never overlap with kernel execution.
Parameters:
symbol - Symbol destination on device
src - Source memory address
count - Size in bytes to copy
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidSymbol, cudaErrorInvalidDevicePointer, cudaErrorIn-
validMemcpyDirection
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemcpy, cudaMemcpy2D, cudaMemcpyToArray, cudaMemcpy2DToArray, cudaMemcpyFromArray, cu-
daMemcpy2DFromArray, cudaMemcpyArrayToArray, cudaMemcpy2DArrayToArray, cudaMemcpyToSym-
bol, cudaMemcpyFromSymbol, cudaMemcpyAsync, cudaMemcpy2DAsync, cudaMemcpyToArrayAsync, cu-
daMemcpy2DToArrayAsync, cudaMemcpyFromArrayAsync, cudaMemcpy2DFromArrayAsync, cudaMem-
cpyFromSymbolAsync
Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value.
Parameters:
devPtr - Pointer to device memory
value - Value to set for each byte of specified memory
count - Size in bytes to set
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemset2D, cudaMemset3D
3.8.2.36 cudaError_t cudaMemset2D (void ∗ devPtr, size_t pitch, int value, size_t width, size_t height)
Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. pitch is
the width in bytes of the 2D array pointed to by dstPtr, including any padding added to the end of each row. This
function performs fastest when the pitch is one that has been passed back by cudaMallocPitch().
Parameters:
devPtr - Pointer to 2D device memory
pitch - Pitch in bytes of 2D device memory
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemset, cudaMemset3D
3.8.2.37 cudaError_t cudaMemset3D (struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent
extent)
Initializes each element of a 3D array to the specified value value. The object to initialize is defined by
pitchedDevPtr. The pitch field of pitchedDevPtr is the width in memory in bytes of the 3D array pointed
to by pitchedDevPtr, including any padding added to the end of each row. The xsize field specifies the logical
width of each row in bytes, while the ysize field specifies the height of each 2D slice in rows.
The extents of the initialized region are specified as a width in bytes, a height in rows, and a depth in slices.
Extents with width greater than or equal to the xsize of pitchedDevPtr may perform significantly faster than
extents narrower than the xsize. Secondarily, extents with height equal to the ysize of pitchedDevPtr will
perform faster than when the height is shorter than the ysize.
This function performs fastest when the pitchedDevPtr has been allocated by cudaMalloc3D().
Parameters:
pitchedDevPtr - Pointer to pitched device memory
value - Value to set for each byte of specified memory
extent - Size parameters for where to set device memory
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaMemset, cudaMemset2D, cudaMalloc3D, make_cudaPitchedPtr, make_cudaExtent
Functions
• cudaError_t cudaGLMapBufferObject (void ∗∗devPtr, GLuint bufObj)
Maps a buffer object for access by CUDA.
This section describes the OpenGL interoperability functions of the CUDA runtime application programming inter-
face.
Maps the buffer object of ID bufObj into the address space of CUDA and returns in ∗devPtr the base pointer of the
resulting mapping. The buffer must have previously been registered by calling cudaGLRegisterBufferObject(). While
a buffer is mapped by CUDA, any OpenGL operation which references the buffer will result in undefined behavior.
The OpenGL context used to create the buffer, or another context from the same share group, must be bound to the
current thread when this is called.
All streams in the current thread are synchronized with the current GL context.
Parameters:
devPtr - Returned device pointer to CUDA object
Returns:
cudaSuccess, cudaErrorMapBufferObjectFailed
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLSetGLDevice, cudaGLRegisterBufferObject, cudaGLUnmapBufferObject, cudaGLUnregisterBufferOb-
ject, cudaGLMapBufferObjectAsync, cudaGLUnmapBufferObjectAsync
Maps the buffer object of ID bufObj into the address space of CUDA and returns in ∗devPtr the base pointer of the
resulting mapping. The buffer must have previously been registered by calling cudaGLRegisterBufferObject(). While
a buffer is mapped by CUDA, any OpenGL operation which references the buffer will result in undefined behavior.
The OpenGL context used to create the buffer, or another context from the same share group, must be bound to the
current thread when this is called.
Stream /p stream is synchronized with the current GL context.
Parameters:
devPtr - Returned device pointer to CUDA object
bufObj - Buffer object ID to map
stream - Stream to synchronize
Returns:
cudaSuccess, cudaErrorMapBufferObjectFailed
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLSetGLDevice, cudaGLRegisterBufferObject, cudaGLUnmapBufferObject, cudaGLUnregisterBufferOb-
ject, cudaGLUnmapBufferObjectAsync
Registers the buffer object of ID bufObj for access by CUDA. This function must be called before CUDA can map
the buffer object. The OpenGL context used to create the buffer, or another context from the same share group, must
be bound to the current thread when this is called.
Parameters:
bufObj - Buffer object ID to register
Returns:
cudaSuccess, cudaErrorInitializationError
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLSetGLDevice, cudaGLMapBufferObject, cudaGLUnmapBufferObject, cudaGLUnregisterBufferObject,
cudaGLMapBufferObjectAsync, cudaGLUnmapBufferObjectAsync
• cudaGLMapFlagsNone: Specifies no hints about how this buffer will be used. It is therefore assumed that this
buffer will be read from and written to by CUDA kernels. This is the default value.
• cudaGLMapFlagsReadOnly: Specifies that CUDA kernels which access this buffer will not write to the buffer.
• cudaGLMapFlagsWriteDiscard: Specifies that CUDA kernels which access this buffer will not read from the
buffer and will write over the entire contents of the buffer, so none of the data previously stored in the buffer
will be preserved.
If bufObj has not been registered for use with CUDA, then cudaErrorInvalidResourceHandle is returned. If bufObj
is presently mapped for access by CUDA, then cudaErrorUnknown is returned.
Parameters:
bufObj - Registered buffer object to set flags for
flags - Parameters for buffer mapping
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLSetGLDevice, cudaGLRegisterBufferObject, cudaGLUnregisterBufferObject, cudaGLMapBufferObject,
cudaGLUnmapBufferObject, cudaGLMapBufferObjectAsync, cudaGLUnmapBufferObjectAsync
Records device as the device on which the active host thread executes the device code. Records the thread as using
OpenGL interopability. If the host thread has already initialized the CUDA runtime by calling non-device management
runtime functions, this call returns cudaErrorSetOnActiveProcess.
Parameters:
device - Device to use for OpenGL interoperability
Returns:
cudaSuccess, cudaErrorInvalidDevice, cudaErrorSetOnActiveProcess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLRegisterBufferObject, cudaGLMapBufferObject, cudaGLUnmapBufferObject, cudaGLUnregisterBuffer-
Object, cudaGLMapBufferObjectAsync, cudaGLUnmapBufferObjectAsync
Unmaps the buffer object of ID bufObj for access by CUDA. When a buffer is unmapped, the base address returned
by cudaGLMapBufferObject() is invalid and subsequent references to the address result in undefined behavior. The
OpenGL context used to create the buffer, or another context from the same share group, must be bound to the current
thread when this is called.
All streams in the current thread are synchronized with the current GL context.
Parameters:
bufObj - Buffer object to unmap
Returns:
cudaSuccess, cudaErrorInvalidDevicePointer, cudaErrorUnmapBufferObjectFailed
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLSetGLDevice, cudaGLRegisterBufferObject, cudaGLMapBufferObject, cudaGLUnregisterBufferObject,
cudaGLMapBufferObjectAsync, cudaGLUnmapBufferObjectAsync
Unmaps the buffer object of ID bufObj for access by CUDA. When a buffer is unmapped, the base address returned
by cudaGLMapBufferObject() is invalid and subsequent references to the address result in undefined behavior. The
OpenGL context used to create the buffer, or another context from the same share group, must be bound to the current
thread when this is called.
Stream /p stream is synchronized with the current GL context.
Parameters:
bufObj - Buffer object to unmap
stream - Stream to synchronize
Returns:
cudaSuccess, cudaErrorInvalidDevicePointer, cudaErrorUnmapBufferObjectFailed
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLSetGLDevice, cudaGLRegisterBufferObject, cudaGLMapBufferObject, cudaGLUnregisterBufferObject,
cudaGLMapBufferObjectAsync
Unregisters the buffer object of ID bufObj for access by CUDA and releases any CUDA resources associated with
the buffer. Once a buffer is unregistered, it may no longer be mapped by CUDA. The GL context used to create the
buffer, or another context from the same share group, must be bound to the current thread when this is called.
Parameters:
bufObj - Buffer object to unregister
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGLSetGLDevice, cudaGLRegisterBufferObject, cudaGLMapBufferObject, cudaGLUnmapBufferObject,
cudaGLMapBufferObjectAsync, cudaGLUnmapBufferObjectAsync
Parameters:
device - Returns the device associated with hGpu, or -1 if hGpu is not a compute device.
hGpu - Handle to a GPU, as queried via WGL_NV_gpu_affinity()
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
WGL_NV_gpu_affinity, cudaGLSetGLDevice
Author:
NVIDIA Corporation
• enum cudaD3D9MapFlags {
cudaD3D9MapFlagsNone,
cudaD3D9MapFlagsReadOnly,
cudaD3D9MapFlagsWriteDiscard }
• enum cudaD3D9RegisterFlags {
cudaD3D9RegisterFlagsNone,
cudaD3D9RegisterFlagsArray }
• cudaError_t cudaD3D9GetDevice (int ∗device, const char ∗pszAdapterName)
Gets the device number for an adapter.
This section describes the Direct3D 9 interoperability functions of the CUDA runtime application programming inter-
face.
Enumerator:
cudaD3D9MapFlagsNone Default; Assume resource can be read/written.
cudaD3D9MapFlagsReadOnly CUDA kernels will not write to this resource.
cudaD3D9MapFlagsWriteDiscard CUDA kernels will only write to and will not read from this resource.
Enumerator:
cudaD3D9RegisterFlagsNone Default; Resource can be accessed througa void∗.
cudaD3D9RegisterFlagsArray Resource can be accessed through a CUarray∗.
Returns in ∗device the CUDA-compatible device corresponding to the adapter name pszAdapterName ob-
tained from EnumDisplayDevices or IDirect3D9::GetAdapterIdentifier(). If no device on the adapter with name
pszAdapterName is CUDA-compatible then the call will fail.
Parameters:
device - Returns the device corresponding to pszAdapterName
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cudaD3D9RegisterResource,
cudaD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources,
cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
Returns in ∗ppDxDevice the Direct3D device against which this CUDA context was created in cu-
daD3D9SetDirect3DDevice().
Parameters:
ppDxDevice - Returns the Direct3D device for this thread
Returns:
cudaSuccess, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9RegisterResource, cu-
daD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources,
cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
Parameters:
count - Number of resources to map for CUDA
ppResources - Resources to map for CUDA
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9UnmapResources,
cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
• IDirect3DVertexBuffer9: No notes.
• IDirect3DIndexBuffer9: No notes.
• IDirect3DSurface9: Only stand-alone objects of type IDirect3DSurface9 may be explicitly shared. In particular,
individual mipmap levels and faces of cube maps may not be registered directly. To access individual surfaces
associated with a texture, one must register the base texture object.
• IDirect3DBaseTexture9: When a texture is registered, all surfaces associated with all mipmap levels of all faces
of the texture will be accessible to CUDA.
The flags argument specifies the mechanism through which CUDA will access the Direct3D resource. The following
value is allowed:
Not all Direct3D resources of the above types may be used for interoperability with CUDA. The following are some
limitations:
• Textures which are not of a format which is 1, 2, or 4 channels of 8, 16, or 32-bit integer or floating-point data
cannot be shared.
If Direct3D interoperability is not initialized on this context, then cudaErrorInvalidDevice is returned. If pResource
is of incorrect type (e.g, is a non-stand-alone IDirect3DSurface9) or is already registered, then cudaErrorIn-
validResourceHandle is returned. If pResource cannot be registered then cudaErrorUnknown is returned.
Parameters:
pResource - Resource to register
flags - Parameters for resource registration
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources,
cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
Returns in ∗pArray an array through which the subresource of the mapped Direct3D resource pResource,
which corresponds to face and level may be accessed. The value set in pArray may change every time that
pResource is mapped.
If pResource is not registered then cudaErrorInvalidResourceHandle is returned. If pResource was not registered
with usage flags cudaD3D9RegisterFlagsArray, then cudaErrorInvalidResourceHandle is returned. If pResource is
not mapped, then cudaErrorUnknown is returned.
For usage requirements of face and level parameters, see cudaD3D9ResourceGetMappedPointer().
Parameters:
ppArray - Returned array corresponding to subresource
pResource - Mapped resource to access
face - Face of resource to access
level - Level of resource to access
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cu-
daD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
Returns in ∗pPitch and ∗pPitchSlice the pitch and Z-slice pitch of the subresource of the mapped Direct3D
resource pResource, which corresponds to face and level. The values set in pPitch and pPitchSlice may
change every time that pResource is mapped.
The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.
For a 2D surface, the byte offset of the sample at position x, y from the base pointer of the surface is:
y ∗ pitch + (bytes per pixel) ∗ x
For a 3D surface, the byte offset of the sample at position x, y, z from the base pointer of the surface is:
z∗ slicePitch + y ∗ pitch + (bytes per pixel) ∗ x
Both parameters pPitch and pPitchSlice are optional and may be set to NULL.
If pResource is not of type IDirect3DBaseTexture9 or one of its sub-types or if pResource has not been registered
for use with CUDA, then cudaErrorInvalidResourceHandle is returned. If pResource was not registered with usage
flags cudaD3D9RegisterFlagsNone, then cudaErrorInvalidResourceHandle is returned. If pResource is not mapped
for access by CUDA then cudaErrorUnknown is returned.
For usage requirements of face and level parameters, see cudaD3D9ResourceGetMappedPointer().
Parameters:
pPitch - Returned pitch of subresource
pPitchSlice - Returned Z-slice pitch of subresource
pResource - Mapped resource to access
face - Face of resource to access
level - Level of resource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cu-
daD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags,
cudaD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedSize
Returns in ∗pPointer the base pointer of the subresource of the mapped Direct3D resource pResource, which
corresponds to face and level. The value set in pPointer may change every time that pResource is mapped.
If pResource is not registered, then cudaErrorInvalidResourceHandle is returned. If pResource was not registered
with usage flags cudaD3D9RegisterFlagsNone, then cudaErrorInvalidResourceHandle is returned. If pResource is
not mapped, then cudaErrorUnknown is returned.
If pResource is of type IDirect3DCubeTexture9, then face must one of the values enumerated by type
D3DCUBEMAP_FACES. For all other types, face must be 0. If face is invalid, then cudaErrorInvalidValue is
returned.
If pResource is of type IDirect3DBaseTexture9, then level must correspond to a valid mipmap level. Only
mipmap level 0 is supported for now. For all other types level must be 0. If level is invalid, then cudaErrorIn-
validValue is returned.
Parameters:
pPointer - Returned pointer corresponding to subresource
pResource - Mapped resource to access
face - Face of resource to access
level - Level of resource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cu-
daD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
Returns in ∗pSize the size of the subresource of the mapped Direct3D resource pResource, which corresponds to
face and level. The value set in pSize may change every time that pResource is mapped.
If pResource has not been registered for use with CUDA then cudaErrorInvalidResourceHandle is returned. If
pResource was not registered with usage flags cudaD3D9RegisterFlagsNone, then cudaErrorInvalidResourceHan-
dle is returned. If pResource is not mapped for access by CUDA then cudaErrorUnknown is returned.
For usage requirements of face and level parameters, see cudaD3D9ResourceGetMappedPointer().
Parameters:
pSize - Returned size of subresource
pResource - Mapped resource to access
face - Face of resource to access
level - Level of resource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cu-
daD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags,
cudaD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedPitch
Returns in ∗pWidth, ∗pHeight, and ∗pDepth the dimensions of the subresource of the mapped Direct3D resource
pResource which corresponds to face and level.
Because anti-aliased surfaces may have multiple samples per pixel, it is possible that the dimensions of a resource will
be an integer factor larger than the dimensions reported by the Direct3D runtime.
The parameters pWidth, pHeight, and pDepth are optional. For 2D surfaces, the value returned in ∗pDepth will
be 0.
If pResource is not of type IDirect3DBaseTexture9 or IDirect3DSurface9 or if pResource has not been registered
for use with CUDA, then cudaErrorInvalidResourceHandle is returned.
For usage requirements of face and level parameters, see cudaD3D9ResourceGetMappedPointer.
Parameters:
pWidth - Returned width of surface
pHeight - Returned height of surface
pDepth - Returned depth of surface
pResource - Registered resource to access
face - Face of resource to access
level - Level of resource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle,
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cu-
daD3D9UnmapResources, cudaD3D9ResourceSetMapFlags, cudaD3D9ResourceGetMappedArray, cu-
daD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
• cudaD3D9MapFlagsNone: Specifies no hints about how this resource will be used. It is therefore assumed that
this resource will be read from and written to by CUDA kernels. This is the default value.
• cudaD3D9MapFlagsReadOnly: Specifies that CUDA kernels which access this resource will not write to this
resource.
• cudaD3D9MapFlagsWriteDiscard: Specifies that CUDA kernels which access this resource will not read from
this resource and will write over the entire contents of the resource, so none of the data previously stored in the
resource will be preserved.
If pResource has not been registered for use with CUDA, then cudaErrorInvalidResourceHandle is returned. If
pResource is presently mapped for access by CUDA, then cudaErrorUnknown is returned.
Parameters:
pResource - Registered resource to set flags for
flags - Parameters for resource mapping
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources, cu-
daD3D9UnmapResources, cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceGetMappedArray,
cudaD3D9ResourceGetMappedPointer, cudaD3D9ResourceGetMappedSize, cu-
daD3D9ResourceGetMappedPitch
Records pDxDevice as the Direct3D device to use for Direct3D interoperability on this host thread. In order to
use Direct3D interoperability, this call must be made before any non-device management CUDA runtime calls on this
thread. In that case, this call will return cudaErrorSetOnActiveProcess.
Successful context creation on pDxDevice will increase the internal reference count on pDxDevice. This reference
count will be decremented upon destruction of this context through cudaThreadExit().
Parameters:
pDxDevice - Direct3D device to use for this thread
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorInvalidValue, cudaErrorSetOnActiveProcess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9GetDirect3DDevice, cudaD3D9RegisterResource, cu-
daD3D9UnregisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources,
cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
Parameters:
count - Number of resources to unmap for CUDA
ppResources - Resources to unmap for CUDA
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9UnregisterResource, cudaD3D9MapResources,
Unregisters the Direct3D resource pResource so it is not accessible by CUDA unless registered again.
If pResource is not registered, then cudaErrorInvalidResourceHandle is returned.
Parameters:
pResource - Resource to unregister
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D9GetDevice, cudaD3D9SetDirect3DDevice, cudaD3D9GetDirect3DDevice, cu-
daD3D9RegisterResource, cudaD3D9MapResources, cudaD3D9UnmapResources,
cudaD3D9ResourceGetSurfaceDimensions, cudaD3D9ResourceSetMapFlags, cu-
daD3D9ResourceGetMappedArray, cudaD3D9ResourceGetMappedPointer, cu-
daD3D9ResourceGetMappedSize, cudaD3D9ResourceGetMappedPitch
Author:
NVIDIA Corporation
• enum cudaD3D10MapFlags {
cudaD3D10MapFlagsNone,
cudaD3D10MapFlagsReadOnly,
cudaD3D10MapFlagsWriteDiscard }
• enum cudaD3D10RegisterFlags {
cudaD3D10RegisterFlagsNone,
cudaD3D10RegisterFlagsArray }
• cudaError_t cudaD3D10GetDevice (int ∗device, IDXGIAdapter ∗pAdapter)
Gets the device number for an adapter.
This section describes the Direct3D 10 interoperability functions of the CUDA runtime application programming
interface.
Enumerator:
cudaD3D10MapFlagsNone Default; Assume resource can be read/written.
cudaD3D10MapFlagsReadOnly CUDA kernels will not write to this resource.
cudaD3D10MapFlagsWriteDiscard CUDA kernels will only write to and will not read from this resource.
Enumerator:
cudaD3D10RegisterFlagsNone Default; Resource can be accessed through a void∗.
cudaD3D10RegisterFlagsArray Resource can be accessed through a CUarray∗.
Returns in ∗device the CUDA-compatible device corresponding to the adapter pAdapter obtained from IDXGI-
Factory::EnumAdapters. This call will succeed only if a device on adapter pAdapter is Cuda-compatible.
Parameters:
device - Returns the device corresponding to pAdapter
pAdapter - D3D10 adapter to get device for
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cudaD3D10UnregisterResource, cu-
daD3D10MapResources, cudaD3D10UnmapResources, cudaD3D10ResourceGetSurfaceDimensions,
cudaD3D10ResourceSetMapFlags, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
Parameters:
count - Number of resources to map for CUDA
ppResources - Resources to map for CUDA
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10UnmapResources, cudaD3D10ResourceGetSurfaceDimensions,
cudaD3D10ResourceSetMapFlags, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
This call is potentially high-overhead and should not be called every frame in interactive applications.
The type of pResource must be one of the following:
The flags argument specifies the mechanism through which CUDA will access the Direct3D resource. The following
values are allowed.
Not all Direct3D resources of the above types may be used for interoperability with CUDA. The following are some
limitations.
If Direct3D interoperability is not initialized on this context then cudaErrorInvalidDevice is returned. If pResource
is of incorrect type or is already registered then cudaErrorInvalidResourceHandle is returned. If pResource cannot
be registered then cudaErrorUnknown is returned.
Parameters:
pResource - Resource to register
flags - Parameters for resource registration
Returns:
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnk-
nown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10UnregisterResource, cu-
daD3D10MapResources, cudaD3D10UnmapResources, cudaD3D10ResourceGetSurfaceDimensions,
cudaD3D10ResourceSetMapFlags, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
Returns in ∗ppArray an array through which the subresource of the mapped Direct3D resource pResource which
corresponds to subResource may be accessed. The value set in ppArray may change every time that pResource
is mapped.
If pResource is not registered, then cudaErrorInvalidResourceHandle is returned. If pResource was not registered
with usage flags cudaD3D10RegisterFlagsArray, then cudaErrorInvalidResourceHandle is returned. If pResource
is not mapped then cudaErrorUnknown is returned.
For usage requirements of the subResource parameter, see cudaD3D10ResourceGetMappedPointer().
Parameters:
ppArray - Returned array corresponding to subresource
pResource - Mapped resource to access
subResource - Subresource of pResource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10MapResources, cudaD3D10UnmapResources,
cudaD3D10ResourceGetSurfaceDimensions, cudaD3D10ResourceSetMapFlags, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
Returns in ∗pPitch and ∗pPitchSlice the pitch and Z-slice pitch of the subresource of the mapped Direct3D
resource pResource, which corresponds to subResource. The values set in pPitch and pPitchSlice may
change every time that pResource is mapped.
The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.
For a 2D surface, the byte offset of the sample at position x, y from the base pointer of the surface is:
y ∗ pitch + (bytes per pixel) ∗ x
For a 3D surface, the byte offset of the sample at position x, y, z from the base pointer of the surface is:
z∗ slicePitch + y ∗ pitch + (bytes per pixel) ∗ x
Both parameters pPitch and pPitchSlice are optional and may be set to NULL.
If pResource is not of type ID3D10Texture1D, ID3D10Texture2D, or ID3D10Texture3D, or if pResource has
not been registered for use with CUDA, then cudaErrorInvalidResourceHandle is returned. If pResource was
not registered with usage flags cudaD3D10RegisterFlagsNone, then cudaErrorInvalidResourceHandle is returned. If
pResource is not mapped for access by CUDA then cudaErrorUnknown is returned.
For usage requirements of the subResource parameter see cudaD3D10ResourceGetMappedPointer().
Parameters:
pPitch - Returned pitch of subresource
pPitchSlice - Returned Z-slice pitch of subresource
pResource - Mapped resource to access
subResource - Subresource of pResource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10MapResources, cudaD3D10UnmapResources,
cudaD3D10ResourceGetSurfaceDimensions, cudaD3D10ResourceSetMapFlags, cu-
daD3D10ResourceGetMappedArray, cudaD3D10ResourceGetMappedPointer, cu-
daD3D10ResourceGetMappedSize
Returns in ∗pPointer the base pointer of the subresource of the mapped Direct3D resource pResource which
corresponds to subResource. The value set in pPointer may change every time that pResource is mapped.
If pResource is not registered, then cudaErrorInvalidResourceHandle is returned. If pResource was not registered
with usage flags cudaD3D9RegisterFlagsNone, then cudaErrorInvalidResourceHandle is returned. If pResource is
not mapped then cudaErrorUnknown is returned.
If pResource is of type ID3D10Buffer then subResource must be 0. If pResource is of any other type, then
the value of subResource must come from the subresource calculation in D3D10CalcSubResource().
Parameters:
pPointer - Returned pointer corresponding to subresource
pResource - Mapped resource to access
subResource - Subresource of pResource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10MapResources, cudaD3D10UnmapResources,
cudaD3D10ResourceGetSurfaceDimensions, cudaD3D10ResourceSetMapFlags, cu-
daD3D10ResourceGetMappedArray, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
Returns in ∗pSize the size of the subresource of the mapped Direct3D resource pResource which corresponds to
subResource. The value set in pSize may change every time that pResource is mapped.
If pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. If pResource
was not registered with usage flags cudaD3D10RegisterFlagsNone, then cudaErrorInvalidHandle is returned. If
pResource is not mapped for access by CUDA then cudaErrorUnknown is returned.
For usage requirements of the subResource parameter see cudaD3D10ResourceGetMappedPointer().
Parameters:
pSize - Returned size of subresource
pResource - Mapped resource to access
subResource - Subresource of pResource to access
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10MapResources, cudaD3D10UnmapResources,
cudaD3D10ResourceGetSurfaceDimensions, cudaD3D10ResourceSetMapFlags, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPitch
Returns in ∗pWidth, ∗pHeight, and ∗pDepth the dimensions of the subresource of the mapped Direct3D resource
pResource which corresponds to subResource.
Because anti-aliased surfaces may have multiple samples per pixel, it is possible that the dimensions of a resource will
be an integer factor larger than the dimensions reported by the Direct3D runtime.
The parameters pWidth, pHeight, and pDepth are optional. For 2D surfaces, the value returned in ∗pDepth will
be 0.
If pResource is not of type ID3D10Texture1D, ID3D10Texture2D, or ID3D10Texture3D, or if pResource has
not been registered for use with CUDA, then cudaErrorInvalidHandle is returned.
For usage requirements of subResource parameters see cudaD3D10ResourceGetMappedPointer().
Parameters:
pWidth - Returned width of surface
pHeight - Returned height of surface
pDepth - Returned depth of surface
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle,
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10MapResources, cudaD3D10UnmapResources,
cudaD3D10ResourceSetMapFlags, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
• cudaD3D10MapFlagsNone: Specifies no hints about how this resource will be used. It is therefore assumed that
this resource will be read from and written to by CUDA kernels. This is the default value.
• cudaD3D10MapFlagsReadOnly: Specifies that CUDA kernels which access this resource will not write to this
resource.
• cudaD3D10MapFlagsWriteDiscard: Specifies that CUDA kernels which access this resource will not read from
this resource and will write over the entire contents of the resource, so none of the data previously stored in the
resource will be preserved.
If pResource has not been registered for use with CUDA then cudaErrorInvalidHandle is returned. If pResource
is presently mapped for access by CUDA then cudaErrorUnknown is returned.
Parameters:
pResource - Registered resource to set flags for
flags - Parameters for resource mapping
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown,
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10MapResources, cudaD3D10UnmapResources,
cudaD3D10ResourceGetSurfaceDimensions, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
Records pDxDevice as the Direct3D device to use for Direct3D interoperability on this host thread. In order to
use Direct3D interoperability, this call must be made before any non-device management CUDA runtime calls on this
thread. In that case, this call will return cudaErrorSetOnActiveProcess.
Successful context creation on pDxDevice will increase the internal reference count on pDxDevice. This reference
count will be decremented upon destruction of this context through cudaThreadExit().
Parameters:
pDxDevice - Direct3D device to use for interoperability
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorInvalidValue, cudaErrorSetOnActiveProcess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10RegisterResource, cudaD3D10UnregisterResource, cu-
daD3D10MapResources, cudaD3D10UnmapResources, cudaD3D10ResourceGetSurfaceDimensions,
cudaD3D10ResourceSetMapFlags, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
Parameters:
count - Number of resources to unmap for CUDA
ppResources - Resources to unmap for CUDA
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10UnregisterResource, cudaD3D10MapResources, cudaD3D10ResourceGetSurfaceDimensions,
Unregisters the Direct3D resource resource so it is not accessible by CUDA unless registered again.
If pResource is not registered, then cudaErrorInvalidResourceHandle is returned.
Parameters:
pResource - Resource to unregister
Returns:
cudaSuccess, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaD3D10GetDevice, cudaD3D10SetDirect3DDevice, cudaD3D10RegisterResource, cu-
daD3D10MapResources, cudaD3D10UnmapResources, cudaD3D10ResourceGetSurfaceDimensions,
cudaD3D10ResourceSetMapFlags, cudaD3D10ResourceGetMappedArray, cu-
daD3D10ResourceGetMappedPointer, cudaD3D10ResourceGetMappedSize, cu-
daD3D10ResourceGetMappedPitch
Functions
• cudaError_t cudaBindTexture (size_t ∗offset, const struct textureReference ∗texref, const void ∗devPtr, const
struct cudaChannelFormatDesc ∗desc, size_t size)
Binds a memory area to a texture.
• cudaError_t cudaBindTexture2D (size_t ∗offset, const struct textureReference ∗texref, const void ∗devPtr, const
struct cudaChannelFormatDesc ∗desc, size_t width, size_t height, size_t pitch)
Binds a 2D memory area to a texture.
• cudaError_t cudaBindTextureToArray (const struct textureReference ∗texref, const struct cudaArray ∗array,
const struct cudaChannelFormatDesc ∗desc)
Binds an array to a texture.
This section describes the low level texture reference management functions of the CUDA runtime application pro-
gramming interface.
3.12.2.1 cudaError_t cudaBindTexture (size_t ∗ offset, const struct textureReference ∗ texref, const void ∗
devPtr, const struct cudaChannelFormatDesc ∗ desc, size_t size)
Binds size bytes of the memory area pointed to by devPtr to the texture reference texref. desc describes
how the memory is interpreted when fetching values from the texture. Any memory previously bound to texref is
unbound.
Since the hardware enforces an alignment requirement on texture base addresses, cudaBindTexture() returns in
∗offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This off-
set must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the
tex1Dfetch() function. If the device memory pointer was returned from cudaMalloc(), the offset is guaranteed to be 0
and NULL may be passed as the offset parameter.
Parameters:
offset - Offset in bytes
texref - Texture to bind
devPtr - Memory area on device
desc - Channel format
size - Size of the memory area pointed to by devPtr
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C++ API),
cudaBindTexture2D (C API), cudaBindTextureToArray (C API), cudaUnbindTexture (C API), cudaGetTexture-
AlignmentOffset (C API)
3.12.2.2 cudaError_t cudaBindTexture2D (size_t ∗ offset, const struct textureReference ∗ texref, const void
∗ devPtr, const struct cudaChannelFormatDesc ∗ desc, size_t width, size_t height, size_t pitch)
Binds the 2D memory area pointed to by devPtr to the texture reference texref. The size of the area is constrained
by width in texel units, height in texel units, and pitch in byte units. desc describes how the memory is
interpreted when fetching values from the texture. Any memory previously bound to texref is unbound.
Since the hardware enforces an alignment requirement on texture base addresses, cudaBindTexture2D() returns in
∗offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This offset
must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex2D()
function. If the device memory pointer was returned from cudaMalloc(), the offset is guaranteed to be 0 and NULL
may be passed as the offset parameter.
Parameters:
offset - Offset in bytes
texref - Texture reference to bind
devPtr - 2D memory area on device
desc - Channel format
width - Width in texel units
height - Height in texel units
pitch - Pitch in bytes
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C API),
cudaBindTexture2D (C++ API), cudaBindTextureToArray (C API), cudaBindTextureToArray (C API), cudaGet-
TextureAlignmentOffset (C API)
Binds the CUDA array array to the texture reference texref. desc describes how the memory is interpreted when
fetching values from the texture. Any CUDA array previously bound to texref is unbound.
Parameters:
texref - Texture to bind
array - Memory array on device
desc - Channel format
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C API),
cudaBindTexture2D (C API), cudaBindTextureToArray (C++ API), cudaUnbindTexture (C API), cudaGetTex-
tureAlignmentOffset (C API)
Returns a channel descriptor with format f and number of bits of each component x, y, z, and w. The cudaChan-
nelFormatDesc is defined as:
struct cudaChannelFormatDesc {
int x, y, z, w;
enum cudaChannelFormatKind f;
};
Parameters:
x - X component
y - Y component
z - Z component
w - W component
f - Channel format
Returns:
Channel descriptor with format f
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C API),
cudaBindTexture2D (C API), cudaBindTextureToArray (C API), cudaUnbindTexture (C API), cudaGetTexture-
AlignmentOffset (C API)
Parameters:
desc - Channel format
array - Memory array on device
Returns:
cudaSuccess, cudaErrorInvalidValue
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C API), cudaGetTextureReference, cudaBindTexture (C API), cudaBindTexture2D (C
API), cudaBindTextureToArray (C API), cudaUnbindTexture (C API), cudaGetTextureAlignmentOffset (C API)
Returns in ∗offset the offset that was returned when texture reference texref was bound.
Parameters:
offset - Offset of texture reference in bytes
texref - Texture to get offset of
Returns:
cudaSuccess, cudaErrorInvalidTexture, cudaErrorInvalidTextureBinding
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C API),
cudaBindTexture2D (C API), cudaBindTextureToArray (C API), cudaUnbindTexture (C API), cudaGetTexture-
AlignmentOffset (C++ API)
Returns in ∗texref the structure associated to the texture reference defined by symbol symbol.
Parameters:
texref - Texture associated with symbol
symbol - Symbol to find texture reference for
Returns:
cudaSuccess, cudaErrorInvalidTexture,
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C API), cudaGetChannelDesc, cudaGetTextureAlignmentOffset (C API), cudaBind-
Texture (C API), cudaBindTexture2D (C API), cudaBindTextureToArray (C API), cudaUnbindTexture (C API)
Parameters:
texref - Texture to unbind
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C API),
cudaBindTexture2D (C API), cudaBindTextureToArray (C API), cudaUnbindTexture (C++ API), cudaGetTex-
tureAlignmentOffset (C API)
Functions
• cudaError_t cudaDriverGetVersion (int ∗driverVersion)
Returns the CUDA driver version.
Returns in ∗driverVersion the version number of the installed CUDA driver. If no driver is installed, then 0 is
returned as the driver version (via driverVersion). This function automatically returns cudaErrorInvalidValue if
the driverVersion argument is NULL.
Parameters:
driverVersion - Returns the CUDA driver version.
Returns:
cudaSuccess, cudaErrorInvalidValue
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaRuntimeGetVersion
Returns in ∗runtimeVersion the version number of the installed CUDA Runtime. This function automatically
returns cudaErrorInvalidValue if the runtimeVersion argument is NULL.
Parameters:
runtimeVersion - Returns the CUDA Runtime version.
Returns:
cudaSuccess, cudaErrorInvalidValue
See also:
cudaDriverGetVersion
Functions
• template<class T , int dim, enum cudaTextureReadMode readMode>
cudaError_t cudaBindTexture (size_t ∗offset, const struct texture< T, dim, readMode > &tex, const void
∗devPtr, size_t size=UINT_MAX)
[C++ API] Binds a memory area to a texture
• template<class T >
cudaChannelFormatDesc cudaCreateChannelDesc (void)
[C++ API] Returns a channel descriptor using the specified format
• template<class T >
cudaError_t cudaFuncGetAttributes (struct cudaFuncAttributes ∗attr, T ∗entry)
[C++ API] Find out attributes for a given function
• template<class T >
cudaError_t cudaGetSymbolAddress (void ∗∗devPtr, const T &symbol)
[C++ API] Finds the address associated with a CUDA symbol
• template<class T >
cudaError_t cudaGetSymbolSize (size_t ∗size, const T &symbol)
[C++ API] Finds the size of the object associated with a CUDA symbol
• template<class T >
cudaError_t cudaLaunch (T ∗entry)
[C++ API] Launches a device function
• template<class T >
cudaError_t cudaSetupArgument (T arg, size_t offset)
[C++ API] Configure a device launch
This section describes the C++ high level API functions of the CUDA runtime application programming interface. To
use these functions, your application needs to be compiled with the nvcc compiler.
Binds size bytes of the memory area pointed to by devPtr to texture reference tex. The channel descriptor is
inherited from the texture reference type. The offset parameter is an optional byte offset as with the low-level
cudaBindTexture(size_t∗, const struct textureReference∗, const void∗, const struct cudaChannelFormatDesc∗, size_t)
function. Any memory previously bound to tex is unbound.
Parameters:
offset - Offset in bytes
tex - Texture to bind
devPtr - Memory area on device
size - Size of the memory area pointed to by devPtr
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C API),
cudaBindTexture (C++ API, inherited channel descriptor), cudaBindTexture2D (C++ API), cudaBindTexture-
ToArray (C++ API), cudaBindTextureToArray (C++ API, inherited channel descriptor), cudaUnbindTexture (C++
API), cudaGetTextureAlignmentOffset (C++ API)
Binds size bytes of the memory area pointed to by devPtr to texture reference tex. desc describes how the
memory is interpreted when fetching values from the texture. The offset parameter is an optional byte offset as
with the low-level cudaBindTexture() function. Any memory previously bound to tex is unbound.
Parameters:
offset - Offset in bytes
tex - Texture to bind
devPtr - Memory area on device
desc - Channel format
size - Size of the memory area pointed to by devPtr
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C API),
cudaBindTexture (C++ API, inherited channel descriptor), cudaBindTexture2D (C++ API), cudaBindTexture-
ToArray (C++ API), cudaBindTextureToArray (C++ API, inherited channel descriptor), cudaUnbindTexture (C++
API), cudaGetTextureAlignmentOffset (C++ API)
Binds the 2D memory area pointed to by devPtr to the texture reference tex. The size of the area is constrained by
width in texel units, height in texel units, and pitch in byte units. desc describes how the memory is interpreted
when fetching values from the texture. Any memory previously bound to tex is unbound.
Since the hardware enforces an alignment requirement on texture base addresses, cudaBindTexture2D() returns in
∗offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This offset
must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex2D()
function. If the device memory pointer was returned from cudaMalloc(), the offset is guaranteed to be 0 and NULL
may be passed as the offset parameter.
Parameters:
offset - Offset in bytes
tex - Texture reference to bind
devPtr - 2D memory area on device
desc - Channel format
width - Width in texel units
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C++
API), cudaBindTexture (C++ API, inherited channel descriptor), cudaBindTexture2D (C API), cudaBindTex-
tureToArray (C++ API), cudaBindTextureToArray (C++ API, inherited channel descriptor), cudaUnbindTexture
(C++ API), cudaGetTextureAlignmentOffset (C++ API)
Binds the CUDA array array to the texture reference tex. The channel descriptor is inherited from the CUDA array.
Any CUDA array previously bound to tex is unbound.
Parameters:
tex - Texture to bind
array - Memory array on device
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C++
API), cudaBindTexture (C++ API, inherited channel descriptor), cudaBindTexture2D (C++ API), cudaBind-
TextureToArray (C API), cudaBindTextureToArray (C++ API), cudaUnbindTexture (C++ API), cudaGetTexture-
AlignmentOffset (C++ API)
Binds the CUDA array array to the texture reference tex. desc describes how the memory is interpreted when
fetching values from the texture. Any CUDA array previously bound to tex is unbound.
Parameters:
tex - Texture to bind
Returns:
cudaSuccess, cudaErrorInvalidValue, cudaErrorInvalidDevicePointer, cudaErrorInvalidTexture
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C++
API), cudaBindTexture (C++ API, inherited channel descriptor), cudaBindTexture2D (C++ API), cudaBind-
TextureToArray (C API), cudaBindTextureToArray (C++ API, inherited channel descriptor), cudaUnbindTexture
(C++ API), cudaGetTextureAlignmentOffset (C++ API)
Returns a channel descriptor with format f and number of bits of each component x, y, z, and w. The cudaChan-
nelFormatDesc is defined as:
struct cudaChannelFormatDesc {
int x, y, z, w;
enum cudaChannelFormatKind f;
};
Returns:
Channel descriptor with format f
See also:
cudaCreateChannelDesc (Low level), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (High
level), cudaBindTexture (High level, inherited channel descriptor), cudaBindTexture2D (High level), cudaBind-
TextureToArray (High level), cudaBindTextureToArray (High level, inherited channel descriptor), cudaUnbind-
Texture (High level), cudaGetTextureAlignmentOffset (High level)
This function obtains the attributes of a function specified via entry. The parameter entry can either be a function
that executes on the device, or it can be a character string, naming a function that executes on the device. The parameter
specified by entry must be declared as a __global__ function. The fetched attributes are placed in attr. If the
specified function does not exist, then cudaErrorInvalidDeviceFunction is returned.
Parameters:
attr - Return pointer to function’s attributes
entry - Function to get attributes of
Returns:
cudaSuccess, cudaErrorInitializationError, cudaErrorInvalidDeviceFunction
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C API), cudaLaunch (C++ API), cudaSetDoubleForDevice, cudaSet-
DoubleForHost, cudaSetupArgument (C++ API)
3.14.2.8 template<class T > cudaError_t cudaGetSymbolAddress (void ∗∗ devPtr, const T & symbol)
Returns in ∗devPtr the address of symbol symbol on the device. symbol can either be a variable that resides
in global memory space, or it can be a character string, naming a variable that resides in global memory space. If
symbol cannot be found, or if symbol is not declared in the global memory space, ∗devPtr is unchanged and the
error cudaErrorInvalidSymbol is returned.
Parameters:
devPtr - Return device pointer associated with symbol
symbol - Global variable or string symbol to search for
Returns:
cudaSuccess, cudaErrorInvalidSymbol, cudaErrorAddressOfConstant
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetSymbolAddress (C API) cudaGetSymbolSize (C++ API)
3.14.2.9 template<class T > cudaError_t cudaGetSymbolSize (size_t ∗ size, const T & symbol)
Returns in ∗size the size of symbol symbol. symbol can either be a variable that resides in global or constant
memory space, or it can be a character string, naming a variable that resides in global or constant memory space. If
symbol cannot be found, or if symbol is not declared in global or constant memory space, ∗size is unchanged
and the error cudaErrorInvalidSymbol is returned.
Parameters:
size - Size of object associated with symbol
symbol - Global variable or string symbol to find size of
Returns:
cudaSuccess, cudaErrorInvalidSymbol
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGetSymbolAddress (C++ API) cudaGetSymbolSize (C API)
Returns in ∗offset the offset that was returned when texture reference tex was bound.
Parameters:
offset - Offset of texture reference in bytes
tex - Texture to get offset of
Returns:
cudaSuccess, cudaErrorInvalidTexture, cudaErrorInvalidTextureBinding
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C++
API), cudaBindTexture (C++ API, inherited channel descriptor), cudaBindTexture2D (C++ API), cudaBindTex-
tureToArray (C++ API), cudaBindTextureToArray (C++ API, inherited channel descriptor), cudaUnbindTexture
(C++ API), cudaGetTextureAlignmentOffset (C API)
Launches the function entry on the device. The parameter entry can either be a function that executes on the
device, or it can be a character string, naming a function that executes on the device. The parameter specified by entry
must be declared as a __global__ function. cudaLaunch() must be preceded by a call to cudaConfigureCall() since
it pops the data that was pushed by cudaConfigureCall() from the execution stack.
Parameters:
entry - Device function pointer or char string naming device function to execute
Returns:
cudaSuccess, cudaErrorInvalidDeviceFunction, cudaErrorInvalidConfiguration, cudaErrorLaunchFailure, cud-
aErrorPriorLaunchFailure, cudaErrorLaunchTimeout, cudaErrorLaunchOutOfResources
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C++ API), cudaLaunch (C API), cudaSetDoubleForDevice, cudaSet-
DoubleForHost, cudaSetupArgument (C++ API)
Pushes size bytes of the argument pointed to by arg at offset bytes from the start of the parameter passing area,
which starts at offset 0. The arguments are stored in the top of the execution stack. cudaSetupArgument() must be
preceded by a call to cudaConfigureCall().
Parameters:
arg - Argument to push for a kernel launch
offset - Offset in argument stack to push new arg
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaConfigureCall, cudaFuncGetAttributes (C++ API), cudaLaunch (C++ API), cudaSetDoubleForDevice, cud-
aSetDoubleForHost, cudaSetupArgument (C API)
Parameters:
tex - Texture to unbind
Returns:
cudaSuccess
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaCreateChannelDesc (C++ API), cudaGetChannelDesc, cudaGetTextureReference, cudaBindTexture (C++
API), cudaBindTexture (C++ API, inherited channel descriptor), cudaBindTexture2D (C++ API), cudaBindTex-
tureToArray (C++ API), cudaBindTextureToArray (C++ API, inherited channel descriptor), cudaUnbindTexture
(C API), cudaGetTextureAlignmentOffset (C++ API)
Data Structures
• struct cudaChannelFormatDesc
• struct cudaDeviceProp
• struct cudaExtent
• struct cudaFuncAttributes
• struct cudaMemcpy3DParms
• struct cudaPitchedPtr
• struct cudaPos
Author:
NVIDIA Corporation
• enum cudaChannelFormatKind {
cudaChannelFormatKindSigned,
cudaChannelFormatKindUnsigned,
cudaChannelFormatKindFloat,
cudaChannelFormatKindNone }
• enum cudaComputeMode {
cudaComputeModeDefault,
cudaComputeModeExclusive,
cudaComputeModeProhibited }
• enum cudaError {
cudaSuccess,
cudaErrorMissingConfiguration,
cudaErrorMemoryAllocation,
cudaErrorInitializationError,
cudaErrorLaunchFailure,
cudaErrorPriorLaunchFailure,
cudaErrorLaunchTimeout,
cudaErrorLaunchOutOfResources,
cudaErrorInvalidDeviceFunction,
cudaErrorInvalidConfiguration,
cudaErrorInvalidDevice,
cudaErrorInvalidValue,
cudaErrorInvalidPitchValue,
cudaErrorInvalidSymbol,
cudaErrorMapBufferObjectFailed,
cudaErrorUnmapBufferObjectFailed,
cudaErrorInvalidHostPointer,
cudaErrorInvalidDevicePointer,
cudaErrorInvalidTexture,
cudaErrorInvalidTextureBinding,
cudaErrorInvalidChannelDescriptor,
cudaErrorInvalidMemcpyDirection,
cudaErrorAddressOfConstant,
cudaErrorTextureFetchFailed,
cudaErrorTextureNotBound,
cudaErrorSynchronizationError,
cudaErrorInvalidFilterSetting,
cudaErrorInvalidNormSetting,
cudaErrorMixedDeviceExecution,
cudaErrorCudartUnloading,
cudaErrorUnknown,
cudaErrorNotYetImplemented,
cudaErrorMemoryValueTooLarge,
cudaErrorInvalidResourceHandle,
cudaErrorNotReady,
cudaErrorInsufficientDriver,
cudaErrorSetOnActiveProcess,
cudaErrorNoDevice,
cudaErrorStartupFailure,
cudaErrorApiFailureBase }
• enum cudaMemcpyKind {
cudaMemcpyHostToHost,
cudaMemcpyHostToDevice,
cudaMemcpyDeviceToHost,
cudaMemcpyDeviceToDevice }
• typedef enum cudaError cudaError_t
• typedef int cudaEvent_t
• typedef int cudaStream_t
• #define cudaDeviceBlockingSync
Device flag - Use blocking synchronization.
• #define cudaDeviceMapHost
Device flag - Support mapped pinned allocations.
• #define cudaDeviceMask
Device flags mask.
• #define cudaDevicePropDontCare
Empty device properties.
• #define cudaDeviceScheduleAuto
Device flag - Automatic scheduling.
• #define cudaDeviceScheduleSpin
Device flag - Spin default scheduling.
• #define cudaDeviceScheduleYield
Device flag - Yield default scheduling.
• #define cudaEventBlockingSync
Event uses blocking synchronization.
• #define cudaEventDefault
Default event flag.
• #define cudaHostAllocDefault
Default page-locked allocation flag.
• #define cudaHostAllocMapped
Map allocation into device space.
• #define cudaHostAllocPortable
Pinned memory accessible by all CUDA contexts.
• #define cudaHostAllocWriteCombined
Write-combined memory.
CUDA stream
Enumerator:
cudaChannelFormatKindSigned Signed channel format.
cudaChannelFormatKindUnsigned Unsigned channel format.
cudaChannelFormatKindFloat Float channel format.
cudaChannelFormatKindNone No channel format.
Enumerator:
cudaComputeModeDefault Default compute mode (Multiple threads can use cudaSetDevice() with this device).
cudaComputeModeExclusive Compute-exclusive mode (Only one thread will be able to use cudaSetDevice()
with this device).
cudaComputeModeProhibited Compute-prohibited mode (No threads can use cudaSetDevice() with this de-
vice).
Enumerator:
cudaSuccess No errors.
cudaErrorMissingConfiguration Missing configuration error.
cudaErrorMemoryAllocation Memory allocation error.
cudaErrorInitializationError Initialization error.
cudaErrorLaunchFailure Launch failure.
cudaErrorPriorLaunchFailure Prior launch failure.
cudaErrorLaunchTimeout Launch timeout error.
cudaErrorLaunchOutOfResources Launch out of resources error.
cudaErrorInvalidDeviceFunction Invalid device function.
cudaErrorInvalidConfiguration Invalid configuration.
cudaErrorInvalidDevice Invalid device.
cudaErrorInvalidValue Invalid value.
cudaErrorInvalidPitchValue Invalid pitch value.
cudaErrorInvalidSymbol Invalid symbol.
cudaErrorMapBufferObjectFailed Map buffer object failed.
cudaErrorUnmapBufferObjectFailed Unmap buffer object failed.
cudaErrorInvalidHostPointer Invalid host pointer.
cudaErrorInvalidDevicePointer Invalid device pointer.
cudaErrorInvalidTexture Invalid texture.
cudaErrorInvalidTextureBinding Invalid texture binding.
Enumerator:
cudaMemcpyHostToHost Host -> Host.
cudaMemcpyHostToDevice Host -> Device.
cudaMemcpyDeviceToHost Device -> Host.
cudaMemcpyDeviceToDevice Device -> Device.
Modules
• Initialization
• Device Management
• Version Management
• Context Management
• Module Management
• Stream Management
• Event Management
• Execution Control
• Memory Management
• Texture Reference Management
• OpenGL Interoperability
• Direct3D 9 Interoperability
• Direct3D 10 Interoperability
• Data types used by CUDA driver
This section describes the low-level CUDA driver application programming interface.
3.17 Initialization
Functions
• CUresult cuInit (unsigned int Flags)
Initialize the CUDA driver API.
This section describes the initialization functions of the low-level CUDA driver application programming interface.
Initializes the driver API and must be called before any other function from the driver API. Currently, the Flags
parameter must be 0. If cuInit() has not been called, any function from the driver API will return CUDA_ERROR_-
NOT_INITIALIZED.
Parameters:
Flags - Initialization flag for CUDA.
Returns:
CUDA_SUCCESS, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
Functions
• CUresult cuDeviceComputeCapability (int ∗major, int ∗minor, CUdevice dev)
Returns the compute capability of the device.
This section describes the device management functions of the low-level CUDA driver application programming in-
terface.
Returns in ∗major and ∗minor the major and minor revision numbers that define the compute capability of the
device dev.
Parameters:
major - Major revision number
minor - Minor revision number
dev - Device handle
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuDeviceGetAttribute, cuDeviceGetCount, cuDeviceGetName, cuDeviceGet, cuDeviceGetProperties, cuDevice-
TotalMem
Returns in ∗device a device handle given an ordinal in the range [0, cuDeviceGetCount()-1].
Parameters:
device - Returned device handle
ordinal - Device number to get handle for
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuDeviceComputeCapability, cuDeviceGetAttribute, cuDeviceGetCount, cuDeviceGetName, cuDeviceGetProp-
erties, cuDeviceTotalMem
Returns in ∗pi the integer value of the attribute attrib on device dev. The supported attributes are:
– CU_COMPUTEMODE_DEFAULT: Default mode - Device is not restricted and can have multiple CUDA
contexts present at a single time.
– CU_COMPUTEMODE_EXCLUSIVE: Compute-exclusive mode - Device can have only one CUDA con-
text present on it at a time.
– CU_COMPUTEMODE_PROHIBITED: Compute-prohibited mode - Device is prohibited from creating
new CUDA contexts.
Parameters:
pi - Returned device attribute value
attrib - Device attribute to query
dev - Device handle
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuDeviceComputeCapability, cuDeviceGetCount, cuDeviceGetName, cuDeviceGet, cuDeviceGetProperties,
cuDeviceTotalMem
Returns in ∗count the number of devices with compute capability greater than or equal to 1.0 that are available for
execution. If there is no such device, cuDeviceGetCount() returns 0.
Parameters:
count - Returned number of compute-capable devices
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuDeviceComputeCapability, cuDeviceGetAttribute, cuDeviceGetName, cuDeviceGet, cuDeviceGetProperties,
cuDeviceTotalMem
Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by name. len specifies
the maximum length of the string that may be returned.
Parameters:
name - Returned identifier string for the device
len - Maximum length of string to store in name
dev - Device to get identifier string for
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuDeviceComputeCapability, cuDeviceGetAttribute, cuDeviceGetCount, cuDeviceGet, cuDeviceGetProperties,
cuDeviceTotalMem
Returns in ∗prop the properties of device dev. The CUdevprop structure is defined as:
where:
• sharedMemPerBlock is the total amount of shared memory available per block in bytes;
• totalConstantMemory is the total amount of constant memory available on the device in bytes;
• memPitch is the maximum pitch allowed by the memory copy functions that involve memory regions allocated
through cuMemAllocPitch();
• textureAlign is the alignment requirement; texture base addresses that are aligned to textureAlign bytes do not
need an offset applied to texture fetches.
Parameters:
prop - Returned properties of device
dev - Device to get properties for
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuDeviceComputeCapability, cuDeviceGetAttribute, cuDeviceGetCount, cuDeviceGetName, cuDeviceGet, cuD-
eviceTotalMem
Returns in ∗bytes the total amount of memory available on the device dev in bytes.
Parameters:
bytes - Returned memory available on device in bytes
dev - Device handle
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuDeviceComputeCapability, cuDeviceGetAttribute, cuDeviceGetCount, cuDeviceGetName, cuDeviceGet, cuD-
eviceGetProperties,
Functions
• CUresult cuDriverGetVersion (int ∗driverVersion)
Returns the CUDA driver version.
This section describes the version management functions of the low-level CUDA driver application programming
interface.
Returns in ∗driverVersion the version number of the installed CUDA driver. This function automatically returns
CUDA_ERROR_INVALID_VALUE if the driverVersion argument is NULL.
Parameters:
driverVersion - Returns the CUDA driver version
Returns:
CUDA_SUCCESS, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
Functions
This section describes the context management functions of the low-level CUDA driver application programming
interface.
Increments the usage count of the context and passes back a context handle in ∗pctx that must be passed to cuC-
txDetach() when the application is done with the context. cuCtxAttach() fails if there is no context current to the
thread.
Currently, the flags parameter must be 0.
Parameters:
pctx - Returned context handle of the current context
flags - Context attach flags (must be 0)
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxCreate, cuCtxDestroy, cuCtxDetach, cuCtxGetDevice, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSyn-
chronize
Creates a new CUDA context and associates it with the calling thread. The flags parameter is described below. The
context is created with a usage count of 1 and the caller of cuCtxCreate() must call cuCtxDestroy() or cuCtxDetach()
when done using the context. If a context is already current to the thread, it is supplanted by the newly created context
and may be restored by a subsequent call to cuCtxPopCurrent().
The two LSBs of the flags parameter can be used to control how the OS thread, which owns the CUDA context at
the time of an API call, interacts with the OS scheduler when waiting for results from the GPU.
• CU_CTX_SCHED_AUTO: The default value if the flags parameter is zero, uses a heuristic based on the
number of active CUDA contexts in the process C and the number of logical processors in the system P. If C >
P, then CUDA will yield to other OS threads when waiting for the GPU, otherwise CUDA will not yield while
waiting for results and actively spin on the processor.
• CU_CTX_SCHED_SPIN: Instruct CUDA to actively spin when waiting for results from the GPU. This can de-
crease latency when waiting for the GPU, but may lower the performance of CPU threads if they are performing
work in parallel with the CUDA thread.
• CU_CTX_SCHED_YIELD: Instruct CUDA to yield its thread when waiting for results from the GPU. This can
increase latency when waiting for the GPU, but can increase the performance of CPU threads performing work
in parallel with the GPU.
• CU_CTX_BLOCKING_SYNC: Instruct CUDA to block the CPU thread on a synchronization primitive when
waiting for the GPU to finish work.
• CU_CTX_MAP_HOST: Instruct CUDA to support mapped pinned allocations. This flag must be set in order
to allocate pinned host memory that is accessible to the GPU.
Parameters:
pctx - Returned context handle of the new context
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_DEVICE, CUDA_ERROR_INVALID_VALUE,
CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxAttach, cuCtxDestroy, cuCtxDetach, cuCtxGetDevice, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSyn-
chronize
Destroys the CUDA context specified by ctx. If the context usage count is not equal to 1, or the context is current
to any CPU thread other than the current one, this function fails. Floating contexts (detached from a CPU thread via
cuCtxPopCurrent()) may be destroyed by this function.
Parameters:
ctx - Context to destroy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxAttach, cuCtxCreate, cuCtxDetach, cuCtxGetDevice, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSynchro-
nize
Decrements the usage count of the context ctx, and destroys the context if the usage count goes to 0. The context
must be a handle that was passed back by cuCtxCreate() or cuCtxAttach(), and must be current to the calling thread.
Parameters:
ctx - Context to destroy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxAttach, cuCtxCreate, cuCtxDestroy, cuCtxGetDevice, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSyn-
chronize
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxAttach, cuCtxCreate, cuCtxDestroy, cuCtxDetach, cuCtxPopCurrent, cuCtxPushCurrent, cuCtxSynchro-
nize
Pops the current CUDA context from the CPU thread. The CUDA context must have a usage count of 1. CUDA con-
texts have a usage count of 1 upon creation; the usage count may be incremented with cuCtxAttach() and decremented
with cuCtxDetach().
If successful, cuCtxPopCurrent() passes back the new context handle in ∗pctx. The old context may then be made
current to a different CPU thread by calling cuCtxPushCurrent().
Floating contexts may be destroyed by calling cuCtxDestroy().
If a context was current to the CPU thread before cuCtxCreate() or cuCtxPushCurrent() was called, this function makes
that context current to the CPU thread again.
Parameters:
pctx - Returned new context handle
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxAttach, cuCtxCreate, cuCtxDestroy, cuCtxDetach, cuCtxGetDevice, cuCtxPushCurrent, cuCtxSynchronize
Pushes the given context ctx onto the CPU thread’s stack of current contexts. The specified context becomes the
CPU thread’s current context, so all CUDA functions that operate on the current context are affected.
The previous current context may be made current again by calling cuCtxDestroy() or cuCtxPopCurrent().
The context must be "floating," i.e. not attached to any thread. Contexts are made to float by calling cuCtxPopCur-
rent().
Parameters:
ctx - Floating context to attach
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxAttach, cuCtxCreate, cuCtxDestroy, cuCtxDetach, cuCtxGetDevice, cuCtxPopCurrent, cuCtxSynchronize
Blocks until the device has completed all preceding requested tasks. cuCtxSynchronize() returns an error if one of the
preceding tasks failed.
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxAttach, cuCtxCreate, cuCtxDestroy, cuCtxDetach, cuCtxGetDevice, cuCtxPopCurrent, cuCtxSynchronize
Functions
• CUresult cuModuleGetFunction (CUfunction ∗hfunc, CUmodule hmod, const char ∗name)
Returns a function handle.
• CUresult cuModuleGetGlobal (CUdeviceptr ∗dptr, unsigned int ∗bytes, CUmodule hmod, const char ∗name)
Returns a global pointer from a module.
• CUresult cuModuleLoadDataEx (CUmodule ∗module, const void ∗image, unsigned int numOptions, CUjit_-
option ∗options, void ∗∗optionValues)
Load a module’s data with options.
This section describes the module management functions of the low-level CUDA driver application programming
interface.
Returns in ∗hfunc the handle of the function of name name located in module hmod. If no function of that name
exists, cuModuleGetFunction() returns CUDA_ERROR_NOT_FOUND.
Parameters:
hfunc - Returned function handle
hmod - Module to retrieve function from
name - Name of function to retrieve
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_NOT_FOUND
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetGlobal, cuModuleGetTexRef, cuModuleLoad, cuModuleLoadData, cuModuleLoadDataEx, cu-
ModuleLoadFatBinary, cuModuleUnload
3.21.2.2 cuModuleGetGlobal (CUdeviceptr ∗ dptr, unsigned int ∗ bytes, CUmodule hmod, const char ∗
name)
Returns in ∗dptr and ∗bytes the base pointer and size of the global of name name located in module hmod. If no
variable of that name exists, cuModuleGetGlobal() returns CUDA_ERROR_NOT_FOUND. Both parameters dptr
and bytes are optional. If one of them is NULL, it is ignored.
Parameters:
dptr - Returned global device pointer
bytes - Returned global size in bytes
hmod - Module to retrieve function from
name - Name of global to retrieve
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_NOT_FOUND
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetFunction, cuModuleGetTexRef, cuModuleLoad, cuModuleLoadData, cuModuleLoadDataEx, cu-
ModuleLoadFatBinary, cuModuleUnload
Returns in ∗pTexRef the handle of the texture reference of name name in the module hmod. If no texture reference
of that name exists, cuModuleGetTexRef() returns CUDA_ERROR_NOT_FOUND. This texture reference handle
should not be destroyed, since it will be destroyed when the module is unloaded.
Parameters:
pTexRef - Returned global device pointer
hmod - Module to retrieve texture-reference from
name - Name of texture-reference to retrieve
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_NOT_FOUND
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetFunction, cuModuleGetGlobal, cuModuleLoad, cuModuleLoadData, cuModuleLoadDataEx, cu-
ModuleLoadFatBinary, cuModuleUnload
Takes a filename fname and loads the corresponding module module into the current context. The CUDA driver API
does not attempt to lazily allocate the resources needed by a module; if the memory for functions and data (constant
and global) needed by the module cannot be allocated, cuModuleLoad() fails. The file should be a cubin file as output
by nvcc or a PTX file, either as output by nvcc or handwrtten.
Parameters:
module - Returned module
fname - Filename of module to load
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_NOT_FOUND,
CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_FILE_NOT_FOUND
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef, cuModuleLoadData, cuModuleLoadDataEx,
cuModuleLoadFatBinary, cuModuleUnload
Takes a pointer image and loads the corresponding module module into the current context. The pointer may be ob-
tained by mapping a cubin or PTX file, passing a cubin or PTX file as a NULL-terminated text string, or incorporating
a cubin object into the executable resources and using operating system calls such as Windows FindResource()
to obtain the pointer.
Parameters:
module - Returned module
image - Module data to load
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef, cuModuleLoad, cuModuleLoadDataEx, cu-
ModuleLoadFatBinary, cuModuleUnload
3.21.2.6 cuModuleLoadDataEx (CUmodule ∗ module, const void ∗ image, unsigned int numOptions,
CUjit_option ∗ options, void ∗∗ optionValues)
Takes a pointer image and loads the corresponding module module into the current context. The pointer may be ob-
tained by mapping a cubin or PTX file, passing a cubin or PTX file as a NULL-terminated text string, or incorporating
a cubin object into the executable resources and using operating system calls such as Windows FindResource()
to obtain the pointer. Options are passed as an array via options and any corresponding parameters are passed
in optionValues. The number of total options is supplied via numOptions. Any outputs will be returned via
optionValues. Supported options are:
Parameters:
module - Returned module
image - Module data to load
numOptions - Number of options
options - Options for JIT
optionValues - Option values for JIT
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY,
CUDA_ERROR_NO_BINARY_FOR_GPU
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef, cuModuleLoad, cuModuleLoadData, cu-
ModuleLoadFatBinary, cuModuleUnload
Takes a pointer fatCubin and loads the corresponding module module into the current context. The pointer
represents a fat binary object, which is a collection of different cubin files, all representing the same device code, but
compiled and optimized for different architectures. There is currently no documented API for constructing and using
fat binary objects by programmers, and therefore this function is an internal function in this version of CUDA. More
information can be found in the nvcc document.
Parameters:
module - Returned module
fatCubin - Fat binary to load
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_NOT_FOUND,
CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_NO_BINARY_FOR_GPU
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef, cuModuleLoad, cuModuleLoadData, cu-
ModuleLoadDataEx, cuModuleUnload
Parameters:
hmod - Module to unload
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuModuleGetFunction, cuModuleGetGlobal, cuModuleGetTexRef, cuModuleLoad, cuModuleLoadData, cu-
ModuleLoadDataEx, cuModuleLoadFatBinary
Functions
• CUresult cuStreamCreate (CUstream ∗phStream, unsigned int Flags)
Create a stream.
This section describes the stream management functions of the low-level CUDA driver application programming
interface.
Parameters:
phStream - Returned newly created stream
Flags - Parameters for stream creation (must be 0)
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuStreamDestroy, cuStreamQuery, cuStreamSynchronize
Parameters:
hStream - Stream to destroy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuStreamCreate, cuStreamQuery, cuStreamSynchronize
Returns CUDA_SUCCESS if all operations in the stream specified by hStream have completed, or CUDA_-
ERROR_NOT_READY if not.
Parameters:
hStream - Stream to query status of
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_READY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuStreamCreate, cuStreamDestroy, cuStreamSynchronize
Waits until the device has completed all operations in the stream specified by hStream.
Parameters:
hStream - Stream to wait for
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuStreamCreate, cuStreamDestroy, cuStreamQuery
Functions
• CUresult cuEventCreate (CUevent ∗phEvent, unsigned int Flags)
Creates an event.
This section describes the event management functions of the low-level CUDA driver application programming inter-
face.
Creates an event ∗phEvent with the flags specified via Flags. Valid flags include:
Parameters:
phEvent - Returns newly created event
Flags - Event creation flags
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuEventRecord, cuEventQuery, cuEventSynchronize, cuEventDestroy, cuEventElapsedTime
Parameters:
hEvent - Event to destroy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuEventCreate, cuEventRecord, cuEventQuery, cuEventSynchronize, cuEventElapsedTime
Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). If
either event has not been recorded yet, this function returns CUDA_ERROR_NOT_READY. If either event has been
recorded with a non-zero stream, the result is undefined.
Parameters:
pMilliseconds - Returned elapsed time in milliseconds
hStart - Starting event
hEnd - Ending event
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_READY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuEventCreate, cuEventRecord, cuEventQuery, cuEventSynchronize, cuEventDestroy
Returns CUDA_SUCCESS if the event has actually been recorded, or CUDA_ERROR_NOT_READY if not. If
cuEventRecord() has not been called on this event, the function returns CUDA_ERROR_INVALID_VALUE.
Parameters:
hEvent - Event to query
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_INVALID_VALUE,
CUDA_ERROR_NOT_READY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuEventCreate, cuEventRecord, cuEventSynchronize, cuEventDestroy, cuEventElapsedTime
Records an event. If stream is non-zero, the event is recorded after all preceding operations in the stream have been
completed; otherwise, it is recorded after all preceding operations in the CUDA context have been completed. Since
operation is asynchronous, cuEventQuery() and/or cuEventSynchronize() must be used to determine when the event
has actually been recorded.
If cuEventRecord() has previously been called and the event has not been recorded yet, this function returns CUDA_-
ERROR_INVALID_VALUE.
Parameters:
hEvent - Event to record
hStream - Stream to record event for
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuEventCreate, cuEventQuery, cuEventSynchronize, cuEventDestroy, cuEventElapsedTime
Waits until the event has actually been recorded. If cuEventRecord() has been called on this event, the function returns
CUDA_ERROR_INVALID_VALUE.
If cuEventRecord() has previously been called and the event has not been recorded yet, this function returns CUDA_-
ERROR_INVALID_VALUE.
Parameters:
hEvent - Event to wait for
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuEventCreate, cuEventRecord, cuEventQuery, cuEventDestroy, cuEventElapsedTime
Functions
• CUresult cuFuncGetAttribute (int ∗pi, CUfunction_attribute attrib, CUfunction hfunc)
Returns information about a function.
• CUresult cuParamSetv (CUfunction hfunc, int offset, void ∗ptr, unsigned int numbytes)
Adds arbitrary data to the function’s argument list.
This section describes the execution control functions of the low-level CUDA driver application programming inter-
face.
Returns in ∗pi the integer value of the attribute attrib on the kernel given by hfunc. The supported attributes are:
Parameters:
pi - Returned attribute value
attrib - Attribute requested
hfunc - Function to query attribute of
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuParamSetSize, cuParamSeti, cuParamSetf, cuParamSetv, cu-
ParamSetTexRef, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
Specifies the x, y, and z dimensions of the thread blocks that are created when the kernel given by hfunc is launched.
Parameters:
hfunc - Kernel to specify dimensions of
x - X dimension
y - Y dimension
z - Z dimension
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSeti, cuParamSetf, cuParamSetv, cuParam-
SetTexRef, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
Sets through bytes the amount of dynamic shared memory that will be available to each thread block when the kernel
given by hfunc is launched.
Parameters:
hfunc - Kernel to specify dynamic shared-memory size for
bytes - Dynamic shared-memory size per thread in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncGetAttribute, cuParamSetSize, cuParamSeti, cuParamSetf, cuParamSetv, cu-
ParamSetTexRef, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
Invokes the kernel f on a 1 x 1 x 1 grid of blocks. The block contains the number of threads specified by a previous
call to cuFuncSetBlockShape().
Parameters:
f - Kernel to launch
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_LAUNCH_FAILED,
CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES, CUDA_ERROR_LAUNCH_TIMEOUT, CUDA_-
ERROR_LAUNCH_INCOMPATIBLE_TEXTURING
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSetf, cuParamSeti,
cuParamSetv, cuParamSetTexRef, cuLaunchGrid, cuLaunchGridAsync
Invokes the kernel f on a grid_width x grid_height grid of blocks. Each block contains the number of threads
specified by a previous call to cuFuncSetBlockShape().
Parameters:
f - Kernel to launch
grid_width - Width of grid in blocks
grid_height - Height of grid in blocks
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_LAUNCH_FAILED,
CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES, CUDA_ERROR_LAUNCH_TIMEOUT, CUDA_-
ERROR_LAUNCH_INCOMPATIBLE_TEXTURING
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSetf, cuParamSeti,
cuParamSetv, cuParamSetTexRef, cuLaunch, cuLaunchGridAsync
Invokes the kernel f on a grid_width x grid_height grid of blocks. Each block contains the number of threads
specified by a previous call to cuFuncSetBlockShape().
cuLaunchGridAsync() can optionally be associated to a stream by passing a non-zero hStream argument.
Parameters:
f - Kernel to launch
grid_width - Width of grid in blocks
grid_height - Height of grid in blocks
hStream - Stream identifier
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_LAUNCH_FAILED,
CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES, CUDA_ERROR_LAUNCH_TIMEOUT, CUDA_-
ERROR_LAUNCH_INCOMPATIBLE_TEXTURING
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSetf, cuParamSeti,
cuParamSetv, cuParamSetTexRef, cuLaunch, cuLaunchGrid
Sets a floating-point parameter that will be specified the next time the kernel corresponding to hfunc will be invoked.
offset is a byte offset.
Parameters:
hfunc - Kernel to add parameter to
offset - Offset to add parameter to argument list
value - Value of parameter
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSeti, cuParamSetv,
cuParamSetTexRef, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
Sets an integer parameter that will be specified the next time the kernel corresponding to hfunc will be invoked.
offset is a byte offset.
Parameters:
hfunc - Kernel to add parameter to
offset - Offset to add parameter to argument list
value - Value of parameter
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSetf, cuParamSetv,
cuParamSetTexRef, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
Sets through numbytes the total size in bytes needed by the function parameters of the kernel corresponding to
hfunc.
Parameters:
hfunc - Kernel to set parameter size for
numbytes - Size of parameter list in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetf, cuParamSeti, cuParamSetv, cu-
ParamSetTexRef, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
Makes the CUDA array or linear memory bound to the texture reference hTexRef available to a device program as a
texture. In this version of CUDA, the texture-reference must be obtained via cuModuleGetTexRef() and the texunit
parameter must be set to CU_PARAM_TR_DEFAULT.
Parameters:
hfunc - Kernel to add texture-reference to
texunit - Texture unit (must be CU_PARAM_TR_DEFAULT)
hTexRef - Texture-reference to add to argument list
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSetf, cuParamSeti,
cuParamSetv, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
3.24.2.11 cuParamSetv (CUfunction hfunc, int offset, void ∗ ptr, unsigned int numbytes)
Copies an arbitrary amount of data (specified in numbytes) from ptr into the parameter space of the kernel corre-
sponding to hfunc. offset is a byte offset.
Parameters:
hfunc - Kernel to add data to
offset - Offset to add data to argument list
ptr - Pointer to arbitrary data
numbytes - Size of data to copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuFuncSetBlockShape, cuFuncSetSharedSize, cuFuncGetAttribute, cuParamSetSize, cuParamSetf, cuParamSeti,
cuParamSetTexRef, cuLaunch, cuLaunchGrid, cuLaunchGridAsync
Functions
• CUresult cuArray3DCreate (CUarray ∗pHandle, const CUDA_ARRAY3D_DESCRIPTOR ∗pAllocateArray)
Creates a 3D CUDA array.
• CUresult cuMemAllocPitch (CUdeviceptr ∗dptr, unsigned int ∗pPitch, unsigned int WidthInBytes, unsigned int
Height, unsigned int ElementSizeBytes)
Allocates pitched device memory.
• CUresult cuMemcpyAtoA (CUarray dstArray, unsigned int dstIndex, CUarray srcArray, unsigned int srcIndex,
unsigned int ByteCount)
Copies memory from Array to Array.
• CUresult cuMemcpyAtoD (CUdeviceptr dstDevice, CUarray hSrc, unsigned int SrcIndex, unsigned int Byte-
Count)
• CUresult cuMemcpyAtoH (void ∗dstHost, CUarray srcArray, unsigned int srcIndex, unsigned int ByteCount)
Copies memory from Array to Host.
• CUresult cuMemcpyAtoHAsync (void ∗dstHost, CUarray srcArray, unsigned int srcIndex, unsigned int Byte-
Count, CUstream hStream)
Copies memory from Array to Host.
• CUresult cuMemcpyDtoA (CUarray dstArray, unsigned int dstIndex, CUdeviceptr srcDevice, unsigned int Byte-
Count)
Copies memory from Device to Array.
• CUresult cuMemcpyDtoHAsync (void ∗dstHost, CUdeviceptr srcDevice, unsigned int ByteCount, CUstream
hStream)
Copies memory from Device to Host.
• CUresult cuMemcpyHtoA (CUarray dstArray, unsigned int dstIndex, const void ∗pSrc, unsigned int Byte-
Count)
Copies memory from Host to Array.
• CUresult cuMemcpyHtoAAsync (CUarray dstArray, unsigned int dstIndex, const void ∗pSrc, unsigned int Byte-
Count, CUstream hStream)
Copies memory from Host to Array.
• CUresult cuMemcpyHtoD (CUdeviceptr dstDevice, const void ∗srcHost, unsigned int ByteCount)
Copies memory from Host to Device.
• CUresult cuMemcpyHtoDAsync (CUdeviceptr dstDevice, const void ∗srcHost, unsigned int ByteCount, CUs-
tream hStream)
Copies memory from Host to Device.
• CUresult cuMemsetD2D16 (CUdeviceptr dstDevice, unsigned int dstPitch, unsigned short us, unsigned int
Width, unsigned int Height)
Initializes device memory.
• CUresult cuMemsetD2D32 (CUdeviceptr dstDevice, unsigned int dstPitch, unsigned int ui, unsigned int Width,
unsigned int Height)
Initializes device memory.
• CUresult cuMemsetD2D8 (CUdeviceptr dstDevice, unsigned int dstPitch, unsigned char uc, unsigned int Width,
unsigned int Height)
Initializes device memory.
This section describes the memory management functions of the low-level CUDA driver application programming
interface.
Creates a CUDA array according to the CUDA_ARRAY3D_DESCRIPTOR structure pAllocateArray and returns
a handle to the new CUDA array in ∗pHandle. The CUDA_ARRAY3D_DESCRIPTOR is defined as:
typedef struct {
unsigned int Width;
unsigned int Height;
unsigned int Depth;
CUarray_format Format;
unsigned int NumChannels;
unsigned int Flags;
} CUDA_ARRAY3D_DESCRIPTOR;
where:
• Width, Height, and Depth are the width, height, and depth of the CUDA array (in elements); the CUDA
array is one-dimensional if height and depth are 0, two-dimensional if depth is 0, and three-dimensional other-
wise;
• Format specifies the format of the elements; CUarray_format is defined as:
• NumChannels specifies the number of packed components per CUDA array element; it may be 1, 2, or 4;
• Flags provides for future features. For now, it must be set to 0.
CUDA_ARRAY3D_DESCRIPTOR desc;
desc.Format = CU_AD_FORMAT_FLOAT;
desc.NumChannels = 1;
desc.Width = 2048;
desc.Height = 0;
desc.Depth = 0;
CUDA_ARRAY3D_DESCRIPTOR desc;
desc.Format = CU_AD_FORMAT_FLOAT;
desc.NumChannels = 1;
desc.Width = 64;
desc.Height = 64;
desc.Depth = 0;
Description for a width x height x depth CUDA array of 64-bit, 4x16-bit float16’s:
CUDA_ARRAY3D_DESCRIPTOR desc;
desc.FormatFlags = CU_AD_FORMAT_HALF;
desc.NumChannels = 4;
desc.Width = width;
desc.Height = height;
desc.Depth = depth;
Parameters:
pHandle - Returned array
pAllocateArray - 3D array descriptor
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY,
CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAlloc, cuMemAl-
locHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D,
cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Returns in ∗pArrayDescriptor a descriptor containing information on the format and dimensions of the CUDA
array hArray. It is useful for subroutines that have been passed a CUDA array, but need to know the CUDA array
parameters for validation or other purposes.
This function may be called on 1D and 2D arrays, in which case the Height and/or Depth members of the descriptor
struct will be set to 0.
Parameters:
pArrayDescriptor - Returned 3D array descriptor
hArray - 3D array to get descriptor of
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAlloc, cuMemAllocHost,
cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D, cuMem-
cpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpyD-
toA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Creates a CUDA array according to the CUDA_ARRAY_DESCRIPTOR structure pAllocateArray and returns a
handle to the new CUDA array in ∗pHandle. The CUDA_ARRAY_DESCRIPTOR is defined as:
typedef struct {
unsigned int Width;
unsigned int Height;
CUarray_format Format;
unsigned int NumChannels;
} CUDA_ARRAY_DESCRIPTOR;
where:
• Width, and Height are the width, and height of the CUDA array (in elements); the CUDA array is one-
dimensional if height is 0, two-dimensional otherwise;
• Format specifies the format of the elements; CUarray_format is defined as:
• NumChannels specifies the number of packed components per CUDA array element; it may be 1, 2, or 4;
CUDA_ARRAY_DESCRIPTOR desc;
desc.Format = CU_AD_FORMAT_FLOAT;
desc.NumChannels = 1;
desc.Width = 2048;
desc.Height = 1;
CUDA_ARRAY_DESCRIPTOR desc;
desc.Format = CU_AD_FORMAT_FLOAT;
desc.NumChannels = 1;
desc.Width = 64;
desc.Height = 64;
CUDA_ARRAY_DESCRIPTOR desc;
desc.FormatFlags = CU_AD_FORMAT_HALF;
desc.NumChannels = 4;
desc.Width = width;
desc.Height = height;
Description for a width x height CUDA array of 16-bit elements, each of which is two 8-bit unsigned chars:
CUDA_ARRAY_DESCRIPTOR arrayDesc;
desc.FormatFlags = CU_AD_FORMAT_UNSIGNED_INT8;
desc.NumChannels = 2;
desc.Width = width;
desc.Height = height;
Parameters:
pHandle - Returned array
pAllocateArray - Array descriptor
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY,
CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayDestroy, cuArrayGetDescriptor, cuMemAlloc, cuMemAl-
locHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D,
cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Parameters:
hArray - Array to destroy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_ARRAY_IS_-
MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayGetDescriptor, cuMemAlloc, cuMemAl-
locHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D,
cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Returns in ∗pArrayDescriptor a descriptor containing information on the format and dimensions of the CUDA
array hArray. It is useful for subroutines that have been passed a CUDA array, but need to know the CUDA array
parameters for validation or other purposes.
Parameters:
pArrayDescriptor - Returned array descriptor
hArray - Array to get descriptor of
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuMemAlloc, cuMemAllocHost,
cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D, cuMem-
cpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpyD-
toA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Allocates bytesize bytes of linear memory on the device and returns in ∗dptr a pointer to the allocated memory.
The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. If bytesize is 0,
cuMemAlloc() returns CUDA_ERROR_INVALID_VALUE.
Parameters:
dptr - Returned device pointer
bytesize - Requested allocation size in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
locHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D,
cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
Allocates bytesize bytes of host memory that is page-locked and accessible to the device. The driver tracks the vir-
tual memory ranges allocated with this function and automatically accelerates calls to functions such as cuMemcpy().
Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than
pageable memory obtained with functions such as malloc(). Allocating excessive amounts of memory with cuMemAl-
locHost() may degrade system performance, since it reduces the amount of memory available to the system for paging.
As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device.
Parameters:
pp - Returned host pointer to page-locked memory
bytesize - Requested allocation size in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D, cuMem-
cpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpyD-
toA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.8 cuMemAllocPitch (CUdeviceptr ∗ dptr, unsigned int ∗ pPitch, unsigned int WidthInBytes, unsigned
int Height, unsigned int ElementSizeBytes)
Allocates at least WidthInBytes ∗ Height bytes of linear memory on the device and returns in ∗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.
ElementSizeBytes specifies the size of the largest reads and writes that will be performed on the memory range.
ElementSizeBytes may be 4, 8 or 16 (since coalesced memory transactions are not possible on other data sizes). If
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 ∗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 T, the address is computed as:
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 cuMemAl-
locPitch(). 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).
Parameters:
dptr - Returned device pointer
pPitch - Returned pitch of allocation in bytes
WidthInBytes - Requested allocation width in bytes
Height - Requested allocation height in rows
ElementSizeBytes - Size of largest reads/writes for range
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D, cuMem-
cpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpyD-
toA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Perform a 2D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY2D structure is
defined as:
where:
• srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively;
CUmemorytype_enum is defined as:
If srcMemoryType is CU_MEMORYTYPE_HOST, srcHost and srcPitch specify the (host) base address of the
source data and the bytes per row to apply. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_DEVICE, srcDevice and srcPitch specify the (device) base address
of the source data and the bytes per row to apply. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_ARRAY, srcArray specifies the handle of the source data. srcHost,
srcDevice and srcPitch are ignored.
If dstMemoryType is CU_MEMORYTYPE_HOST, dstHost and dstPitch specify the (host) base address of the
destination data and the bytes per row to apply. dstArray is ignored.
If dstMemoryType is CU_MEMORYTYPE_DEVICE, dstDevice and dstPitch specify the (device) base address
of the destination data and the bytes per row to apply. dstArray is ignored.
• srcXInBytes and srcY specify the base address of the source data for the copy.
For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
• dstXInBytes and dstY specify the base address of the destination data for the copy.
For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
• WidthInBytes and Height specify the width (in bytes) and height of the 2D copy being performed. Any pitches
must be greater than or equal to WidthInBytes.
cuMemcpy2D() returns an error if any pitch is greater than the maximum allowed (CU_DEVICE_ATTRIBUTE_-
MAX_PITCH). cuMemAllocPitch() passes back pitches that always work with cuMemcpy2D(). On intra-device
memory copies (device ? device, CUDA array ? device, CUDA array ? CUDA array), cuMemcpy2D() may fail
for pitches not computed by cuMemAllocPitch(). cuMemcpy2DUnaligned() does not have this restriction, but
may run significantly slower in the cases where cuMemcpy2D() would have returned an error code.
Parameters:
pCopy - Parameters for the memory copy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2DAsync, cuMemcpy2DUnaligned, cuMemcpy3D,
cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Perform a 2D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY2D structure is
defined as:
where:
• srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively;
CUmemorytype_enum is defined as:
If srcMemoryType is CU_MEMORYTYPE_HOST, srcHost and srcPitch specify the (host) base address of the
source data and the bytes per row to apply. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_DEVICE, srcDevice and srcPitch specify the (device) base address
of the source data and the bytes per row to apply. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_ARRAY, srcArray specifies the handle of the source data. srcHost,
srcDevice and srcPitch are ignored.
If dstMemoryType is CU_MEMORYTYPE_HOST, dstHost and dstPitch specify the (host) base address of the
destination data and the bytes per row to apply. dstArray is ignored.
If dstMemoryType is CU_MEMORYTYPE_DEVICE, dstDevice and dstPitch specify the (device) base address
of the destination data and the bytes per row to apply. dstArray is ignored.
• srcXInBytes and srcY specify the base address of the source data for the copy.
For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
• dstXInBytes and dstY specify the base address of the destination data for the copy.
For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
• WidthInBytes and Height specify the width (in bytes) and height of the 2D copy being performed. Any pitches
must be greater than or equal to WidthInBytes.
cuMemcpy2D() returns an error if any pitch is greater than the maximum allowed (CU_DEVICE_ATTRIBUTE_-
MAX_PITCH). cuMemAllocPitch() passes back pitches that always work with cuMemcpy2D(). On intra-device
memory copies (device ? device, CUDA array ? device, CUDA array ? CUDA array), cuMemcpy2D() may fail
for pitches not computed by cuMemAllocPitch(). cuMemcpy2DUnaligned() does not have this restriction, but
may run significantly slower in the cases where cuMemcpy2D() would have returned an error code.
cuMemcpy2DAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero hStream
argument. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input.
Parameters:
pCopy - Parameters for the memory copy
hStream - Stream identifier
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DUnaligned, cuMemcpy3D, cuMem-
cpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpyD-
toA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Perform a 2D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY2D structure is
defined as:
CUdeviceptr srcDevice;
CUarray srcArray;
unsigned int srcPitch;
unsigned int dstXInBytes, dstY;
CUmemorytype dstMemoryType;
void *dstHost;
CUdeviceptr dstDevice;
CUarray dstArray;
unsigned int dstPitch;
unsigned int WidthInBytes;
unsigned int Height;
} CUDA_MEMCPY2D;
where:
• srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively;
CUmemorytype_enum is defined as:
If srcMemoryType is CU_MEMORYTYPE_HOST, srcHost and srcPitch specify the (host) base address of the
source data and the bytes per row to apply. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_DEVICE, srcDevice and srcPitch specify the (device) base address
of the source data and the bytes per row to apply. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_ARRAY, srcArray specifies the handle of the source data. srcHost,
srcDevice and srcPitch are ignored.
If dstMemoryType is CU_MEMORYTYPE_HOST, dstHost and dstPitch specify the (host) base address of the
destination data and the bytes per row to apply. dstArray is ignored.
If dstMemoryType is CU_MEMORYTYPE_DEVICE, dstDevice and dstPitch specify the (device) base address
of the destination data and the bytes per row to apply. dstArray is ignored.
• srcXInBytes and srcY specify the base address of the source data for the copy.
For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
• dstXInBytes and dstY specify the base address of the destination data for the copy.
For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
• WidthInBytes and Height specify the width (in bytes) and height of the 2D copy being performed. Any pitches
must be greater than or equal to WidthInBytes.
cuMemcpy2D() returns an error if any pitch is greater than the maximum allowed (CU_DEVICE_ATTRIBUTE_-
MAX_PITCH). cuMemAllocPitch() passes back pitches that always work with cuMemcpy2D(). On intra-device
memory copies (device ? device, CUDA array ? device, CUDA array ? CUDA array), cuMemcpy2D() may fail
for pitches not computed by cuMemAllocPitch(). cuMemcpy2DUnaligned() does not have this restriction, but
may run significantly slower in the cases where cuMemcpy2D() would have returned an error code.
Parameters:
pCopy - Parameters for the memory copy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy3D, cuMem-
cpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpyD-
toA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Perform a 3D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY3D structure is
defined as:
where:
• srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively;
CUmemorytype_enum is defined as:
If srcMemoryType is CU_MEMORYTYPE_HOST, srcHost, srcPitch and srcHeight specify the (host) base ad-
dress of the source data, the bytes per row, and the height of each 2D slice of the 3D array. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_ARRAY, srcArray specifies the handle of the source data. srcHost,
srcDevice, srcPitch and srcHeight are ignored.
If dstMemoryType is CU_MEMORYTYPE_HOST, dstHost and dstPitch specify the (host) base address of the
destination data, the bytes per row, and the height of each 2D slice of the 3D array. dstArray is ignored.
If dstMemoryType is CU_MEMORYTYPE_DEVICE, dstDevice and dstPitch specify the (device) base address
of the destination data, the bytes per row, and the height of each 2D slice of the 3D array. dstArray is ignored.
• srcXInBytes, srcY and srcZ specify the base address of the source data for the copy.
For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
• dstXInBytes, dstY and dstZ specify the base address of the destination data for the copy.
For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
• WidthInBytes, Height and Depth specify the width (in bytes), height and depth of the 3D copy being performed.
Any pitches must be greater than or equal to WidthInBytes.
cuMemcpy3D() returns an error if any pitch is greater than the maximum allowed (CU_DEVICE_ATTRIBUTE_-
MAX_PITCH).
The srcLOD and dstLOD members of the CUDA_MEMCPY3D structure must be set to 0.
Parameters:
pCopy - Parameters for the memory copy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Perform a 3D memory copy according to the parameters specified in pCopy. The CUDA_MEMCPY3D structure is
defined as:
where:
• srcMemoryType and dstMemoryType specify the type of memory of the source and destination, respectively;
CUmemorytype_enum is defined as:
If srcMemoryType is CU_MEMORYTYPE_HOST, srcHost, srcPitch and srcHeight specify the (host) base ad-
dress of the source data, the bytes per row, and the height of each 2D slice of the 3D array. srcArray is ignored.
If srcMemoryType is CU_MEMORYTYPE_ARRAY, srcArray specifies the handle of the source data. srcHost,
srcDevice, srcPitch and srcHeight are ignored.
If dstMemoryType is CU_MEMORYTYPE_HOST, dstHost and dstPitch specify the (host) base address of the
destination data, the bytes per row, and the height of each 2D slice of the 3D array. dstArray is ignored.
If dstMemoryType is CU_MEMORYTYPE_DEVICE, dstDevice and dstPitch specify the (device) base address
of the destination data, the bytes per row, and the height of each 2D slice of the 3D array. dstArray is ignored.
• srcXInBytes, srcY and srcZ specify the base address of the source data for the copy.
For CUDA arrays, srcXInBytes must be evenly divisible by the array element size.
• dstXInBytes, dstY and dstZ specify the base address of the destination data for the copy.
For CUDA arrays, dstXInBytes must be evenly divisible by the array element size.
• WidthInBytes, Height and Depth specify the width (in bytes), height and depth of the 3D copy being performed.
Any pitches must be greater than or equal to WidthInBytes.
cuMemcpy3D() returns an error if any pitch is greater than the maximum allowed (CU_DEVICE_ATTRIBUTE_-
MAX_PITCH).
cuMemcpy3DAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero hStream
argument. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input.
The srcLOD and dstLOD members of the CUDA_MEMCPY3D structure must be set to 0.
Parameters:
pCopy - Parameters for the memory copy
hStream - Stream identifier
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpyD-
toA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.14 cuMemcpyAtoA (CUarray dstArray, unsigned int dstIndex, CUarray srcArray, unsigned int
srcIndex, unsigned int ByteCount)
Copies from one 1D CUDA array to another. dstArray and srcArray specify the handles of the destination
and source CUDA arrays for the copy, respectively. dstIndex and srcIndex specify the destination and source
indices into the CUDA array. These values are in the range [0, Width-1] for the CUDA array; they are not byte offsets.
ByteCount is the number of bytes to be copied. The size of the elements in the CUDA arrays need not be the same
format, but the elements must be the same size; and count must be evenly divisible by that size.
Parameters:
dstArray - Destination array
dstIndex - Offset of destination array
srcArray - Source array
srcIndex - Offset of source array
ByteCount - Size of memory copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
3.25.2.15 cuMemcpyAtoD (CUdeviceptr dstDevice, CUarray hSrc, unsigned int SrcIndex, unsigned int
ByteCount)
Copies from one 1D CUDA array to device memory. dstDevice specifies the base pointer of the destination and
must be naturally aligned with the CUDA array elements. hSrc and SrcIndex specify the CUDA array handle and
the index (in array elements) of the array element where the copy is to begin. ByteCount specifies the number of
bytes to copy and must be evenly divisible by the array element size.
Parameters:
dstDevice - Destination device pointer
hSrc - Source array
SrcIndex - Offset of source array
ByteCount - Size of memory copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoH, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.16 cuMemcpyAtoH (void ∗ dstHost, CUarray srcArray, unsigned int srcIndex, unsigned int
ByteCount)
Copies from one 1D CUDA array to host memory. dstHost specifies the base pointer of the destination. srcArray
and srcIndex specify the CUDA array handle and starting index of the source data. ByteCount specifies the
number of bytes to copy.
Parameters:
dstHost - Destination device pointer
srcArray - Source array
srcIndex - Offset of source array
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoHAsync, cuMemcpy-
DtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.17 cuMemcpyAtoHAsync (void ∗ dstHost, CUarray srcArray, unsigned int srcIndex, unsigned int
ByteCount, CUstream hStream)
Copies from one 1D CUDA array to host memory. dstHost specifies the base pointer of the destination. srcArray
and srcIndex specify the CUDA array handle and starting index of the source data. ByteCount specifies the
number of bytes to copy.
cuMemcpyAtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero stream
argument. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed
as input.
Parameters:
dstHost - Destination pointer
srcArray - Source array
srcIndex - Offset of source array
ByteCount - Size of memory copy in bytes
hStream - Stream identifier
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyDtoA,
cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync, cuMem-
cpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.18 cuMemcpyDtoA (CUarray dstArray, unsigned int dstIndex, CUdeviceptr srcDevice, unsigned int
ByteCount)
Copies from device memory to a 1D CUDA array. dstArray and dstIndex specify the CUDA array handle and
starting index of the destination data. srcDevice specifies the base pointer of the source. ByteCount specifies
the number of bytes to copy.
Parameters:
dstArray - Destination array
dstIndex - Offset of destination array
srcDevice - Source device pointer
ByteCount - Size of memory copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Copies from device memory to device memory. dstDevice and srcDevice are the base pointers of the destination
and source, respectively. ByteCount specifies the number of bytes to copy. Note that this function is asynchronous.
Parameters:
dstDevice - Destination device pointer
srcDevice - Source device pointer
ByteCount - Size of memory copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Copies from device to host memory. dstHost and srcDevice specify the base pointers of the destination and
source, respectively. ByteCount specifies the number of bytes to copy. Note that this function is synchronous.
Parameters:
dstHost - Destination host pointer
srcDevice - Source device pointer
ByteCount - Size of memory copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoHAsync, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.21 cuMemcpyDtoHAsync (void ∗ dstHost, CUdeviceptr srcDevice, unsigned int ByteCount, CUstream
hStream)
Copies from device to host memory. dstHost and srcDevice specify the base pointers of the destination and
source, respectively. ByteCount specifies the number of bytes to copy.
cuMemcpyDtoHAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero
hStream argument. It only works on page-locked memory and returns an error if a pointer to pageable memory
is passed as input.
Parameters:
dstHost - Destination host pointer
srcDevice - Source device pointer
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyHtoA, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.22 cuMemcpyHtoA (CUarray dstArray, unsigned int dstIndex, const void ∗ pSrc, unsigned int
ByteCount)
Copies from host memory to a 1D CUDA array. dstArray and dstIndex specify the CUDA array handle and
starting index of the destination data. pSrc specifies the base address of the source. ByteCount specifies the
number of bytes to copy.
Parameters:
dstArray - Destination array
dstIndex - Offset of destination array
pSrc - Source host pointer
ByteCount - Size of memory copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoAAsync,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.23 cuMemcpyHtoAAsync (CUarray dstArray, unsigned int dstIndex, const void ∗ pSrc, unsigned int
ByteCount, CUstream hStream)
Copies from host memory to a 1D CUDA array. dstArray and dstIndex specify the CUDA array handle and
starting index of the destination data. pSrc specifies the base address of the source. ByteCount specifies the
number of bytes to copy.
cuMemcpyHtoAAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero
hStream argument. It only works on page-locked memory and returns an error if a pointer to pageable memory
is passed as input.
Parameters:
dstArray - Destination array
dstIndex - Offset of destination array
pSrc - Source host pointer
ByteCount - Size of memory copy in bytes
hStream - Stream identifier
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.24 cuMemcpyHtoD (CUdeviceptr dstDevice, const void ∗ srcHost, unsigned int ByteCount)
Copies from host memory to device memory. dstDevice and srcHost are the base addresses of the destination
and source, respectively. ByteCount specifies the number of bytes to copy. Note that this function is synchronous.
Parameters:
dstDevice - Destination device pointer
srcHost - Source host pointer
ByteCount - Size of memory copy in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAddressRange,
cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMem-
setD2D32, cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.25 cuMemcpyHtoDAsync (CUdeviceptr dstDevice, const void ∗ srcHost, unsigned int ByteCount,
CUstream hStream)
Copies from host memory to device memory. dstDevice and srcHost are the base addresses of the destination
and source, respectively. ByteCount specifies the number of bytes to copy.
cuMemcpyHtoDAsync() is asynchronous and can optionally be associated to a stream by passing a non-zero hStream
argument. It only works on page-locked memory and returns an error if a pointer to pageable memory is passed as
input.
Parameters:
dstDevice - Destination device pointer
srcHost - Source host pointer
ByteCount - Size of memory copy in bytes
hStream - Stream identifier
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemFree, cuMemFreeHost, cuMemGetAddressRange, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Frees the memory space pointed to by dptr, which must have been returned by a previous call to cuMemAlloc() or
cuMemAllocPitch().
Parameters:
dptr - Pointer to memory to free
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFreeHost, cuMemGetAddressRange,
cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMem-
setD2D32, cuMemsetD8, cuMemsetD16, cuMemsetD32
Frees the memory space pointed to by p, which must have been returned by a previous call to cuMemAllocHost().
Parameters:
p - Pointer to memory to free
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemGetAddressRange,
cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMem-
setD2D32, cuMemsetD8, cuMemsetD16, cuMemsetD32
Returns the base address in ∗pbase and size in ∗psize of the allocation by cuMemAlloc() or cuMemAllocPitch()
that contains the input pointer dptr. Both parameters pbase and psize are optional. If one of them is NULL, it is
ignored.
Parameters:
pbase - Returned base address
psize - Returned size of device memory allocation
dptr - Device pointer to query
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGet-
Info, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32,
cuMemsetD8, cuMemsetD16, cuMemsetD32
Returns in ∗free and ∗total respectively, the free and total amount of memory available for allocation by the
CUDA context, in bytes.
Parameters:
free - Returned free memory in bytes
total - Returned total memory in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMem-
setD2D32, cuMemsetD8, cuMemsetD16, cuMemsetD32
Allocates bytesize bytes of host memory that is page-locked and accessible to the device. The driver tracks the
virtual memory ranges allocated with this function and automatically accelerates calls to functions such as cuMem-
cpyHtoD(). Since the memory can be accessed directly by the device, it can be read or written with much higher
bandwidth than pageable memory obtained with functions such as malloc(). Allocating excessive amounts of pinned
memory may degrade system performance, since it reduces the amount of memory available to the system for paging.
As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device.
The Flags parameter enables different options to be specified that affect the allocation, as follows.
• CU_MEMHOSTALLOC_PORTABLE: The memory returned by this call will be considered as pinned memory
by all CUDA contexts, not just the one that performed the allocation.
• CU_MEMHOSTALLOC_DEVICEMAP: Maps the allocation into the CUDA address space. The device pointer
to the memory may be obtained by calling cuMemHostGetDevicePointer(). This feature is available only on
GPUs with compute capability greater than or equal to 1.1.
All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or
write-combined with no restrictions.
The CUDA context must have been created with the CU_CTX_MAP_HOST flag in order for the CU_-
MEMHOSTALLOC_MAPPED flag to have any effect.
The CU_MEMHOSTALLOC_MAPPED flag may be specified on CUDA contexts for devices that do not support
mapped pinned memory. The failure is deferred to cuMemHostGetDevicePointer() because the memory may be
mapped into other CUDA contexts via the CU_MEMHOSTALLOC_PORTABLE flag.
The memory allocated by this function must be freed with cuMemFreeHost().
Parameters:
pp - Returned host pointer to page-locked memory
bytesize - Requested allocation size in bytes
Flags - Flags for allocation request
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemGetInfo, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMemsetD2D16, cuMem-
setD2D32, cuMemsetD8, cuMemsetD16, cuMemsetD32
Passes back the device pointer pdptr corresponding to the mapped, pinned host buffer p allocated by cuMemHostAl-
loc.
cuMemHostGetDevicePointer() will fail if the CU_MEMALLOCHOST_DEVICEMAP flag was not specified at the
time the memory was allocated, or if the function is called on a GPU that does not support mapped pinned memory.
Flags provides for future releases. For now, it must be set to 0.
Parameters:
pdptr - Returned device pointer
p - Host pointer
Flags - Options (must be 0)
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGetAd-
dressRange, cuMemGetInfo, cuMemHostAlloc, cuMemsetD2D8, cuMemsetD2D16, cuMemsetD2D32, cuMem-
setD8, cuMemsetD16, cuMemsetD32
Passes back the flags pFlags that were specified when allocating the pinned host buffer p allocated by
cuMemHostAlloc.
cuMemHostGetFlags() will fail if the pointer does not reside in an allocation performed by cuMemAllocHost() or
cuMemHostAlloc().
Parameters:
pFlags - Returned flags word
p - Host pointer
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuMemAllocHost, cuMemHostAlloc
Sets the memory range of N 16-bit values to the specified value us.
Parameters:
dstDevice - Destination device pointer
us - Value to set
N - Number of elements
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMem-
setD2D16, cuMemsetD2D32, cuMemsetD8, cuMemsetD32
3.25.2.34 cuMemsetD2D16 (CUdeviceptr dstDevice, unsigned int dstPitch, unsigned short us, unsigned int
Width, unsigned int Height)
Sets the 2D memory range of Width 16-bit values to the specified value us. Height specifies the number of rows
to set, and dstPitch specifies the number of bytes between each row. This function performs fastest when the pitch
is one that has been passed back by cuMemAllocPitch().
Parameters:
dstDevice - Destination device pointer
dstPitch - Pitch of destination device pointer
us - Value to set
Width - Width of row
Height - Number of rows
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMem-
setD2D32, cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.35 cuMemsetD2D32 (CUdeviceptr dstDevice, unsigned int dstPitch, unsigned int ui, unsigned int
Width, unsigned int Height)
Sets the 2D memory range of Width 32-bit values to the specified value ui. Height specifies the number of rows
to set, and dstPitch specifies the number of bytes between each row. This function performs fastest when the pitch
is one that has been passed back by cuMemAllocPitch().
Parameters:
dstDevice - Destination device pointer
dstPitch - Pitch of destination device pointer
ui - Value to set
Width - Width of row
Height - Number of rows
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMem-
setD2D16, cuMemsetD8, cuMemsetD16, cuMemsetD32
3.25.2.36 cuMemsetD2D8 (CUdeviceptr dstDevice, unsigned int dstPitch, unsigned char uc, unsigned int
Width, unsigned int Height)
Sets the 2D memory range of Width 8-bit values to the specified value uc. Height specifies the number of rows to
set, and dstPitch specifies the number of bytes between each row. This function performs fastest when the pitch is
one that has been passed back by cuMemAllocPitch().
Parameters:
dstDevice - Destination device pointer
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D16, cuMem-
setD2D32, cuMemsetD8, cuMemsetD16, cuMemsetD32
Sets the memory range of N 32-bit values to the specified value ui.
Parameters:
dstDevice - Destination device pointer
ui - Value to set
N - Number of elements
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMem-
setD2D16, cuMemsetD2D32, cuMemsetD8, cuMemsetD16
Sets the memory range of N 8-bit values to the specified value uc.
Parameters:
dstDevice - Destination device pointer
uc - Value to set
N - Number of elements
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuArray3DCreate, cuArray3DGetDescriptor, cuArrayCreate, cuArrayDestroy, cuArrayGetDescriptor, cuMemAl-
loc, cuMemAllocHost, cuMemAllocPitch, cuMemcpy2D, cuMemcpy2DAsync, cuMemcpy2DUnaligned,
cuMemcpy3D, cuMemcpy3DAsync, cuMemcpyAtoA, cuMemcpyAtoD, cuMemcpyAtoH, cuMemcpyAto-
HAsync, cuMemcpyDtoA, cuMemcpyDtoD, cuMemcpyDtoH, cuMemcpyDtoHAsync, cuMemcpyHtoA,
cuMemcpyHtoAAsync, cuMemcpyHtoD, cuMemcpyHtoDAsync, cuMemFree, cuMemFreeHost, cuMemGe-
tAddressRange, cuMemGetInfo, cuMemHostAlloc, cuMemHostGetDevicePointer, cuMemsetD2D8, cuMem-
setD2D16, cuMemsetD2D32, cuMemsetD16, cuMemsetD32
Functions
• CUresult cuTexRefCreate (CUtexref ∗pTexRef)
Creates a texture reference.
• CUresult cuTexRefSetAddress (unsigned int ∗ByteOffset, CUtexref hTexRef, CUdeviceptr dptr, unsigned int
bytes)
Binds an address as a texture reference.
This section describes the texture reference management functions of the low-level CUDA driver application program-
ming interface.
Creates a texture reference and returns its handle in ∗pTexRef. Once created, the application must call cuTexRefSe-
tArray() or cuTexRefSetAddress() to associate the reference with allocated memory. Other texture reference functions
are used to specify the format and interpretation (addressing, filtering, etc.) to be used when the memory is read
through this texture reference. To associate the texture reference with a texture ordinal for a given function, the
application should call cuParamSetTexRef().
Parameters:
pTexRef - Returned texture reference
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode, cuTexRefSetAr-
ray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAd-
dressMode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Parameters:
hTexRef - Texture reference to destroy
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode, cuTexRefSetArray,
cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Returns in ∗pdptr the base address bound to the texture reference hTexRef, or returns CUDA_ERROR_-
INVALID_VALUE if the texture reference is not bound to any device memory range.
Parameters:
pdptr - Returned device address
hTexRef - Texture reference
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Returns in ∗pam the addressing mode corresponding to the dimension dim of the texture reference hTexRef. Cur-
rently, the only valid value for dim are 0 and 1.
Parameters:
pam - Returned addressing mode
hTexRef - Texture reference
dim - Dimension
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cu-
TexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Returns in ∗phArray the CUDA array bound to the texture reference hTexRef, or returns CUDA_ERROR_-
INVALID_VALUE if the texture reference is not bound to any CUDA array.
Parameters:
phArray - Returned array
hTexRef - Texture reference
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cu-
TexRefGetAddressMode, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Parameters:
pfm - Returned filtering mode
hTexRef - Texture reference
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cu-
TexRefGetAddressMode, cuTexRefGetArray, cuTexRefGetFlags, cuTexRefGetFormat
Parameters:
pFlags - Returned flags
hTexRef - Texture reference
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cu-
TexRefGetAddressMode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFormat
Returns in ∗pFormat and ∗pNumChannels the format and number of components of the CUDA array bound to
the texture reference hTexRef. If pFormat or pNumChannels is NULL, it will be ignored.
Parameters:
pFormat - Returned format
pNumChannels - Returned number of components
hTexRef - Texture reference
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cu-
TexRefGetAddressMode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags
3.26.2.9 cuTexRefSetAddress (unsigned int ∗ ByteOffset, CUtexref hTexRef, CUdeviceptr dptr, unsigned int
bytes)
Binds a linear address range to the texture reference hTexRef. Any previous address or CUDA array state associated
with the texture reference is superseded by this function. Any memory previously bound to hTexRef is unbound.
Since the hardware enforces an alignment requirement on texture base addresses, cuTexRefSetAddress() passes back
a byte offset in ∗ByteOffset that must be applied to texture fetches in order to read from the desired memory. This
offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the
tex1Dfetch() function.
If the device memory pointer was returned from cuMemAlloc(), the offset is guaranteed to be 0 and NULL may be
passed as the ByteOffset parameter.
Parameters:
ByteOffset - Returned byte offset
hTexRef - Texture reference to bind
dptr - Device pointer to bind
bytes - Size of memory to bind in bytes
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress2D, cuTexRefSetAddressMode, cuTexRefSetArray, cu-
TexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Binds a linear address range to the texture reference hTexRef. Any previous address or CUDA array state associated
with the texture reference is superseded by this function. Any memory previously bound to hTexRef is unbound.
When using a tex2D() function inside a kernel, we have to either call cuTexRefSetArray() to bind the corresponding
texture reference to an array, or cuTexRefSetAddress2D() to bind the texture reference to linear memory.
Function calls to cuTexRefSetFormat() cannot follow calls to cuTexRefSetAddress2D() for the same texture reference.
Parameters:
hTexRef - Texture reference to bind
desc - Descriptor of CUDA array
dptr - Device pointer to bind
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddressMode, cuTexRefSetArray, cu-
TexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Specifies the addressing mode am for the given dimension dim of the texture reference hTexRef. If dim is zero,
the addressing mode is applied to the first parameter of the functions used to fetch from the texture; if dim is 1, the
second, and so on. CUaddress_mode is defined as:
Note that this call has no effect if hTexRef is bound to linear memory.
Parameters:
hTexRef - Texture reference
dim - Dimension
am - Addressing mode to set
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetArray, cu-
TexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Binds the CUDA array hArray to the texture reference hTexRef. Any previous address or CUDA array state
associated with the texture reference is superseded by this function. Flags must be set to CU_TRSA_OVERRIDE_-
FORMAT. Any CUDA array previously bound to hTexRef is unbound.
Parameters:
hTexRef - Texture reference to bind
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Specifies the filtering mode fm to be used when reading memory through the texture reference hTexRef. CUfilter_-
mode_enum is defined as:
Note that this call has no effect if hTexRef is bound to linear memory.
Parameters:
hTexRef - Texture reference
fm - Filtering mode to set
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFlags, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAddressMode,
cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Specifies optional flags via Flags to specify the behavior of data returned through the texture reference hTexRef.
The valid flags are:
• CU_TRSF_READ_AS_INTEGER, which suppresses the default behavior of having the texture promote integer
data to floating point data in the range [0, 1];
• CU_TRSF_NORMALIZED_COORDINATES, which suppresses the default behavior of having the texture co-
ordinates range from [0, Dim) where Dim is the width or height of the CUDA array. Instead, the texture
coordinates [0, 1.0) reference the entire breadth of the array dimension;
Parameters:
hTexRef - Texture reference
Flags - Optional flags to set
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFormat, cuTexRefGetAddress, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Specifies the format of the data to be read by the texture reference hTexRef. fmt and NumPackedComponents
are exactly analogous to the Format and NumChannels members of the CUDA_ARRAY_DESCRIPTOR structure:
They specify the format of each component and the number of components per array element.
Parameters:
hTexRef - Texture reference
fmt - Format to set
NumPackedComponents - Number of components per array element
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
See also:
cuTexRefCreate, cuTexRefDestroy, cuTexRefSetAddress, cuTexRefSetAddress2D, cuTexRefSetAddressMode,
cuTexRefSetArray, cuTexRefSetFilterMode, cuTexRefSetFlags, cuTexRefGetAddress, cuTexRefGetAddress-
Mode, cuTexRefGetArray, cuTexRefGetFilterMode, cuTexRefGetFlags, cuTexRefGetFormat
Functions
• CUresult cuGLCtxCreate (CUcontext ∗pCtx, unsigned int Flags, CUdevice device)
Create a CUDA context for interoperability with OpenGL.
• CUresult cuGLMapBufferObjectAsync (CUdeviceptr ∗dptr, unsigned int ∗size, GLuint bufferobj, CUstream
hStream)
Maps an OpenGL buffer object.
This section describes the OpenGL interoperability functions of the low-level CUDA driver application programming
interface.
Creates a new CUDA context, initializes OpenGL interoperability, and associates the CUDA context with the calling
thread. It must be called before performing any other OpenGL interoperability operations. It may fail if the needed
OpenGL driver facilities are not available. For usage of the Flags parameter, see cuCtxCreate().
Parameters:
pCtx - Returned CUDA context
Flags - Options for CUDA context creation
device - Device on which to create the context
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuCtxCreate, cuGLInit, cuGLMapBufferObject, cuGLRegisterBufferObject, cuGLUnmapBufferObject,
cuGLUnregisterBufferObject, cuGLMapBufferObjectAsync, cuGLUnmapBufferObjectAsync, cuGLSetBuffer-
ObjectMapFlags, cuWGLGetDevice
Initializes OpenGL interoperability. It must be called before performing any other OpenGL interoperability operations.
It may fail if the needed OpenGL driver facilities are not available.
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLMapBufferObject, cuGLRegisterBufferObject, cuGLUnmapBufferObject, cuGLUn-
registerBufferObject, cuGLMapBufferObjectAsync, cuGLUnmapBufferObjectAsync, cuGLSetBufferOb-
jectMapFlags, cuWGLGetDevice
Maps the buffer object of ID bufferobj into the address space of the current CUDA context and returns in ∗dptr
and ∗size the base pointer and size of the resulting mapping.
All streams in the current CUDA context are synchronized with the current GL context.
Parameters:
dptr - Returned mapped base pointer
size - Returned size of mapping
bufferobj - Buffer object to map
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_MAP_FAILED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLRegisterBufferObject, cuGLUnmapBufferObject, cuGLUnregisterBufferObject,
cuGLMapBufferObjectAsync, cuGLUnmapBufferObjectAsync, cuGLSetBufferObjectMapFlags, cuWGLGet-
Device
Maps the buffer object of ID bufferobj into the address space of the current CUDA context and returns in ∗dptr
and ∗size the base pointer and size of the resulting mapping.
Stream hStream in the current CUDA context is synchronized with the current GL context.
Parameters:
dptr - Returned mapped base pointer
size - Returned size of mapping
bufferobj - Buffer object to map
hStream - Stream to synchronize
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_MAP_FAILED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLRegisterBufferObject, cuGLUnmapBufferObject, cuGLUnregisterBufferObject,
cuGLUnmapBufferObjectAsync, cuGLSetBufferObjectMapFlags,cuWGLGetDevice
Registers the buffer object of ID bufferobj for access by CUDA. This function must be called before CUDA can
map the buffer object. While it is registered, the buffer object cannot be used by any OpenGL commands, except as a
data source for OpenGL drawing commands.
Parameters:
bufferobj - Buffer object to register
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_ALREADY_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLMapBufferObject, cuGLUnmapBufferObject, cuGLMapBufferObjectAsync,
cuGLUnmapBufferObjectAsync, cuGLSetBufferObjectMapFlags, cuGLUnregisterBufferObject, cuWGLGetDe-
vice
Sets the map flags for the registered buffer object of ID bufferobj.
Changes to Flags will take effect the next time bufferobj is mapped. The Flags argument may be any of the
following:
If bufferobj has not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned.
If bufferobj is presently mapped for access by CUDA, then CUDA_ERROR_ALREADY_MAPPED is returned.
Parameters:
bufferobj - Buffer object to unmap
Flags - Map flags
Returns:
CUDA_SUCCESS, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_HANDLE, CUDA_-
ERROR_ALREADY_MAPPED, CUDA_ERROR_INVALID_CONTEXT,
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLMapBufferObject, cuGLRegisterBufferObject, cuGLUnregisterBufferObject,
cuGLUnmapBufferObject, cuGLMapBufferObjectAsync, cuGLUnmapBufferObjectAsync, cuWGLGetDevice
Parameters:
bufferobj - Buffer object to unmap
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLMapBufferObject, cuGLRegisterBufferObject, cuGLUnregisterBufferObject,
cuGLMapBufferObjectAsync, cuGLUnmapBufferObjectAsync, cuGLSetBufferObjectMapFlags, cuWGLGet-
Device
Parameters:
bufferobj - Buffer object to unmap
hStream - Stream to synchronize
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLMapBufferObject, cuGLRegisterBufferObject, cuGLUnregisterBufferObject,
cuGLMapBufferObjectAsync, cuGLSetBufferObjectMapFlags, cuWGLGetDevice
Parameters:
bufferobj - Buffer object to unmap
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLMapBufferObject, cuGLRegisterBufferObject, cuGLUnmapBufferObject,
cuGLMapBufferObjectAsync, cuGLUnmapBufferObjectAsync, cuGLSetBufferObjectMapFlags, cuWGLGet-
Device
Parameters:
pDevice - Device associated with hGpu
hGpu - Handle to a GPU, as queried via WGL_NV_gpu_affinity()
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuGLCtxCreate, cuGLInit, cuGLMapBufferObject, cuGLRegisterBufferObject, cuGLUnmapBufferObject,
cuGLUnregisterBufferObject, cuGLUnmapBufferObjectAsync, cuGLSetBufferObjectMapFlags
Functions
• CUresult cuD3D9CtxCreate (CUcontext ∗pCtx, CUdevice ∗pCuDevice, unsigned int Flags, IDirect3DDevice9
∗pDxDevice)
Create a CUDA context for interoperability with Direct3D.
• CUresult cuD3D9ResourceGetSurfaceDimensions (unsigned int ∗pWidth, unsigned int ∗pHeight, unsigned int
∗pDepth, IDirect3DResource9 ∗pResource, unsigned int Face, unsigned int Level)
Get the dimensions of a registered surface.
This section describes the Direct3D 9 interoperability functions of the low-level CUDA driver application program-
ming interface.
Creates a new CUDA context, enables interoperability for that context with the Direct3D device pDxDevice, and as-
sociates the created CUDA context with the calling thread. The CUcontext will be returned in ∗pCtx. If pCuDevice
is non-NULL, then the CUdevice on which this CUDA context was created will be returned in ∗pCuDevice. For
usage of the Flags parameter, see cuCtxCreate(). Direct3D resources from this device may be registered and mapped
through the lifetime of this CUDA context.
This context will function only until its Direct3D device is destroyed. On success, this call will increase the internal
reference count on pDxDevice. This reference count will be decremented upon destruction of this context through
cuCtxDestroy().
Parameters:
pCtx - Returned newly created CUDA context
pCuDevice - Returned pointer to device on which context was created
Flags - Context creation flags (see cuCtxCreate() for details)
pDxDevice - Direct3D device to create interoperability context with
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources, cuD3D9RegisterResource,
cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch, cuD3D9ResourceGetMappedPointer,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Returns in ∗pDevice the CUDA-compatible device corresponding to the adapter name pszAdapterName ob-
tained from EnumDisplayDevices() or IDirect3D9::GetAdapterIdentifier(). If no device on the adapter with name
pszAdapterName is CUDA-compatible, then the call will fail.
Parameters:
pDevice - Returned CUDA device corresponding to pszAdapterName
pszAdapterName - Adapter name to query for device
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_VALUE, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDirect3DDevice, cuD3D9MapResources, cuD3D9RegisterResource,
cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch, cuD3D9ResourceGetMappedPointer,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Returns in ∗ppDxDevice the Direct3D device against which this CUDA context was created in cuD3D9CtxCreate().
Parameters:
ppDxDevice - Returned Direct3D device corresponding to CUDA context
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9MapResources, cuD3D9RegisterResource,
cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch, cuD3D9ResourceGetMappedPointer,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Parameters:
count - Number of resources in ppResource
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_ALREADY_-
MAPPED, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9RegisterResource,
cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch, cuD3D9ResourceGetMappedPointer,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
The Flags argument specifies the mechanism through which CUDA will access the Direct3D resource. The following
values are allowed.
• CU_D3D9_REGISTER_FLAGS_NONE: Specifies that CUDA will access this resource through a CUd-
eviceptr. The pointer, size, and (for textures), pitch for each subresource of this allocation
may be queried through cuD3D9ResourceGetMappedPointer(), cuD3D9ResourceGetMappedSize(), and
cuD3D9ResourceGetMappedPitch() respectively. This option is valid for all resource types.
• CU_D3D9_REGISTER_FLAGS_ARRAY: Specifies that CUDA will access this resource through a CUarray
queried on a sub-resource basis through cuD3D9ResourceGetMappedArray(). This option is only valid for
resources of type IDirect3DSurface9 and subtypes of IDirect3DBaseTexture9.
Not all Direct3D resources of the above types may be used for interoperability with CUDA. The following are some
limitations.
• Textures which are not of a format which is 1, 2, or 4 channels of 8, 16, or 32-bit integer or floating-point data
cannot be shared.
Parameters:
pResource - Resource to register for CUDA access
Flags - Flags for resource registration
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch, cuD3D9ResourceGetMappedPointer,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Returns in ∗pArray an array through which the subresource of the mapped Direct3D resource pResource
which corresponds to Face and Level may be accessed. The value set in pArray may change every time that
pResource is mapped.
If pResource is not registered then CUDA_ERROR_INVALID_HANDLE is returned. If pResource was not
registered with usage flags CU_D3D9_REGISTER_FLAGS_ARRAY then CUDA_ERROR_INVALID_HANDLE is
returned. If pResource is not mapped then CUDA_ERROR_NOT_MAPPED is returned.
For usage requirements of Face and Level parameters, see cuD3D9ResourceGetMappedPointer().
Parameters:
pArray - Returned array corresponding to subresource
pResource - Mapped resource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedPitch, cuD3D9ResourceGetMappedPointer,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Returns in ∗pPitch and ∗pPitchSlice the pitch and Z-slice pitch of the subresource of the mapped Direct3D
resource pResource, which corresponds to Face and Level. The values set in pPitch and pPitchSlice may
change every time that pResource is mapped.
The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.
For a 2D surface, the byte offset of the sample at position x, y from the base pointer of the surface is:
y ∗ pitch + (bytes per pixel) ∗ x
For a 3D surface, the byte offset of the sample at position x, y, z from the base pointer of the surface is:
z∗ slicePitch + y ∗ pitch + (bytes per pixel) ∗ x
Both parameters pPitch and pPitchSlice are optional and may be set to NULL.
If pResource is not of type IDirect3DBaseTexture9 or one of its sub-types or if pResource has not been reg-
istered for use with CUDA, then cudaErrorInvalidResourceHandle is returned. If pResource was not registered
with usage flags CU_D3D9_REGISTER_FLAGS_NONE, then CUDA_ERROR_INVALID_HANDLE is returned. If
pResource is not mapped for access by CUDA then CUDA_ERROR_NOT_MAPPED is returned.
For usage requirements of Face and Level parameters, see cuD3D9ResourceGetMappedPointer().
Parameters:
pPitch - Returned pitch of subresource
pPitchSlice - Returned Z-slice pitch of subresource
pResource - Mapped resource to access
Face - Face of resource to access
Level - Level of resource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPointer,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Returns in ∗pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource, which
corresponds to Face and Level. The value set in pDevPtr may change every time that pResource is mapped.
If pResource is not registered, then CUDA_ERROR_INVALID_HANDLE is returned. If pResource was not
registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE, then CUDA_ERROR_INVALID_HANDLE is
returned. If pResource is not mapped, then CUDA_ERROR_NOT_MAPPED is returned.
If pResource is of type IDirect3DCubeTexture9, then Face must one of the values enumerated by type
D3DCUBEMAP_FACES. For all other types Face must be 0. If Face is invalid, then CUDA_ERROR_INVALID_-
VALUE is returned.
If pResource is of type IDirect3DBaseTexture9, then Level must correspond to a valid mipmap level. At present
only mipmap level 0 is supported. For all other types Level must be 0. If Level is invalid, then CUDA_ERROR_-
INVALID_VALUE is returned.
Parameters:
pDevPtr - Returned pointer corresponding to subresource
pResource - Mapped resource to access
Face - Face of resource to access
Level - Level of resource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch,
cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Returns in ∗pSize the size of the subresource of the mapped Direct3D resource pResource, which corresponds to
Face and Level. The value set in pSize may change every time that pResource is mapped.
If pResource has not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned.
If pResource was not registered with usage flags CU_D3D9_REGISTER_FLAGS_NONE, then CUDA_ERROR_-
INVALID_HANDLE is returned. If pResource is not mapped for access by CUDA, then CUDA_ERROR_NOT_-
MAPPED is returned.
For usage requirements of Face and Level parameters, see cuD3D9ResourceGetMappedPointer.
Parameters:
pSize - Returned size of subresource
pResource - Mapped resource to access
Face - Face of resource to access
Level - Level of resource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch,
cuD3D9ResourceGetMappedPointer, cuD3D9ResourceGetSurfaceDimensions, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Returns in ∗pWidth, ∗pHeight, and ∗pDepth the dimensions of the subresource of the mapped Direct3D resource
pResource, which corresponds to Face and Level.
Because anti-aliased surfaces may have multiple samples per pixel, it is possible that the dimensions of a resource will
be an integer factor larger than the dimensions reported by the Direct3D runtime.
The parameters pWidth, pHeight, and pDepth are optional. For 2D surfaces, the value returned in ∗pDepth will
be 0.
If pResource is not of type IDirect3DBaseTexture9 or IDirect3DSurface9 or if pResource has not been registered
for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned.
For usage requirements of Face and Level parameters, see cuD3D9ResourceGetMappedPointer().
Parameters:
pWidth - Returned width of surface
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch,
cuD3D9ResourceGetMappedPointer, cuD3D9ResourceGetMappedSize, cuD3D9ResourceSetMapFlags,
cuD3D9UnmapResources, cuD3D9UnregisterResource
If pResource has not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned.
If pResource is presently mapped for access by CUDA, then CUDA_ERROR_ALREADY_MAPPED is returned.
Parameters:
pResource - Registered resource to set flags for
Flags - Parameters for resource mapping
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_ALREADY_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch,
cuD3D9ResourceGetMappedPointer, cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions,
cuD3D9UnmapResources, cuD3D9UnregisterResource
Parameters:
count - Number of resources to unmap for CUDA
ppResource - Resources to unmap for CUDA
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_NOT_MAPPED,
CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch,
cuD3D9ResourceGetMappedPointer, cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions,
cuD3D9ResourceSetMapFlags, cuD3D9UnregisterResource
Unregisters the Direct3D resource pResource so it is not accessible by CUDA unless registered again.
If pResource is not registered, then CUDA_ERROR_INVALID_HANDLE is returned.
Parameters:
pResource - Resource to unregister
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D9CtxCreate, cuD3D9GetDevice, cuD3D9GetDirect3DDevice, cuD3D9MapResources,
cuD3D9RegisterResource, cuD3D9ResourceGetMappedArray, cuD3D9ResourceGetMappedPitch,
cuD3D9ResourceGetMappedPointer, cuD3D9ResourceGetMappedSize, cuD3D9ResourceGetSurfaceDimensions,
cuD3D9ResourceSetMapFlags, cuD3D9UnmapResources
Functions
• CUresult cuD3D10CtxCreate (CUcontext ∗pCtx, CUdevice ∗pCuDevice, unsigned int Flags, ID3D10Device
∗pDxDevice)
Create a CUDA context for interoperability with Direct3D.
• CUresult cuD3D10ResourceGetSurfaceDimensions (unsigned int ∗pWidth, unsigned int ∗pHeight, unsigned int
∗pDepth, ID3D10Resource ∗pResource, unsigned int SubResource)
Get the dimensions of a registered surface.
This section describes the Direct3D 10 interoperability functions of the low-level CUDA driver application program-
ming interface.
3.29.2.1 cuD3D10CtxCreate (CUcontext ∗ pCtx, CUdevice ∗ pCuDevice, unsigned int Flags, ID3D10Device
∗ pDxDevice)
Creates a new CUDA context, enables interoperability for that context with the Direct3D device pDxDevice, and as-
sociates the created CUDA context with the calling thread. The CUcontext will be returned in ∗pCtx. If pCuDevice
is non-NULL, then the CUdevice on which this CUDA context was created will be returned in ∗pCuDevice. For
usage of the Flags parameter, see cuCtxCreate(). Direct3D resources from this device may be registered and mapped
through the lifetime of this CUDA context.
This context will function only until its Direct3D device is destroyed. On success, this call will increase the internal
reference count on pDxDevice. This reference count will be decremented upon destruction of this context through
cuCtxDestroy().
Parameters:
pCtx - Returned newly created CUDA context
pCuDevice - Returned pointer to device on which context was created
Flags - Context creation flags (see cuCtxCreate() for details)
pDxDevice - Direct3D device to create interoperability context with
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_VALUE, CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource, cuD3D10ResourceGetMappedArray,
cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer, cuD3D10ResourceGetMappedSize,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Returns in ∗pDevice the Cuda-compatible device corresponding to the adapter pAdapter obtained from IDXGI-
Factory::EnumAdapters. This call will succeed only if a device on adapter pAdapter is Cuda-compatible.
Parameters:
pDevice - Returns the device corresponding to pAdapter
pAdapter - D3D10 adapter to get device for
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_VALUE, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10MapResources, cuD3D10RegisterResource, cuD3D10ResourceGetMappedArray,
cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer, cuD3D10ResourceGetMappedSize,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Parameters:
count - Number of resources to map for CUDA
ppResources - Resources to map for CUDA
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_ALREADY_-
MAPPED, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10RegisterResource, cuD3D10ResourceGetMappedArray,
cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer, cuD3D10ResourceGetMappedSize,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
• ID3D10Texture1D: No restrictions.
• ID3D10Texture2D: No restrictions.
• ID3D10Texture3D: No restrictions.
The Flags argument specifies the mechanism through which CUDA will access the Direct3D resource. The following
values are allowed.
Not all Direct3D resources of the above types may be used for interoperability with CUDA. The following are some
limitations.
Parameters:
pResource - Resource to register
Flags - Parameters for resource registration
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_OUT_OF_MEMORY, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10ResourceGetMappedArray,
cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer, cuD3D10ResourceGetMappedSize,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Returns in ∗pArray an array through which the subresource of the mapped Direct3D resource pResource, which
corresponds to SubResource may be accessed. The value set in pArray may change every time that pResource
is mapped.
If pResource is not registered, then CUDA_ERROR_INVALID_HANDLE is returned. If pResource was not
registered with usage flags CU_D3D10_REGISTER_FLAGS_ARRAY, then CUDA_ERROR_INVALID_HANDLE
is returned. If pResource is not mapped, then CUDA_ERROR_NOT_MAPPED is returned.
For usage requirements of the SubResource parameter, see cuD3D10ResourceGetMappedPointer().
Parameters:
pArray - Returned array corresponding to subresource
pResource - Mapped resource to access
SubResource - Subresource of pResource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer, cuD3D10ResourceGetMappedSize,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Returns in ∗pPitch and ∗pPitchSlice the pitch and Z-slice pitch of the subresource of the mapped Direct3D
resource pResource, which corresponds to SubResource. The values set in pPitch and pPitchSlice may
change every time that pResource is mapped.
The pitch and Z-slice pitch values may be used to compute the location of a sample on a surface as follows.
For a 2D surface, the byte offset of the sample at position x, y from the base pointer of the surface is:
y ∗ pitch + (bytes per pixel) ∗ x
For a 3D surface, the byte offset of the sample at position x, y, z from the base pointer of the surface is:
z∗ slicePitch + y ∗ pitch + (bytes per pixel) ∗ x
Both parameters pPitch and pPitchSlice are optional and may be set to NULL.
If pResource is not of type IDirect3DBaseTexture10 or one of its sub-types or if pResource has not been regis-
tered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned. If pResource was not registered
with usage flags CU_D3D10_REGISTER_FLAGS_NONE, then CUDA_ERROR_INVALID_HANDLE is returned.
If pResource is not mapped for access by CUDA, then CUDA_ERROR_NOT_MAPPED is returned.
Parameters:
pPitch - Returned pitch of subresource
pPitchSlice - Returned Z-slice pitch of subresource
pResource - Mapped resource to access
SubResource - Subresource of pResource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedArray, cuD3D10ResourceGetMappedPointer, cuD3D10ResourceGetMappedSize,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Returns in ∗pDevPtr the base pointer of the subresource of the mapped Direct3D resource pResource, which
corresponds to SubResource. The value set in pDevPtr may change every time that pResource is mapped.
If pResource is not registered, then CUDA_ERROR_INVALID_HANDLE is returned. If pResource was not
registered with usage flags CU_D3D10_REGISTER_FLAGS_NONE, then CUDA_ERROR_INVALID_HANDLE is
returned. If pResource is not mapped, then CUDA_ERROR_NOT_MAPPED is returned.
If pResource is of type ID3D10Buffer, then SubResource must be 0. If pResource is of any other type, then
the value of SubResource must come from the subresource calculation in D3D10CalcSubResource().
Parameters:
pDevPtr - Returned pointer corresponding to subresource
pResource - Mapped resource to access
SubResource - Subresource of pResource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedArray, cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedSize,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Returns in ∗pSize the size of the subresource of the mapped Direct3D resource pResource, which corresponds to
SubResource. The value set in pSize may change every time that pResource is mapped.
If pResource has not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned. If
pResource was not registered with usage flags CU_D3D10_REGISTER_FLAGS_NONE, then CUDA_ERROR_-
INVALID_HANDLE is returned. If pResource is not mapped for access by CUDA, then CUDA_ERROR_NOT_-
MAPPED is returned.
For usage requirements of the SubResource parameter, see cuD3D10ResourceGetMappedPointer().
Parameters:
pSize - Returned size of subresource
pResource - Mapped resource to access
SubResource - Subresource of pResource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedArray, cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer,
cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Returns in ∗pWidth, ∗pHeight, and ∗pDepth the dimensions of the subresource of the mapped Direct3D resource
pResource, which corresponds to SubResource.
Because anti-aliased surfaces may have multiple samples per pixel, it is possible that the dimensions of a resource will
be an integer factor larger than the dimensions reported by the Direct3D runtime.
The parameters pWidth, pHeight, and pDepth are optional. For 2D surfaces, the value returned in ∗pDepth will
be 0.
If pResource is not of type IDirect3DBaseTexture10 or IDirect3DSurface10 or if pResource has not been regis-
tered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned.
For usage requirements of the SubResource parameter, see cuD3D10ResourceGetMappedPointer().
Parameters:
pWidth - Returned width of surface
pHeight - Returned height of surface
pDepth - Returned depth of surface
pResource - Registered resource to access
SubResource - Subresource of pResource to access
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedArray, cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer,
cuD3D10ResourceGetMappedSize, cuD3D10ResourceSetMapFlags, cuD3D10UnmapResources,
cuD3D10UnregisterResource
If pResource has not been registered for use with CUDA, then CUDA_ERROR_INVALID_HANDLE is returned.
If pResource is presently mapped for access by CUDA then CUDA_ERROR_ALREADY_MAPPED is returned.
Parameters:
pResource - Registered resource to set flags for
Flags - Parameters for resource mapping
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_ALREADY_MAPPED
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedArray, cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer,
cuD3D10ResourceGetMappedSize, cuD3D10ResourceGetSurfaceDimensions, cuD3D10UnmapResources,
cuD3D10UnregisterResource
Parameters:
count - Number of resources to unmap for CUDA
ppResources - Resources to unmap for CUDA
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_MAPPED, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedArray, cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer,
cuD3D10ResourceGetMappedSize, cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags,
cuD3D10UnregisterResource
Unregisters the Direct3D resource pResource so it is not accessible by CUDA unless registered again.
If pResource is not registered, then CUDA_ERROR_INVALID_HANDLE is returned.
Parameters:
pResource - Resources to unregister
Returns:
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_-
ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_HANDLE, CUDA_ERROR_UNKNOWN
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cuD3D10CtxCreate, cuD3D10GetDevice, cuD3D10MapResources, cuD3D10RegisterResource,
cuD3D10ResourceGetMappedArray, cuD3D10ResourceGetMappedPitch, cuD3D10ResourceGetMappedPointer,
cuD3D10ResourceGetMappedSize, cuD3D10ResourceGetSurfaceDimensions, cuD3D10ResourceSetMapFlags,
cuD3D10UnmapResources
Data Structures
• struct CUDA_ARRAY3D_DESCRIPTOR
• struct CUDA_ARRAY_DESCRIPTOR
• struct CUDA_MEMCPY2D_st
• struct CUDA_MEMCPY3D_st
• struct CUdevprop_st
Author:
NVIDIA Corporation
• enum CUaddress_mode_enum {
CU_TR_ADDRESS_MODE_WRAP,
CU_TR_ADDRESS_MODE_CLAMP,
CU_TR_ADDRESS_MODE_MIRROR }
• enum CUarray_format_enum {
CU_AD_FORMAT_UNSIGNED_INT8,
CU_AD_FORMAT_UNSIGNED_INT16,
CU_AD_FORMAT_UNSIGNED_INT32,
CU_AD_FORMAT_SIGNED_INT8,
CU_AD_FORMAT_SIGNED_INT16,
CU_AD_FORMAT_SIGNED_INT32,
CU_AD_FORMAT_HALF,
CU_AD_FORMAT_FLOAT }
• enum CUcomputemode_enum {
CU_COMPUTEMODE_DEFAULT,
CU_COMPUTEMODE_EXCLUSIVE,
CU_COMPUTEMODE_PROHIBITED }
• enum CUctx_flags_enum {
CU_CTX_SCHED_AUTO,
CU_CTX_SCHED_SPIN,
CU_CTX_SCHED_YIELD ,
CU_CTX_BLOCKING_SYNC,
CU_CTX_MAP_HOST,
CU_CTX_LMEM_RESIZE_TO_MAX }
• enum cudaError_enum {
CUDA_SUCCESS,
CUDA_ERROR_INVALID_VALUE,
CUDA_ERROR_OUT_OF_MEMORY,
CUDA_ERROR_NOT_INITIALIZED,
CUDA_ERROR_DEINITIALIZED,
CUDA_ERROR_NO_DEVICE,
CUDA_ERROR_INVALID_DEVICE,
CUDA_ERROR_INVALID_IMAGE,
CUDA_ERROR_INVALID_CONTEXT,
CUDA_ERROR_CONTEXT_ALREADY_CURRENT,
CUDA_ERROR_MAP_FAILED,
CUDA_ERROR_UNMAP_FAILED,
CUDA_ERROR_ARRAY_IS_MAPPED,
CUDA_ERROR_ALREADY_MAPPED,
CUDA_ERROR_NO_BINARY_FOR_GPU,
CUDA_ERROR_ALREADY_ACQUIRED,
CUDA_ERROR_NOT_MAPPED,
CUDA_ERROR_INVALID_SOURCE,
CUDA_ERROR_FILE_NOT_FOUND,
CUDA_ERROR_INVALID_HANDLE,
CUDA_ERROR_NOT_FOUND,
CUDA_ERROR_NOT_READY,
CUDA_ERROR_LAUNCH_FAILED,
CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
CUDA_ERROR_LAUNCH_TIMEOUT,
CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
CUDA_ERROR_UNKNOWN }
• enum CUdevice_attribute_enum {
CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK,
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X,
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y,
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z,
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X,
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y,
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z,
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK,
CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK,
CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY,
CU_DEVICE_ATTRIBUTE_WARP_SIZE,
CU_DEVICE_ATTRIBUTE_MAX_PITCH,
CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK,
CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK,
CU_DEVICE_ATTRIBUTE_CLOCK_RATE,
CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT,
CU_DEVICE_ATTRIBUTE_GPU_OVERLAP,
CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT,
CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT,
CU_DEVICE_ATTRIBUTE_INTEGRATED,
CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY,
CU_DEVICE_ATTRIBUTE_COMPUTE_MODE }
• enum CUevent_flags_enum {
CU_EVENT_DEFAULT,
CU_EVENT_BLOCKING_SYNC }
• enum CUfilter_mode_enum {
CU_TR_FILTER_MODE_POINT,
CU_TR_FILTER_MODE_LINEAR }
• enum CUfunction_attribute_enum {
CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK,
CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES,
CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES,
CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES,
CU_FUNC_ATTRIBUTE_NUM_REGS }
• enum CUjit_fallback_enum {
CU_PREFER_PTX,
CU_PREFER_BINARY }
• enum CUjit_option_enum {
CU_JIT_MAX_REGISTERS,
CU_JIT_THREADS_PER_BLOCK,
CU_JIT_WALL_TIME,
CU_JIT_INFO_LOG_BUFFER,
CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES,
CU_JIT_ERROR_LOG_BUFFER,
CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES,
CU_JIT_OPTIMIZATION_LEVEL,
CU_JIT_TARGET_FROM_CUCONTEXT,
CU_JIT_TARGET,
CU_JIT_FALLBACK_STRATEGY }
• enum CUjit_target_enum {
CU_TARGET_COMPUTE_10,
CU_TARGET_COMPUTE_11,
CU_TARGET_COMPUTE_12,
CU_TARGET_COMPUTE_13 }
• enum CUmemorytype_enum {
CU_MEMORYTYPE_HOST,
CU_MEMORYTYPE_DEVICE,
CU_MEMORYTYPE_ARRAY }
• typedef enum CUaddress_mode_enum CUaddress_mode
• typedef struct CUarray_st ∗ CUarray
CUDA array.
• #define CU_MEMHOSTALLOC_DEVICEMAP
• #define CU_MEMHOSTALLOC_PORTABLE
• #define CU_MEMHOSTALLOC_WRITECOMBINED
• #define CU_PARAM_TR_DEFAULT
• #define CU_TRSA_OVERRIDE_FORMAT
• #define CU_TRSF_NORMALIZED_COORDINATES
• #define CU_TRSF_READ_AS_INTEGER
• #define CUDA_VERSION
If set, host memory is mapped into CUDA address space and cuMemHostGetDevicePointer() may be called on the
host pointer. Flag for cuMemHostAlloc()
If set, host memory is portable between CUDA contexts. Flag for cuMemHostAlloc()
If set, host memory is allocated as write-combined - fast to write, faster to DMA, slow to read except via SSE4
streaming load instruction (MOVNTDQA). Flag for cuMemHostAlloc()
For texture references loaded into the module, use default texunit from texture reference.
Override the texref format with a format inferred from the array. Flag for cuTexRefSetArray()
Use normalized texture coordinates in the range [0,1) instead of [0,dim). Flag for cuTexRefSetFlags()
Read the texture as integers rather than promoting the values to floats in the range [0,1]. Flag for cuTexRefSetFlags()
Array formats
Compute Modes
Device properties
Function properties
Memory types
Error codes
Enumerator:
CU_TR_ADDRESS_MODE_WRAP Wrapping address mode.
CU_TR_ADDRESS_MODE_CLAMP Clamp to edge address mode.
CU_TR_ADDRESS_MODE_MIRROR Mirror address mode.
Array formats
Enumerator:
CU_AD_FORMAT_UNSIGNED_INT8 Unsigned 8-bit integers.
CU_AD_FORMAT_UNSIGNED_INT16 Unsigned 16-bit integers.
CU_AD_FORMAT_UNSIGNED_INT32 Unsigned 32-bit integers.
CU_AD_FORMAT_SIGNED_INT8 Signed 8-bit integers.
CU_AD_FORMAT_SIGNED_INT16 Signed 16-bit integers.
CU_AD_FORMAT_SIGNED_INT32 Signed 32-bit integers.
CU_AD_FORMAT_HALF 16-bit floating point
CU_AD_FORMAT_FLOAT 32-bit floating point
Compute Modes
Enumerator:
CU_COMPUTEMODE_DEFAULT Default compute mode (Multiple contexts allowed per device).
CU_COMPUTEMODE_EXCLUSIVE Compute-exclusive mode (Only one context can be present on this de-
vice at a time).
CU_COMPUTEMODE_PROHIBITED Compute-prohibited mode (No contexts can be created on this device
at this time).
Enumerator:
CU_CTX_SCHED_AUTO Automatic scheduling.
CU_CTX_SCHED_SPIN Set spin as default scheduling.
CU_CTX_SCHED_YIELD Set yield as default scheduling.
CU_CTX_BLOCKING_SYNC Use blocking synchronization.
CU_CTX_MAP_HOST Support mapped pinned allocations.
CU_CTX_LMEM_RESIZE_TO_MAX Keep local memory allocation after launch.
Error codes
Enumerator:
CUDA_SUCCESS No errors.
CUDA_ERROR_INVALID_VALUE Invalid value.
CUDA_ERROR_OUT_OF_MEMORY Out of memory.
CUDA_ERROR_NOT_INITIALIZED Driver not initialized.
CUDA_ERROR_DEINITIALIZED Driver deinitialized.
CUDA_ERROR_NO_DEVICE No CUDA-capable device available.
CUDA_ERROR_INVALID_DEVICE Invalid device.
CUDA_ERROR_INVALID_IMAGE Invalid kernel image.
CUDA_ERROR_INVALID_CONTEXT Invalid context.
CUDA_ERROR_CONTEXT_ALREADY_CURRENT Context already current.
CUDA_ERROR_MAP_FAILED Map failed.
CUDA_ERROR_UNMAP_FAILED Unmap failed.
CUDA_ERROR_ARRAY_IS_MAPPED Array is mapped.
CUDA_ERROR_ALREADY_MAPPED Already mapped.
CUDA_ERROR_NO_BINARY_FOR_GPU No binary for GPU.
CUDA_ERROR_ALREADY_ACQUIRED Already acquired.
CUDA_ERROR_NOT_MAPPED Not mapped.
CUDA_ERROR_INVALID_SOURCE Invalid source.
CUDA_ERROR_FILE_NOT_FOUND File not found.
CUDA_ERROR_INVALID_HANDLE Invalid handle.
CUDA_ERROR_NOT_FOUND Not found.
CUDA_ERROR_NOT_READY CUDA not ready.
CUDA_ERROR_LAUNCH_FAILED Launch failed.
CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES Launch exceeded resources.
CUDA_ERROR_LAUNCH_TIMEOUT Launch exceeded timeout.
CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING Launch with incompatible texturing.
CUDA_ERROR_UNKNOWN Unknown error.
Device properties
Enumerator:
CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK Maximum number of threads per block.
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X Maximum block dimension X.
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y Maximum block dimension Y.
CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z Maximum block dimension Z.
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X Maximum grid dimension X.
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y Maximum grid dimension Y.
CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z Maximum grid dimension Z.
CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK Maximum shared memory avail-
able per block in bytes.
CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK Deprecated, use CU_DEVICE_-
ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK.
CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY Memory available on device for __constant_-
_ variables in a CUDA C kernel in bytes.
CU_DEVICE_ATTRIBUTE_WARP_SIZE Warp size in threads.
CU_DEVICE_ATTRIBUTE_MAX_PITCH Maximum pitch in bytes allowed by memory copies.
CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK Maximum number of 32-bit registers avail-
able per block.
CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK Deprecated, use CU_DEVICE_ATTRIBUTE_-
MAX_REGISTERS_PER_BLOCK.
CU_DEVICE_ATTRIBUTE_CLOCK_RATE Peak clock frequency in kilohertz.
CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT Alignment requirement for textures.
CU_DEVICE_ATTRIBUTE_GPU_OVERLAP Device can possibly copy memory and execute a kernel con-
currently.
CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT Number of multiprocessors on device.
CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT Specifies whether there is a run time limit on ker-
nels.
CU_DEVICE_ATTRIBUTE_INTEGRATED Device is integrated with host memory.
CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY Device can map host memory into CUDA ad-
dress space.
CU_DEVICE_ATTRIBUTE_COMPUTE_MODE Compute mode (See CUcomputemode for details).
Enumerator:
CU_EVENT_DEFAULT Default event flag.
CU_EVENT_BLOCKING_SYNC Event uses blocking synchronization.
Enumerator:
CU_TR_FILTER_MODE_POINT Point filter mode.
CU_TR_FILTER_MODE_LINEAR Linear filter mode.
Function properties
Enumerator:
CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK The number of threads beyond which a launch of
the function would fail. This number depends on both the function and the device on which the function is
currently loaded.
CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES The size in bytes of statically-allocated shared memory
required by this function. This does not include dynamically-allocated shared memory requested by the user
at runtime.
CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES The size in bytes of user-allocated constant memory re-
quired by this function.
CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES The size in bytes of thread local memory used by this func-
tion.
CU_FUNC_ATTRIBUTE_NUM_REGS The number of registers used by each thread of this function.
Enumerator:
CU_PREFER_PTX Prefer to compile ptx
CU_PREFER_BINARY Prefer to fall back to compatible binary code
Enumerator:
CU_JIT_MAX_REGISTERS Max number of registers that a thread may use.
CU_JIT_THREADS_PER_BLOCK IN: Specifies minimum number of threads per block to target compilation
for
OUT: Returns the number of threads the compiler actually targeted. This restricts the resource utilization
fo the compiler (e.g. max registers) such that a block with the given number of threads should be able to
launch based on register limitations. Note, this option does not currently take into account any other resource
limitations, such as shared memory utilization.
CU_JIT_WALL_TIME Returns a float value in the option of the wall clock time, in milliseconds, spent creating
the cubin
CU_JIT_INFO_LOG_BUFFER Pointer to a buffer in which to print any log messsages from PTXAS that are
informational in nature
CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES IN: Log buffer size in bytes. Log messages will be capped at
this size (including null terminator)
OUT: Amount of log buffer filled with messages
CU_JIT_ERROR_LOG_BUFFER Pointer to a buffer in which to print any log messages from PTXAS that
reflect errors
CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES IN: Log buffer size in bytes. Log messages will be capped
at this size (including null terminator)
OUT: Amount of log buffer filled with messages
CU_JIT_OPTIMIZATION_LEVEL Level of optimizations to apply to generated code (0 - 4), with 4 being the
default and highest level of optimizations.
CU_JIT_TARGET_FROM_CUCONTEXT No option value required. Determines the target based on the cur-
rent attached context (default)
CU_JIT_TARGET Target is chosen based on supplied CUjit_target_enum.
CU_JIT_FALLBACK_STRATEGY Specifies choice of fallback strategy if matching cubin is not found. Choice
is based on supplied CUjit_fallback_enum.
Enumerator:
CU_TARGET_COMPUTE_10 Compute device class 1.0.
CU_TARGET_COMPUTE_11 Compute device class 1.1.
CU_TARGET_COMPUTE_12 Compute device class 1.2.
CU_TARGET_COMPUTE_13 Compute device class 1.3.
Memory types
Enumerator:
CU_MEMORYTYPE_HOST Host memory.
CU_MEMORYTYPE_DEVICE Device memory.
CU_MEMORYTYPE_ARRAY Array memory.
Data Fields
• unsigned int Depth
Depth of 3D array.
• CUarray_format Format
Array format.
3D array descriptor
214 Data Structure Documentation
Data Fields
• CUarray_format Format
Array format.
Array descriptor
Data Fields
• CUarray dstArray
Destination array reference.
• CUdeviceptr dstDevice
Destination device pointer.
• void ∗ dstHost
Destination host pointer.
• CUmemorytype dstMemoryType
Destination memory type (host, device, array).
• CUarray srcArray
Source array reference.
• CUdeviceptr srcDevice
Source device pointer.
• CUmemorytype srcMemoryType
Source memory type (host, device, array).
Data Fields
• unsigned int Depth
Depth of 3D memory copy.
• CUarray dstArray
Destination array reference.
• CUdeviceptr dstDevice
Destination device pointer.
• void ∗ dstHost
Destination host pointer.
• CUmemorytype dstMemoryType
Destination memory type (host, device, array).
• void ∗ reserved0
Must be NULL.
• void ∗ reserved1
Must be NULL.
• CUarray srcArray
Source array reference.
• CUdeviceptr srcDevice
• CUmemorytype srcMemoryType
Source memory type (host, device, array).
Data Fields
• enum cudaChannelFormatKind f
Channel format kind.
• int w
w
• int x
x
• int y
y
• int z
z
Data Fields
• int canMapHostMemory
Device can map host memory with cudaHostAlloc/cudaHostGetDevicePointer.
• int clockRate
Clock frequency in kilohertz.
• int computeMode
Compute mode (See cudaComputeMode).
• int deviceOverlap
Device can concurrently copy memory and execute a kernel.
• int integrated
Device is integrated as opposed to discrete.
• int kernelExecTimeoutEnabled
Specified whether there is a run time limit on kernels.
• int major
Major compute capability.
• int maxThreadsPerBlock
Maximum number of threads per block.
• size_t memPitch
Maximum pitch in bytes allowed by memory copies.
• int minor
Minor compute capability.
• int multiProcessorCount
Number of multiprocessors on device.
• int regsPerBlock
32-bit registers available per block
• size_t sharedMemPerBlock
• size_t textureAlignment
Alignment requirement for textures.
• size_t totalConstMem
Constant memory available on device in bytes.
• size_t totalGlobalMem
Global memory available on device in bytes.
• int warpSize
Warp size in threads.
Data Fields
• size_t depth
Depth in bytes.
• size_t height
Height in bytes.
• size_t width
Width in bytes.
CUDA extent
Data Fields
• size_t constSizeBytes
Size of constant memory in bytes.
• size_t localSizeBytes
Size of local memory in bytes.
• int maxThreadsPerBlock
Maximum number of threads per block.
• int numRegs
Number of registers used.
• size_t sharedSizeBytes
Size of shared memory in bytes.
Data Fields
• struct cudaArray ∗ dstArray
Destination memory address.
Data Fields
• size_t pitch
Pitch of allocated memory in bytes.
• void ∗ ptr
Pointer to allocated memory.
• size_t xsize
Logical width of allocation in elements.
• size_t ysize
Logical height of allocation in elements.
Data Fields
• size_t x
x
• size_t y
y
• size_t z
z
CUDA 3D position
Data Fields
• int clockRate
Clock frequency in kilohertz.
• int maxThreadsPerBlock
Maximum number of threads per block.
• int memPitch
Maximum pitch in bytes allowed by memory copies.
• int regsPerBlock
32-bit registers available per block
• int sharedMemPerBlock
Shared memory available per block in bytes.
• int SIMDWidth
Warp size in threads.
• int textureAlign
Alignment requirement for textures.
• int totalConstantMemory
Constant memory available on device in bytes.
CUDART_D3D9, 63 cudaErrorInvalidTexture
cudaD3D9ResourceGetSurfaceDimensions CUDART_TYPES, 95
CUDART_D3D9, 64 cudaErrorInvalidTextureBinding
cudaD3D9ResourceSetMapFlags CUDART_TYPES, 95
CUDART_D3D9, 65 cudaErrorInvalidValue
cudaD3D9SetDirect3DDevice CUDART_TYPES, 95
CUDART_D3D9, 65 cudaErrorLaunchFailure
cudaD3D9UnmapResources CUDART_TYPES, 95
CUDART_D3D9, 66 cudaErrorLaunchOutOfResources
cudaD3D9UnregisterResource CUDART_TYPES, 95
CUDART_D3D9, 67 cudaErrorLaunchTimeout
cudaDeviceProp, 220 CUDART_TYPES, 95
cudaDriverGetVersion cudaErrorMapBufferObjectFailed
CUDART_VERSION, 83 CUDART_TYPES, 95
cudaError cudaErrorMemoryAllocation
CUDART_TYPES, 95 CUDART_TYPES, 95
cudaError_enum cudaErrorMemoryValueTooLarge
CUDA_TYPES, 208 CUDART_TYPES, 96
cudaError_t cudaErrorMissingConfiguration
CUDART_TYPES, 94 CUDART_TYPES, 95
cudaErrorAddressOfConstant cudaErrorMixedDeviceExecution
CUDART_TYPES, 96 CUDART_TYPES, 96
cudaErrorApiFailureBase cudaErrorNoDevice
CUDART_TYPES, 96 CUDART_TYPES, 96
cudaErrorCudartUnloading cudaErrorNotReady
CUDART_TYPES, 96 CUDART_TYPES, 96
cudaErrorInitializationError cudaErrorNotYetImplemented
CUDART_TYPES, 95 CUDART_TYPES, 96
cudaErrorInsufficientDriver cudaErrorPriorLaunchFailure
CUDART_TYPES, 96 CUDART_TYPES, 95
cudaErrorInvalidChannelDescriptor cudaErrorSetOnActiveProcess
CUDART_TYPES, 95 CUDART_TYPES, 96
cudaErrorInvalidConfiguration cudaErrorStartupFailure
CUDART_TYPES, 95 CUDART_TYPES, 96
cudaErrorInvalidDevice cudaErrorSynchronizationError
CUDART_TYPES, 95 CUDART_TYPES, 96
cudaErrorInvalidDeviceFunction cudaErrorTextureFetchFailed
CUDART_TYPES, 95 CUDART_TYPES, 96
cudaErrorInvalidDevicePointer cudaErrorTextureNotBound
CUDART_TYPES, 95 CUDART_TYPES, 96
cudaErrorInvalidFilterSetting cudaErrorUnknown
CUDART_TYPES, 96 CUDART_TYPES, 96
cudaErrorInvalidHostPointer cudaErrorUnmapBufferObjectFailed
CUDART_TYPES, 95 CUDART_TYPES, 95
cudaErrorInvalidMemcpyDirection cudaEvent_t
CUDART_TYPES, 96 CUDART_TYPES, 94
cudaErrorInvalidNormSetting cudaEventCreate
CUDART_TYPES, 96 CUDART_EVENT, 16
cudaErrorInvalidPitchValue cudaEventCreateWithFlags
CUDART_TYPES, 95 CUDART_EVENT, 16
cudaErrorInvalidResourceHandle cudaEventDestroy
CUDART_TYPES, 96 CUDART_EVENT, 17
cudaErrorInvalidSymbol cudaEventElapsedTime
CUDART_TYPES, 95 CUDART_EVENT, 17
cudaEventQuery cudaGLUnregisterBufferObject
CUDART_EVENT, 18 CUDART_OPENGL, 56
cudaEventRecord cudaHostAlloc
CUDART_EVENT, 18 CUDART_MEMORY, 28
cudaEventSynchronize cudaHostGetDevicePointer
CUDART_EVENT, 19 CUDART_MEMORY, 29
cudaExtent, 222 cudaHostGetFlags
cudaFree CUDART_MEMORY, 30
CUDART_MEMORY, 26 cudaLaunch
cudaFreeArray CUDART_EXECUTION, 21
CUDART_MEMORY, 27 CUDART_HIGHLEVEL, 90
cudaFreeHost cudaMalloc
CUDART_MEMORY, 27 CUDART_MEMORY, 30
cudaFuncAttributes, 223 cudaMalloc3D
cudaFuncGetAttributes CUDART_MEMORY, 30
CUDART_EXECUTION, 21 cudaMalloc3DArray
CUDART_HIGHLEVEL, 88 CUDART_MEMORY, 31
cudaGetChannelDesc cudaMallocArray
CUDART_TEXTURE, 81 CUDART_MEMORY, 32
cudaGetDevice cudaMallocHost
CUDART_DEVICE, 9 CUDART_MEMORY, 33
cudaGetDeviceCount cudaMallocPitch
CUDART_DEVICE, 10 CUDART_MEMORY, 33
cudaGetDeviceProperties cudaMemcpy
CUDART_DEVICE, 10 CUDART_MEMORY, 34
cudaGetErrorString cudaMemcpy2D
CUDART_ERROR, 7 CUDART_MEMORY, 34
cudaGetLastError cudaMemcpy2DArrayToArray
CUDART_ERROR, 7 CUDART_MEMORY, 35
cudaGetSymbolAddress cudaMemcpy2DAsync
CUDART_HIGHLEVEL, 89 CUDART_MEMORY, 36
CUDART_MEMORY, 27 cudaMemcpy2DFromArray
cudaGetSymbolSize CUDART_MEMORY, 37
CUDART_HIGHLEVEL, 89 cudaMemcpy2DFromArrayAsync
CUDART_MEMORY, 28 CUDART_MEMORY, 37
cudaGetTextureAlignmentOffset cudaMemcpy2DToArray
CUDART_HIGHLEVEL, 90 CUDART_MEMORY, 38
CUDART_TEXTURE, 81 cudaMemcpy2DToArrayAsync
cudaGetTextureReference CUDART_MEMORY, 39
CUDART_TEXTURE, 82 cudaMemcpy3D
cudaGLMapBufferObject CUDART_MEMORY, 40
CUDART_OPENGL, 52 cudaMemcpy3DAsync
cudaGLMapBufferObjectAsync CUDART_MEMORY, 41
CUDART_OPENGL, 53 cudaMemcpy3DParms, 224
cudaGLRegisterBufferObject cudaMemcpyArrayToArray
CUDART_OPENGL, 53 CUDART_MEMORY, 43
cudaGLSetBufferObjectMapFlags cudaMemcpyAsync
CUDART_OPENGL, 54 CUDART_MEMORY, 43
cudaGLSetGLDevice cudaMemcpyDeviceToDevice
CUDART_OPENGL, 54 CUDART_TYPES, 96
cudaGLUnmapBufferObject cudaMemcpyDeviceToHost
CUDART_OPENGL, 55 CUDART_TYPES, 96
cudaGLUnmapBufferObjectAsync cudaMemcpyFromArray
CUDART_OPENGL, 55 CUDART_MEMORY, 44
cudaMemcpyFromArrayAsync cudaErrorInvalidConfiguration, 95
CUDART_MEMORY, 45 cudaErrorInvalidDevice, 95
cudaMemcpyFromSymbol cudaErrorInvalidDeviceFunction, 95
CUDART_MEMORY, 46 cudaErrorInvalidDevicePointer, 95
cudaMemcpyFromSymbolAsync cudaErrorInvalidFilterSetting, 96
CUDART_MEMORY, 46 cudaErrorInvalidHostPointer, 95
cudaMemcpyHostToDevice cudaErrorInvalidMemcpyDirection, 96
CUDART_TYPES, 96 cudaErrorInvalidNormSetting, 96
cudaMemcpyHostToHost cudaErrorInvalidPitchValue, 95
CUDART_TYPES, 96 cudaErrorInvalidResourceHandle, 96
cudaMemcpyKind cudaErrorInvalidSymbol, 95
CUDART_TYPES, 96 cudaErrorInvalidTexture, 95
cudaMemcpyToArray cudaErrorInvalidTextureBinding, 95
CUDART_MEMORY, 47 cudaErrorInvalidValue, 95
cudaMemcpyToArrayAsync cudaErrorLaunchFailure, 95
CUDART_MEMORY, 48 cudaErrorLaunchOutOfResources, 95
cudaMemcpyToSymbol cudaErrorLaunchTimeout, 95
CUDART_MEMORY, 48 cudaErrorMapBufferObjectFailed, 95
cudaMemcpyToSymbolAsync cudaErrorMemoryAllocation, 95
CUDART_MEMORY, 49 cudaErrorMemoryValueTooLarge, 96
cudaMemset cudaErrorMissingConfiguration, 95
CUDART_MEMORY, 50 cudaErrorMixedDeviceExecution, 96
cudaMemset2D cudaErrorNoDevice, 96
CUDART_MEMORY, 50 cudaErrorNotReady, 96
cudaMemset3D cudaErrorNotYetImplemented, 96
CUDART_MEMORY, 51 cudaErrorPriorLaunchFailure, 95
cudaPitchedPtr, 225 cudaErrorSetOnActiveProcess, 96
cudaPos, 226 cudaErrorStartupFailure, 96
CUDART_D3D10 cudaErrorSynchronizationError, 96
cudaD3D10MapFlagsNone, 69 cudaErrorTextureFetchFailed, 96
cudaD3D10MapFlagsReadOnly, 69 cudaErrorTextureNotBound, 96
cudaD3D10MapFlagsWriteDiscard, 69 cudaErrorUnknown, 96
cudaD3D10RegisterFlagsArray, 69 cudaErrorUnmapBufferObjectFailed, 95
cudaD3D10RegisterFlagsNone, 69 cudaMemcpyDeviceToDevice, 96
CUDART_D3D9 cudaMemcpyDeviceToHost, 96
cudaD3D9MapFlagsNone, 58 cudaMemcpyHostToDevice, 96
cudaD3D9MapFlagsReadOnly, 58 cudaMemcpyHostToHost, 96
cudaD3D9MapFlagsWriteDiscard, 58 cudaSuccess, 95
cudaD3D9RegisterFlagsArray, 58 CUDART_D3D10
cudaD3D9RegisterFlagsNone, 58 cudaD3D10GetDevice, 69
CUDART_TYPES cudaD3D10MapFlags, 69
cudaChannelFormatKindFloat, 95 cudaD3D10MapResources, 70
cudaChannelFormatKindNone, 95 cudaD3D10RegisterFlags, 69
cudaChannelFormatKindSigned, 95 cudaD3D10RegisterResource, 70
cudaChannelFormatKindUnsigned, 95 cudaD3D10ResourceGetMappedArray, 71
cudaComputeModeDefault, 95 cudaD3D10ResourceGetMappedPitch, 72
cudaComputeModeExclusive, 95 cudaD3D10ResourceGetMappedPointer, 73
cudaComputeModeProhibited, 95 cudaD3D10ResourceGetMappedSize, 73
cudaErrorAddressOfConstant, 96 cudaD3D10ResourceGetSurfaceDimensions, 74
cudaErrorApiFailureBase, 96 cudaD3D10ResourceSetMapFlags, 75
cudaErrorCudartUnloading, 96 cudaD3D10SetDirect3DDevice, 75
cudaErrorInitializationError, 95 cudaD3D10UnmapResources, 76
cudaErrorInsufficientDriver, 96 cudaD3D10UnregisterResource, 77
cudaErrorInvalidChannelDescriptor, 95 CUDART_D3D9
cudaD3D9GetDevice, 58 cudaFree, 26
cudaD3D9GetDirect3DDevice, 59 cudaFreeArray, 27
cudaD3D9MapFlags, 58 cudaFreeHost, 27
cudaD3D9MapResources, 59 cudaGetSymbolAddress, 27
cudaD3D9RegisterFlags, 58 cudaGetSymbolSize, 28
cudaD3D9RegisterResource, 60 cudaHostAlloc, 28
cudaD3D9ResourceGetMappedArray, 61 cudaHostGetDevicePointer, 29
cudaD3D9ResourceGetMappedPitch, 62 cudaHostGetFlags, 30
cudaD3D9ResourceGetMappedPointer, 63 cudaMalloc, 30
cudaD3D9ResourceGetMappedSize, 63 cudaMalloc3D, 30
cudaD3D9ResourceGetSurfaceDimensions, 64 cudaMalloc3DArray, 31
cudaD3D9ResourceSetMapFlags, 65 cudaMallocArray, 32
cudaD3D9SetDirect3DDevice, 65 cudaMallocHost, 33
cudaD3D9UnmapResources, 66 cudaMallocPitch, 33
cudaD3D9UnregisterResource, 67 cudaMemcpy, 34
CUDART_DEVICE cudaMemcpy2D, 34
cudaChooseDevice, 9 cudaMemcpy2DArrayToArray, 35
cudaGetDevice, 9 cudaMemcpy2DAsync, 36
cudaGetDeviceCount, 10 cudaMemcpy2DFromArray, 37
cudaGetDeviceProperties, 10 cudaMemcpy2DFromArrayAsync, 37
cudaSetDevice, 12 cudaMemcpy2DToArray, 38
cudaSetDeviceFlags, 12 cudaMemcpy2DToArrayAsync, 39
cudaSetValidDevices, 13 cudaMemcpy3D, 40
CUDART_ERROR cudaMemcpy3DAsync, 41
cudaGetErrorString, 7 cudaMemcpyArrayToArray, 43
cudaGetLastError, 7 cudaMemcpyAsync, 43
CUDART_EVENT cudaMemcpyFromArray, 44
cudaEventCreate, 16 cudaMemcpyFromArrayAsync, 45
cudaEventCreateWithFlags, 16 cudaMemcpyFromSymbol, 46
cudaEventDestroy, 17 cudaMemcpyFromSymbolAsync, 46
cudaEventElapsedTime, 17 cudaMemcpyToArray, 47
cudaEventQuery, 18 cudaMemcpyToArrayAsync, 48
cudaEventRecord, 18 cudaMemcpyToSymbol, 48
cudaEventSynchronize, 19 cudaMemcpyToSymbolAsync, 49
CUDART_EXECUTION cudaMemset, 50
cudaConfigureCall, 20 cudaMemset2D, 50
cudaFuncGetAttributes, 21 cudaMemset3D, 51
cudaLaunch, 21 CUDART_OPENGL
cudaSetDoubleForDevice, 21 cudaGLMapBufferObject, 52
cudaSetDoubleForHost, 22 cudaGLMapBufferObjectAsync, 53
cudaSetupArgument, 22 cudaGLRegisterBufferObject, 53
CUDART_HIGHLEVEL cudaGLSetBufferObjectMapFlags, 54
cudaBindTexture, 85 cudaGLSetGLDevice, 54
cudaBindTexture2D, 86 cudaGLUnmapBufferObject, 55
cudaBindTextureToArray, 87 cudaGLUnmapBufferObjectAsync, 55
cudaCreateChannelDesc, 88 cudaGLUnregisterBufferObject, 56
cudaFuncGetAttributes, 88 cudaWGLGetDevice, 56
cudaGetSymbolAddress, 89 CUDART_STREAM
cudaGetSymbolSize, 89 cudaStreamCreate, 14
cudaGetTextureAlignmentOffset, 90 cudaStreamDestroy, 14
cudaLaunch, 90 cudaStreamQuery, 15
cudaSetupArgument, 90 cudaStreamSynchronize, 15
cudaUnbindTexture, 91 CUDART_TEXTURE
CUDART_MEMORY cudaBindTexture, 78
cudaBindTexture2D, 79 CUDART_TEXTURE, 82
cudaBindTextureToArray, 80 cudaWGLGetDevice
cudaCreateChannelDesc, 80 CUDART_OPENGL, 56
cudaGetChannelDesc, 81 CUDEVICE
cudaGetTextureAlignmentOffset, 81 cuDeviceComputeCapability, 99
cudaGetTextureReference, 82 cuDeviceGet, 100
cudaUnbindTexture, 82 cuDeviceGetAttribute, 100
CUDART_THREAD cuDeviceGetCount, 101
cudaThreadExit, 6 cuDeviceGetName, 102
cudaThreadSynchronize, 6 cuDeviceGetProperties, 102
CUDART_TYPES cuDeviceTotalMem, 103
cudaChannelFormatKind, 94 CUdevice_attribute
cudaComputeMode, 95 CUDA_TYPES, 206
cudaError, 95 CUdevice_attribute_enum
cudaError_t, 94 CUDA_TYPES, 208
cudaEvent_t, 94 cuDeviceComputeCapability
cudaMemcpyKind, 96 CUDEVICE, 99
cudaStream_t, 94 cuDeviceGet
CUDART_VERSION CUDEVICE, 100
cudaDriverGetVersion, 83 cuDeviceGetAttribute
cudaRuntimeGetVersion, 83 CUDEVICE, 100
cudaRuntimeGetVersion cuDeviceGetCount
CUDART_VERSION, 83 CUDEVICE, 101
cudaSetDevice cuDeviceGetName
CUDART_DEVICE, 12 CUDEVICE, 102
cudaSetDeviceFlags cuDeviceGetProperties
CUDART_DEVICE, 12 CUDEVICE, 102
cudaSetDoubleForDevice cuDeviceTotalMem
CUDART_EXECUTION, 21 CUDEVICE, 103
cudaSetDoubleForHost CUdevprop
CUDART_EXECUTION, 22 CUDA_TYPES, 206
cudaSetupArgument CUdevprop_st, 227
CUDART_EXECUTION, 22 cuDriverGetVersion
CUDART_HIGHLEVEL, 90 CUVERSION, 105
cudaSetValidDevices CUEVENT
CUDART_DEVICE, 13 cuEventCreate, 119
cudaStream_t cuEventDestroy, 120
CUDART_TYPES, 94 cuEventElapsedTime, 120
cudaStreamCreate cuEventQuery, 120
CUDART_STREAM, 14 cuEventRecord, 121
cudaStreamDestroy cuEventSynchronize, 121
CUDART_STREAM, 14 CUevent_flags
cudaStreamQuery CUDA_TYPES, 206
CUDART_STREAM, 15 CUevent_flags_enum
cudaStreamSynchronize CUDA_TYPES, 209
CUDART_STREAM, 15 cuEventCreate
cudaSuccess CUEVENT, 119
CUDART_TYPES, 95 cuEventDestroy
cudaThreadExit CUEVENT, 120
CUDART_THREAD, 6 cuEventElapsedTime
cudaThreadSynchronize CUEVENT, 120
CUDART_THREAD, 6 cuEventQuery
cudaUnbindTexture CUEVENT, 120
CUDART_HIGHLEVEL, 91 cuEventRecord
NVIDIA Corporation
2701 San Tomas Expressway
Santa Clara, CA 95050
www.nvidia.com