Contenido principal

Esta página se ha traducido mediante traducción automática. Haga clic aquí para ver la versión original en inglés.

Programación de CUDA y MEX para GPU

R2026b
Acelerar aún más el código con programación avanzada de CUDA® y MEX para GPU

Si ejecutar funciones de MATLAB® en la GPU no acelera lo suficiente el código o si desea utilizar funcionalidades avanzadas de CUDA para GPU, puede escribir código CUDA propio y ejecutarlo en MATLAB generando un archivo MEX ejecutable con mexcuda o un kernel ejecutable con parallel.gpu.CUDAKernel.

En general, utilizar archivos MEX es más flexible que utilizar objetos CUDAKernel. Para obtener más información, consulte Run MEX Functions Containing CUDA Code.

Funciones

expandir todo

mexcudaCompile MEX functions or PTX files for GPU computation
CUDAKernelKernel executable on GPU
fevalEvaluate kernel on GPU
setConstantMemorySet some constant memory on GPU
mxGPUArrayType for MATLAB gpuArray
mxGPUCopyFromMxArrayCopy mxArray to mxGPUArray
mxGPUCopyGPUArrayDuplicate (deep copy) mxGPUArray object
mxGPUCopyImag Copy imaginary part of mxGPUArray
mxGPUCopyReal Copy real part of mxGPUArray
mxGPUCreateComplexGPUArrayCreate complex GPU array from two real gpuArrays
mxGPUCreateFromMxArrayCreate read-only mxGPUArray object from input mxArray
mxGPUCreateGPUArrayCreate mxGPUArray object, allocating memory on GPU
mxGPUCreateMxArrayOnCPUCreate mxArray for returning CPU data to MATLAB with data from GPU
mxGPUCreateMxArrayOnGPUCreate mxArray for returning GPU data to MATLAB
mxGPUDestroyGPUArrayDelete mxGPUArray object
mxGPUGetClassIDmxClassID associated with data on GPU
mxGPUGetComplexityComplexity of data on GPU
mxGPUGetDataRaw pointer to underlying data
mxGPUGetDataReadOnlyRead-only raw pointer to underlying data
mxGPUGetDimensionsmxGPUArray dimensions
mxGPUGetNumberOfDimensionsSize of dimension array for mxGPUArray
mxGPUGetNumberOfElementsNumber of elements on GPU for array
mxGPUIsSameDetermine if two mxGPUArrays refer to same GPU data
mxGPUIsSparseDetermine if mxGPUArray contains sparse GPU data
mxGPUIsValidGPUDataDetermine if mxArray is pointer to valid GPU data
mxGPUSetDimensionsModify number of dimensions and size of each dimension
mxIsGPUArrayDetermine if mxArray contains GPU data
mxInitGPUInitialize MATLAB GPU library on currently selected device

Temas

  • Run MEX Functions Containing CUDA Code

    If running MATLAB functions on the GPU does not sufficiently speed up your code, or if you need to use advanced GPU CUDA features, you can write your own CUDA code and run it in MATLAB by generating an executable MEX file using mexcuda.

  • Run CUDA or PTX Code on GPU

    If running MATLAB functions on the GPU does not sufficiently speed up your code, or if you need to use advanced GPU CUDA features, you can write your own CUDA code and run it in MATLAB by an executable kernel using parallel.gpu.CUDAKernel.

Ejemplos destacados