- Joined
- 4/17/07
- Messages
- 258
- Points
- 28
I have a question regarding speeding up the Matlab code. Part of the trading strategies logic is implemented in Matlab. One run of the Matlab routine may take about 15 minutes, however to calibrate the model I need to run this code hundreds of times. For my purposes it is not practical to transfer Matlab code to C++ or C#.
My goal is to improve runtime for the Matlab code. It does not really matter whether the code is running in Matlab (direct or precompiled code), or whether C++ executing Matlab code (either using precompiled Matlab libraries or directly invoking Matlab).
I tried several potential solutions:
1. Invoke Matlab from C#: 1.1. Using DDE 1.2. COM approach 1.3. Using low level API. The last approach is fastest, though it does not increase the speed, because in this case I am just invoking Matlab code from C# and executing it on Matlab engine and the Matlab code is not precompiled.
2. Compile the code in Matlab using Matlab .Net Builder and then use the assembly in C# or C++. There are at least three different directions here: 2.1. Use Matlab Com engine interface (slow) 2.2. Use C shared library 2.3. Using .Net assembly. I implemented the third approach, however it does not seem faster, since according to Matlab (Does the MATLAB Compiler speed up the execution time of MATLAB functions? - 1-1ARNS ) compiling the code in Matlab does not usually increase the performance, because, as I understand, the code is not compiled as such but methods simply put in a stand along library.
I would appreciate if you have any ideas about how to speed up the Matlab code.
Is there any way to compile Matlab code to the low level? Maybe you know the way to automatically convert Matlab code into C++ without creating libraries or again, creating the libraries that are compiled to the low level?
Thank you for reading the details and thanks in advance for posting!
Vadim
My goal is to improve runtime for the Matlab code. It does not really matter whether the code is running in Matlab (direct or precompiled code), or whether C++ executing Matlab code (either using precompiled Matlab libraries or directly invoking Matlab).
I tried several potential solutions:
1. Invoke Matlab from C#: 1.1. Using DDE 1.2. COM approach 1.3. Using low level API. The last approach is fastest, though it does not increase the speed, because in this case I am just invoking Matlab code from C# and executing it on Matlab engine and the Matlab code is not precompiled.
2. Compile the code in Matlab using Matlab .Net Builder and then use the assembly in C# or C++. There are at least three different directions here: 2.1. Use Matlab Com engine interface (slow) 2.2. Use C shared library 2.3. Using .Net assembly. I implemented the third approach, however it does not seem faster, since according to Matlab (Does the MATLAB Compiler speed up the execution time of MATLAB functions? - 1-1ARNS ) compiling the code in Matlab does not usually increase the performance, because, as I understand, the code is not compiled as such but methods simply put in a stand along library.
I would appreciate if you have any ideas about how to speed up the Matlab code.
Is there any way to compile Matlab code to the low level? Maybe you know the way to automatically convert Matlab code into C++ without creating libraries or again, creating the libraries that are compiled to the low level?
Thank you for reading the details and thanks in advance for posting!
Vadim