Matlab mex file is slow compared to its straight C equivalent

前端 未结 2 916
一个人的身影
一个人的身影 2020-12-28 15:58

I\'m at a loss to explain (and avoid) the differences in speed between a Matlab mex program and the corresponding C program with no Matlab interface. I\'ve been profiling a

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-28 16:27

    Recall that Matlab stores arrays as column major, and C/C++ as row major. Is it possible that your loop structure/algorithm is iterating in a row major fashion, resulting in poor memory access times in Matlab, but fast access times in C/C++ ?

提交回复
热议问题