分析mex函数 [英] Profiling a mex-function

查看:127
本文介绍了分析mex函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚用c ++重写了Matlab程序作为mex函数,以加快处理速度,并取得了令人惊讶的结果.这个优化决定是一个非常非常好的主意,在不使用线程的情况下,速度提高了20倍.它仍然让我对混合功能花时间在什么地方并想找出可能的瓶颈感到好奇.

I have just rewritten a Matlab program in c++ as a mex-function to speed things up, with fantastic results. This optimization decision was a very very good idea, with up to a factor 20 speed up without threading. It still left me curious about what the mex-function was spending time on and wanting to identify possible bottlenecks.

我正在寻找一种分析混合功能的方法. matlab探查器用处不大,我下载的其他探查器(免费和试用版)都希望运行可执行文件.我不是专家,但据我所知,运行混合物的唯一方法是在Matlab中运行.该mex函数被编译为dll,但称为.mex64.因此,此问题应类似于分析dll.为了编写c ++ mex函数,我使用了单用户VS2005(即,不是团队版本),并且在x64平台上运行.

I'm looking for a way to profile mex-functions. The matlab profiler is not much use, and the other profilers I've downloaded (both free and trial) all want an executable to run. I'm no mex-guru, but as far as I've understood the only way to run a mex is from within Matlab. The mex-function is compiled into a dll, but is called .mex64. So this problem should be similar to profiling a dll. To write the c++ mex-function I used a single-user VS2005 (i.e., not the team version), and am running on a x64-platform.

有人知道配置mex函数的好方法吗?从Matlab内部启动时,应该使用什么工具以及如何使用它?还是有其他方法可以分析C ++代码?

Does anyone know of a good way to profile a mex-function? What tool should I use and how do I use it when I start from within Matlab? Or is there any other way to profile the c++-code?

推荐答案

我设法做到这一点的唯一方法是分离出完成工作的功能,并编写一个加载.mat的单独包装器(而不是mexFunction).包含测试数据的文件,并作为独立的可执行文件运行.然后可以使用例如gprof

the only way i've managed to do this is to separate out the function doing the work and writing a separate wrapper (instead of mexFunction) that loads .mat files with test data and runs as a standalone executable. this can then be profiled using e.g. gprof

这篇关于分析mex函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆