Prev: Gaussian Filter
Next: command "imagesc"
From: darthshak on 2 Jul 2010 03:32 Hi all I had recently written some code for intensive number crunching. In one of the test runs, I had to call the fft() function ~ 6.4 million times in a nested loop. The number of points of each vector being transformed is usually around 2^14. Now, the net execution time for the statement containing the call to the fft() function was approximately 1080 seconds. However, in my experience with MEX-functions in general, there is usually a lot of overhead involved in making a large number of MEX function calls, in some cases, even 3x or 4x the actual execution time of the function. Is this is a possibilty in this case, even though the fft() is a built-in function? Also, I just have a nagging feeling that much of this time is being spent in memory allocation and reallocation. If so, is there any way, with or without MATLAB, that I can profile this fft() function and figure out how much time is spent on calculating *only* the Fourier transform itself? Also, if memory allocation is genuinely an issue, is there a way to keep the memory persistent between function calls? This is possible with user-defined MEX function with the mexMakeArrayPersistent() function, but is there a similar such setting with the FFTW library set?
From: darthshak on 10 Jul 2010 22:11 Anyone?
From: darthshak on 10 Jul 2010 22:12 Anyone?
From: Rune Allnor on 11 Jul 2010 06:36 On 2 Jul, 13:32, darthshak <vishakada...(a)gmail.com> wrote: > Hi all > > I had recently written some code for intensive number crunching. In one of the test runs, I had to call the fft() function ~ 6.4 million times in a nested loop. The number of points of each vector being transformed is usually around 2^14. > > Now, the net execution time for the statement containing the call to the fft() function was approximately 1080 seconds. That's, what, some 17 minutes? Not too bad. A different way of stating this is that you are executing some 6000 1684 pt DFTs every second. > However, in my experience with MEX-functions in general, there is usually a lot of overhead involved in making a large number of MEX function calls, in some cases, even 3x or 4x the actual execution time of the function. Is this is a possibilty in this case, even though the fft() is a built-in function? That's nothing you need to worry about. Run-time speed is not, and has never been, a prioritized aspect of matlab. > Also, I just have a nagging feeling that much of this time is being spent in memory allocation and reallocation. If so, is there any way, with or without MATLAB, that I can profile this fft() function and figure out how much time is spent on calculating *only* the Fourier transform itself? There is only *one* reason to use matlab for programming: To save *coding* time. The time you save on getting something up and running is paid for by poor run-time performance. If you really want speed, ditch matlab alltogether and use one of the compiled languages. Of course, chances are that you will spend a lot of time on numerical stuff that comes canned with matlab (this si the case with C or C++), or you will spend a lot of time coming up with flexible control structures that is hard also in matlab (which is the case with fortran). Rune
From: us on 11 Jul 2010 07:25
darthshak <vishakadatta(a)gmail.com> wrote in message <493389247.59587.1278070392955.JavaMail.root(a)gallium.mathforum.org>... > Hi all > > I had recently written some code for intensive number crunching. In one of the test runs, I had to call the fft() function ~ 6.4 million times in a nested loop. The number of points of each vector being transformed is usually around 2^14. > > Now, the net execution time for the statement containing the call to the fft() function was approximately 1080 seconds. However, in my experience with MEX-functions in general, there is usually a lot of overhead involved in making a large number of MEX function calls, in some cases, even 3x or 4x the actual execution time of the function. Is this is a possibilty in this case, even though the fft() is a built-in function? > > Also, I just have a nagging feeling that much of this time is being spent in memory allocation and reallocation. If so, is there any way, with or without MATLAB, that I can profile this fft() function and figure out how much time is spent on calculating *only* the Fourier transform itself? > > Also, if memory allocation is genuinely an issue, is there a way to keep the memory persistent between function calls? This is possible with user-defined MEX function with the mexMakeArrayPersistent() function, but is there a similar such setting with the FFTW library set? a hint: help profile; % <- make sure memory/jit switches are set... us |