Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Apple Businesses Science

FFTs Using AltiVec on Linux and Mac OS X 33

GregAllen writes "After searching for a good open-source AltiVec implementation of the Fast Fourier Transform (FFT), I have put together the AltiVec FFT page. It has all of the source, some benchmarks, and runs on Mac OS X or LinuxPPC. I even compared it to the venerable (but scalar) FFTW."
This discussion has been archived. No new comments can be posted.

FFTs Using AltiVec on Linux and Mac OS X

Comments Filter:
  • the obligatory... (Score:2, Insightful)

    by ndevice ( 304743 )
    even faster mp3 / dvd / video variant - encoding/decoding!

    Won't the *aa be pleased.

    'Consumers shouldn't be allowed to have machines that can encode media files quickly since we're the only ones who are allowed to produce this stuff...'

    'and no, why would consumers need machines that can decode a media file faster than the realtime playback speed? if you're playing something back, you won't need to do anything else...'
  • memory interleaving (Score:2, Interesting)

    by ndevice ( 304743 )
    from the article:
    "Split data seems to be much faster with SIMD architectures"

    caching associativity and memory interleaving anyone?
    • caching associativity and memory interleaving anyone?

      I think the main reason is probably that vDSP only uses vectorized functions on split data, if it has to stride over the data set, it uses a scalar version of the function.

      Take a look at the docs [apple.com] for vDSP - for each function it lists the critera used to select the vector/scaler version of each function. You'll see the requirement that "Stride is equal to 1" pop up all the time - those functions only use altivec if the data has been split.
  • What exactly is a FFT, and why would I want to do one?
    • Re:What's a FFT (Score:5, Informative)

      by ndevice ( 304743 ) on Sunday March 23, 2003 @05:56AM (#5577706)
      an fft is a fast fourier transform. It is commonly used to transform data from the time domain to the frequency domain.

      What this means is that is if you have a time-varying signal like audio for example, you can run an fft on it and get a frequency analysis on the sound. i.e. from the sound in a waveform format, after an fft, you can pick out which are the dominant frequencies, and what the relationship between frequencies are.

      Although the fft is strictly not necessary because it is, after all, just a transform, it turns out that many media compression techniques use them because humans aren't as discriminating in the frequency domain so if you do lossy compression in the frequency domain, we won't notice/mind as much.

      fyi, you do an fft any time you view a .jpg, or listen to an .mp3, or watch a dvd, etc. Lots of uses for them, and that doesn't even get into the engineering/scientific uses...
      • Such as SETI@home. It runs FFT for a split-second before doing the more CPU intensive tasks.
      • Re:What's a FFT (Score:5, Informative)

        by nathanh ( 1214 ) on Sunday March 23, 2003 @08:09AM (#5577844) Homepage
        fyi, you do an fft any time you view a .jpg, or listen to an .mp3, or watch a dvd, etc.

        You use a FFT anytime you ENCODE a .jpg, or an .mp3, or a DVD. When you view or listen or watch you are using an Inverse FFT.

        And to be very specific, I think all your examples use DCT (Discrete Cosine Transform) and not FFT. JPEG definitely does. Very good overview here [cs.sfu.ca]

        • oops, my mistake. Got my series mixed up there.
        • by melquiades ( 314628 ) on Sunday March 23, 2003 @01:35PM (#5578671) Homepage
          Although people often use the terms interchangably, strictly speaking the Fourier Transform is the mathematical operation (like "sort") and the FFT is a particular way of computing it (like "quicksort").

          The FFT is a particularly FAST algorithm for computing Fourier Transforms, with O(n log n) instead of O(n^2) for the naive algorithm -- thus the name. I believe that there is a comparably fast and very similar algorithm for computing the DCT, which doesn't really have a separate name.

          You use a FFT anytime you ENCODE a .jpg, or an .mp3, or a DVD. When you view or listen or watch you are using an Inverse FFT.

          True, though an inverse Fourier tranform is simply the Fourier transform run through a complex complement and multiplication by a constant. The FFT and the IFFT are essentially the same algorithm.

          And to be very specific, I think all your examples use DCT (Discrete Cosine Transform) and not FFT.

          Right ... though again, the DCT and the FT are essentially the same operation -- the DCT is just the real part of the FT (the FT is complex).
          • by plastik55 ( 218435 ) on Monday March 24, 2003 @05:51PM (#5586251) Homepage
            Right ... though again, the DCT and the FT are essentially the same operation -- the DCT is just the real part of the FT (the FT is complex).


            No -- the DCT spaces its components at half-wavenumbers while the FT has components spaced at integer wavenumbers. So only every other DCT components would be equal to the real part of an FT component. (that isn't strictly true, either, since most DCTs have a half-sample offset compared to FT)


            Interestingly enough it wasn't until the '90s that a "fast" or O(n log n) algorithm for calculating the DCT was found--this is well after it had become widely used in compression.

      • One quick correction:

        "It is commonly used to transform data from the time domain to the frequency domain."

        Technically, it can take data from any well-behaved domain to the frequency domain, not just temporal data. I use FFTs on spatial data more than temporal data. Just had to nitpick that. :)

        -Jellisky
    • Re:What's a FFT (Score:2, Informative)

      by Anonymous Coward
      FFT = Fast Fourier Transform. It's used to convert a signal from time domain to frequency domain, which is closer to the way human perception works. For example: To record audio data, air pressure changes over time are sampled. An FFT of a sequence of samples gives the freqencies which are in that block. Most current media compression schemes make use of this transformation to identify the data components which are least noticeable when left out or encoded with reduced precision.
  • by RalphBNumbers ( 655475 ) on Sunday March 23, 2003 @10:06AM (#5577976)
    Note that MacOS X has a library called vDSP which is as much as twice as fast as vBigDSP on split data. Source code is not available, making it difficult to port to Linux.


    So unless you're writing something for OSX and linux, want to use the same libs on both and are willing to sacrifice a 2x speed increase, you'd be well advised not to use this library package for FFTs on OSX.
    • by GregAllen ( 178208 ) on Sunday March 23, 2003 @12:18PM (#5578358) Homepage
      It's important to point out that the "traditional way" to store complex numbers (and do an FFT) is with interleaved data. If your application uses interleaved data (and most do), then this library is for you. Split data is being used more because of the obvious performance improvements, but you have to change your code (and your mindset) to use it.

      I've updated it to say: as much as twice as fast as vBigDSP on split data (but about the same on interleaved data).

      I'd like to get an open-source split-data version to add to the site, so Linux users get good split-data FFTs, too.
      • I've updated it to say: as much as twice as fast as vBigDSP on split data (but about the same on interleaved data).

        There's a rather obvious reason for this, if you read the docs on vDSP [apple.com].

        All of the functions are provided in vector and scalar forms, with a set of criteria listed that must be met for the vector form of the function to be used. You'll see the requirement "Stride must be equal to 1" quite often.
        In other words, the function is only vectorized for split data, and runs a slower scalar versio
        • by using interleaved data, you are benchmarking a scalar vDSP against your other scalar algorithms

          This is clearly not the case. On an 800 MHz G4, the peak scalar performance is 1600 MFLOPS. You're lucky to get 800 MFLOPS, just like the (very good) scalar FFTW. That's exactly why we have SIMD/AltiVec.

          I'm using Apple's ctoz() and ztoc() to convert from interleaved to split and back, and getting "about the same as vBigDSP" -- that's 1-2 GFLOPS. Without these conversions, that curve peaks at about 4 GFLOP
  • by dcstimm ( 556797 ) on Sunday March 23, 2003 @11:06AM (#5578137) Homepage
    I use Gentoo Linux on my ibook and since I can compile all my code for my g3 cpu, I notice a huge speed increase between linux and macosx. Since My cpu doesnt take advantage of altivec apps that are compiled for altivec run slow on a g3. Apps that are directly compiled for a g3 will run 20-30% faster. Of course apple could make Macosx faster for g3 people if they recompiled the OS with out altivec support, but they cant do that. With My g4 system I dont see a huge speed difference in linux unless I use more aggressive gcc optimizations. Anyway, Linux on a g3 will always run faster than macosx on a g3.
    • This is probably because OS/X is heavily altivec-optimized, and g3's don't have altivec. So basically what you're saying is "a g3 optimized operating system is faster on my g3 than a g4 optimized operating system."

      Shocking, eh?

    • This is wrong. Apps that are compiled for Altivec don't run at all on G3s. That is why if you want to run Altivec code you have to detect at runtime what CPU you are on and run a non-Altivec version (or quit) if you are on a G3. So adding in optimizations for G4s do not make G3s run slower: they just run the non-optimized, plain PPC version.

      You notice a speed difference between OSX and Linux because you compiled Linux from source for the G3? Huh? Perhaps it is because you are running a completely dif
      • Just to pick nits, I've never seen anyone (other than maybe a few open source projects during early development) include two copies of an application. Most apps only benefit from altivec enhancements in a handful of frequently used but easily isolated core processing routines. Thus, they simply take one conditional path on hardware with Altivec and a different path on hardware without it.

        Also you don't compile an application for Altivec. You write a separate version of those core routines that is compl

  • Old story? (Score:2, Informative)

    I wonder when this benchmark was published, because the FFTW homepage [fftw.org] already offers a 3.0beta for download, including SIMD support (SSE/SSE2/3DNow!/Altivec) support.

    For applications where raw speed is not very important I recommend everyone to use the fftw library, it is already installed on a lot of systems and easy in use. Very fast are Intel's SDK version and DJ Bernstein's [cr.yp.to] (only 256 points).
  • by Dominic_Mazzoni ( 125164 ) on Sunday March 23, 2003 @02:23PM (#5578913) Homepage
    Well, FFTW 3.0 beta [fftw.org] has been released, and it includes Altivec support. I would be very surprised if this new FFTW wasn't extremely competitive with all the benchmarks presented on this page, if not better.

    Anyone want to add it to the benchmark?
  • by twoflower ( 24166 ) on Sunday March 23, 2003 @03:10PM (#5579066)
    Have you tried djbfft [cr.yp.to]? You might want to, as it's quality software from a hardcore mathematician.
    • The djbfft website clearly emphasizes the Pentium, and makes no mention of AltiVec. I have personally found FFTW to be relatively fast on most (non-vector) platforms. However, the AltiVec FFTs smoke it.

      You have to give the FFTW people credit: they have provided their results, and made it easy for you to reproduce them. I guess that's why they're at MIT, and djbfft is at.... Where is it again?

      I don't really care who wrote my FFT, I just want it to be FAST and CORRECT.

      The djbfft website sounds like a lo
      • The djbfft website clearly emphasizes the Pentium, and makes no mention of AltiVec. I have personally found FFTW to be relatively fast on most (non-vector) platforms. However, the AltiVec FFTs smoke it.

        djbfft is faster than FFTW. It's also faster than many FFT libraries that sacrifice accuracy for speed. I asked if you had tried it, and you didn't answer.

        You have to give the FFTW people credit: they have provided their results, and made it easy for you to reproduce them. I guess that's why they're at

        • djbfft is faster than FFTW

          As is (almost) every AltiVec FFT benchmarked on the site -- FFTW is the slowest one listed. I included FFTW only because it is a "well known" scalar point of reference -- it is obviously very well known to djb. The topic of discussion is AltiVec, which djbfft clearly does not use. No matter how fast of a scalar implementation djbfft is, it cannot hope to compete with vBigDSP.

          I mean absolutely no disrespect to Dr. Bernstein. On his site [cr.yp.to] he makes statements such as this: How many

  • What about Matlab? (Score:1, Interesting)

    by Anonymous Coward
    I always just use MATLAB. Does exactly what I need with speed and grace. I just hope that they come out with an OS X graphical version soon...
    • by coult ( 200316 )
      Umm...not sure what is meant by "OS X graphical version", but I'm running Matlab for OS X and its the full version, does everything that it does on other platforms, including fancy graphics. It works really well with Apple's X11 because then all the graphics are hardware accelerated.

"Kill the Wabbit, Kill the Wabbit, Kill the Wabbit!" -- Looney Tunes, "What's Opera Doc?" (1957, Chuck Jones)

Working...