Allocate page locked memory for output array in mex?

Hello,
I have something like this:
plhs[0] = mxCreateDoubleMatrix(ref_row, ref_col, mxREAL);
I would like to know if it's possible to replace this function with a cudaHostAlloc function instead. Thanks.

 Accepted Answer

Justin,
Unfortunately this isn't possible in MATLAB today. The function mxCreateDoubleMatrix returns an mxArray, not a raw pointer, and mxArrays that get returned to MATLAB need to be freed by MATLAB.

3 Comments

Thanks for the response!
-Justin
Is this still true in 2019?
MATLAB still needs to allocate its own memory for mxArray variables. Within a mex routine, that means using API functions or call backs into other MATLAB functions.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Asked:

on 19 Apr 2012

Commented:

on 11 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!