フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Is there a data size limited in the mex of cell format?

1 回表示 (過去 30 日間)
wei zhang
wei zhang 2021 年 3 月 12 日
閉鎖済み: wei zhang 2021 年 3 月 12 日
I am trying to pass some large cell arrays from mex to Matlab. I found it may stuck Matlab if the output cell array is large. Is there a limitation of cell format capacity? I know little knowledge of it. Do I use the cell format in wrong way? Any suggestion would be appreciated.
Here is an example.
In matlab
r = test1((ones(1e8,1)));% matlab crash or stuck
The cu file to build mex.
%% test1.cu
void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
mxInitGPU();
mxGPUArray const *a0 = mxGPUCreateFromMxArray(prhs[0]);
double *d_a0 = (double*)mxGPUGetDataReadOnly(a0);
int K = 1;
prhs[0] = mxCreateCellMatrix(K,1);
mxArray * R;
for(int i = 0;i<K;i++)
{
R = mxGPUCreateMxArrayOnCPU(a0);
mxSetCell(RESULT,i,R);
}
mxGPUDestroyGPUArray(a0);
mxDestroyArray(R);
}
If I output the result without cell, like below.
r = test2((ones(1e8,1))); % good
%% test2.cu
void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
mxInitGPU();
mxGPUArray const *a0 = mxGPUCreateFromMxArray(prhs[0]);
double *d_a0 = (double*)mxGPUGetDataReadOnly(a0);
plhs[0] = mxGPUCreateMxArrayOnCPU(a0);
mxGPUDestroyGPUArray(a0);
}
  1 件のコメント
wei zhang
wei zhang 2021 年 3 月 12 日
It should be
mxSetCell(RESULT,i,mxDuplicateArray(R));
Sorry for using wrong format of copy array in cell format. It has nothing to do with the size.

回答 (0 件)

この質問は閉じられています。

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by