Wednesday, August 18, 2010

Speeding Up Matlab

Java 'Out of memory' errors
修改或新增下列程式碼於 'java.opts' (in $MATLAB/bin/win32/java.opts)
-XX:PermSize=72m
-XX:MaxPermSize=72m
-Xmx256m
-Dcom.sun.management.jmxremote
除此之外, 可以參考 Sun JVM的微調參數, 做更進一步的調教

Java Virtual Machine (JVM) Matlab
修改系統變數 MATLAB_JAVA
更換Matlab內建的 BLAS函式庫
先找出你CPU對應最佳化Basic Linear Algebra Subroutines (BLAS)函式庫, 然後修改 BLAS_VERSION這個系統變數, 去使用最佳化函式庫
理論上, 這對舊版的 Matlab 6有奇效, 因為舊的 Matlab並沒有使用最佳化的函式庫, 改用新的至少會快兩倍
以下是 Intel 最佳化函式庫 9.1.2版的對照表 (最新版是 10.1)
mkl_p3 Kernel optimized for Intel® Pentium® III processor
mkl_p4 Kernel optimized for Intel® Pentium® 4 processor
mkl_p4m Kernel optimized for Intel® Core™ 2 Duo Processor
mkl_p4p Kernel optimized for Intel® Pentium® 4 processor with SSE3 Instructions
可以用 LAPACK_VERBOSITY=1 來檢查 BLAS的版本

Optimized Elementary MATLAB Functions
用在 PII以上, 可以快上兩三倍

No comments: