how to add "large arrays" (64 bits) to codegen generated function?

조회 수: 3 (최근 30일)
Sergio Zlotnik
Sergio Zlotnik 2017년 6월 30일
편집: Jan 2017년 7월 4일
Hi all, is there some flag to tell codegen function to use 64 bits indexes? (Something similar to the -largeArrayDims for the mex compilation) Thanks!
  댓글 수: 1
Sergio Zlotnik
Sergio Zlotnik 2017년 6월 30일
Ok, I found this thread:
https://www.mathworks.com/matlabcentral/answers/166142-how-can-i-re-mex-matlab-coder-generated-c-h-and-o-files-using-largedimarrays-flag
That answer my question. Did this changed since 2014? Thanks in advance!

댓글을 달려면 로그인하십시오.

답변 (2개)

Fangjun Jiang
Fangjun Jiang 2017년 6월 30일
I would assume that, if you specify the data type of your index variable as uint64, it will generate the code correctly using 64 bits indexing.

Jan
Jan 2017년 6월 30일
편집: Jan 2017년 7월 4일
codegen creates C code, as far as I understand. The C code itself is not limited to 32 or 64 bit. 32 bit compilers can work with 64 bit variables also. But the addressing depends on the compiler. But as long as the created code contains e.g. size_t for the addressing, this is adjusted during the compilation.
During the mex compilation it matters, which libraries are used. Hm. I stop poking around in the dark. I think a kind of -largeArrayDims would not make sense for codegen.
[EDITED] See http://www.mathworks.com/help/coder/ug/array-size-restrictions-for-code-generation.html: My assumption was wrong. The code supports 32 bit addressing in arrays only.
  댓글 수: 2
Sergio Zlotnik
Sergio Zlotnik 2017년 6월 30일
Thanks Jan for answer.
Let me describe my problem: if I run this (stupid) function it works well:
function alloc_large_matrix()
o = ones(2147483647,3);
If I try
codegen alloc_large_matrix.m
??? Maximum variable size allowed by the program is exceeded.
Error in ==> alloc_large_matrix Line: 2 Column: 5
So I guessed that something similar to largeArrayDims was missing...
Jan
Jan 2017년 7월 4일
편집: Jan 2017년 7월 4일
See [EDITED]

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by