Increasing speed in MATLAB 2018a

Posted on

Today, I finally installed MATLAB 2018a. As always, I am quite excited about the software releases shipped every 6 months. One of the release notes on performance particularly caught my interest.

Loops that contain mainly indexing and scalar math operations execute faster due to execution engine optimizations. (see here)

TopoToolbox contains a number of tight loops with scalar math and thus I expect that this release should make TopoToolbox generally faster. I tested this using the function flowacc with a large DEM (SRTM-3, 90 m resolution, about 239 Millionen pixels). flowacc has been coded to be fast and thus there is also a C-coded MEX-file available for benchmarking. However, the code can also be run as pure MATLAB code which I have done in 2017b and 2018a. I measured run-times with tic-toc using 20 repetitions. The results are shown below.

Run-time comparison of the flow accumulation code in TopoToolbox.

M-code in 2018a takes about 77% of the time required in 2017b. That is a major improvement. Moreover, run-times are close to the C-code benchmark (118%). Can it get much better than this?

Now let’s put this in relation to other software. What we have looked at are flow accumulation run-times for the entire Himalayan range at a resolution of 90 m. 4-6 seconds is quite fast, I guess. In ArcGIS, the same operation would take hours*. But I am a bit reluctant to test this in detail.

*Note that ArcGIS doesn’t keep data in the main memory. Thus, much of the time may be used to swap data between the main memory and the hard drive. A direct comparison is thus not fair.