Main Content

mxGPUCreateGPUArray (C)

Create mxGPUArray object, allocating memory on GPU

C Syntax

#include "gpu/mxGPUArray.h"
mxGPUArray* mxGPUCreateGPUArray(mwSize const ndims,
                                mwSize const * const dims,
                                mxClassID const cid,
                                mxComplexity const ccx,
                                mxGPUInitialize const init0)



mwSize type specifying the number of dimensions in the created mxGPUArray.


Pointer to an mwSize vector specifying the sizes of each dimension in the created mxGPUArray.


mxClassID type specifying the element class of the created mxGPUArray.


mxComplexity type specifying the complexity of the created mxGPUArray.


mxGPUInitialize type specifying whether to initialize elements values to 0 in the created mxGPUArray.

  • A value of MX_GPU_INITIALIZE_VALUES specifies that elements are to be initialized to 0.

  • A value of MX_GPU_DO_NOT_INITIALIZE specifies that elements are not to be initialized.


Pointer to an mxGPUArray.


mxGPUCreateGPUArray creates a new mxGPUArray object with the specified size, type, and complexity. It also allocates the required memory on the GPU, and initializes the memory if requested.

This function allocates a new mxGPUArray object on the CPU. Use mxGPUDestroyGPUArray to delete the object when you are done with it.

Version History

Introduced in R2013a