Using CPU's Cache Efficiently

6 次查看(过去 30 天)
Reynaldo
Reynaldo 2012-5-12
Hey! I just had a brief question... Is there any way I can efficiently use the CPU's cache in MATLAB to improve performance? Is there any code segment that illustrates the effective use of L1 and L2 caches to improve overall execution? Thank you for your help!
  1 个评论
Reynaldo
Reynaldo 2012-5-12
Sorry... I forgot to mention that I am using MatLab R2011a. Thanks!

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2012-5-12
MATLAB does not offer any ability to query cache sizes, or to align data in the cache, and makes few promises about the order of operations of anything if the JIT (Just In Time compiler) is turned on.
Variables can be silently copied to new memory if needed for "copy on write" purposes.
In situations where common vector or array operations are being done and the number of elements is high enough, the operations may be passed off to the LAPACK or BLAS libraries, which are tuned for efficiency -- but the nature of that tuning is a "black box" as far as the user is concerned.
Guidelines are difficult to give as the internal structure of MATLAB variables is mostly not documented. Well, we can give a guideline: if you work at the mex level, although it is possible to use system memory allocation routines to align data memory, doing so is risky, as MATLAB assumes that all memory has been allocated by its own allocation routines.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by