Is Matlab Coder Toolbox generated C++ code tight and minimal? Has anyone evaluated the C++ code generated by Matlab’s Coder toolbox? Is it tight and minimal? I have been told a lot of the generated code can be quite bloated which does not make it a low latency quality for use in a high frequency trading environment. Is there truth to this claim? This is even if you build the code at the Coder’s minimal settings. The Matlab M scripts I would use is M core only so I would not be using any extended Matlab toolboxes like Econmetrics. Thanks for any insight
-
I haven't used the toolbox itself, but a while back I did get to look at some code it generated and wasn't impressed. Caveat: I doubt that was the current version and I have no idea what settings were used.Jerry Coffin– Jerry Coffin2012-05-23 14:09:39 +00:00Commented May 23, 2012 at 14:09
-
Hi Jerry, did you at least set the Coder settings to minimal code generation?heavy rocker dude– heavy rocker dude2012-05-23 14:12:01 +00:00Commented May 23, 2012 at 14:12
-
As I said, I didn't set anything -- I was asked to look at some code that had already been generated. It had some comments saying it had been generated by Matlab (and I'd already been told that anyway), but I don't really know how they produced what I saw (it seems like the comments may have said something about the setting that were used, but if so I didn't pay much attention -- they weren't relevant to what I needed to do at the time.Jerry Coffin– Jerry Coffin2012-05-23 15:00:58 +00:00Commented May 23, 2012 at 15:00
-
"Tight and minimal" C++ code isn't that important anymore, with modern compilers. They do wonders on reasonable code.MSalters– MSalters2012-05-24 09:36:11 +00:00Commented May 24, 2012 at 9:36
1 Answer
It can be made tight and minimal if you know what you're doing, and you write your MATLAB in the right way in the first place (which includes not only very few toolboxes, but also restricting yourself to a subset of the MATLAB language). There are plenty of people using MATLAB-generated C code in algorithmic and high-frequency trading.
If you're serious about finding out exactly how tight and minimal it can be made, how you'd need to change your MATLAB coding style, and how difficult that might be, I would really recommend getting in touch with MathWorks. MATLAB Coder is a complex product, and people typically need advice to get the most out of it.
[Disclaimer, in case the above sounds like a sales pitch - I'm an ex-MathWorker, but I no longer have any interest in trying to sell you anything. It's just my 2cents of advice.]