fftwlink(d).lib


Files

file  fftwlink.h

Functions

int _fftw_link_api (TCHAR *dll_path, unsigned flags)
void _fftw_unlink_api (unsigned flags)

Detailed Description

FFTWLink library.

This library permits the use of the right FFTW library compilation for the computer it is being run on.

To use, link your application with fftwlink.lib and call _fftw_link_api(), then use FFTW as described in the FFTW documentation, while making sure to prepend all FFTW functions and variable names with an underscore ("_").

Example:
/*
 * Copyight (c) 2005 Michaël Roy
 *
 * The fftw library is :
 *
 * Copyright (c) 2003 Matteo Frigo
 * Copyright (c) 2003 Massachusetts Institute of Technology
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include "../fftwlink/fftwlink.h"

#define NS (1 << 13)

double get_us(__int64 t0, __int64 t1, __int64 freq)
{
    return 1000000. * ((double)(t1 - t0) / (double)freq);
}

int main()
{
    __int64 t0, t1, freq;
    int i;
    unsigned flags;
    FILE* file;
    char* sz;

    fftw_complex *ci, *co;
    fftwf_complex *cfi, *cfo;

    fftw_plan plan;
    fftwf_plan planf;

    double us;

    QueryPerformanceFrequency((LARGE_INTEGER*)&freq);


    for (i = 0; i < 3; ++i)
    {
        switch(i) {
        case 0:
            printf("Loading fastest code for machine\n");
            flags = FFTW_LINK_FLOAT | FFTW_LINK_DOUBLE;
            break;
        case 1:
            printf("\nDisabling SSE2 code\n");
            flags = FFTW_LINK_FLOAT | FFTW_LINK_DOUBLE | FFTW_NO_SSE2;
            break;
        case 2:
            printf("\nDisabling SSE and SSE2 code\n");
            flags = FFTW_LINK_FLOAT | FFTW_LINK_DOUBLE | FFTW_NO_SSE | FFTW_NO_SSE2;
            break;
        }

        // unload is automatic on second call
        if(!_fftw_link_api(_T("..\\..\\bin"), flags))
        {
            printf("ERROR : can't load DLLs\n");
            return 1;
        }

        ci = _fftw_malloc(NS * sizeof(fftw_complex));
        co = _fftw_malloc(NS * sizeof(fftw_complex));
        plan = _fftw_plan_dft_1d(NS, ci, co, FFTW_FORWARD, FFTW_MEASURE);

        _fftw_execute(plan);
        QueryPerformanceCounter((LARGE_INTEGER*)&t0);
        _fftw_execute(plan);
        QueryPerformanceCounter((LARGE_INTEGER*)&t1);

        _fftw_destroy_plan(plan);

        us = get_us(t0, t1, freq);
        printf("_fftw_execute  : N = %d, time = %10.3lf us.\n", NS, us);

        cfi = _fftwf_malloc(NS * sizeof(fftwf_complex));
        cfo = _fftwf_malloc(NS * sizeof(fftwf_complex));
        planf = _fftwf_plan_dft_1d(NS, cfi, cfo, FFTW_FORWARD, FFTW_MEASURE);

        _fftwf_execute(planf);
        QueryPerformanceCounter((LARGE_INTEGER*)&t0);
        _fftwf_execute(planf);
        QueryPerformanceCounter((LARGE_INTEGER*)&t1);
        _fftwf_destroy_plan(planf);

        us = get_us(t0, t1, freq);
        printf("_fftwf_execute : N = %d, time = %10.3lf us.\n", NS, us);
    }

    return 0;
}

Function Documentation

int _fftw_link_api TCHAR *  dll_path,
unsigned  flags
 

loads the FFTW dll.

Loads the FFTW dll. Detects support for SSE and SSE2 and selects automatically the best library to load and run.

Parameters:
dll_path the folder where the DLLs are located. Must have no terminating backslash '\' character.
flags loading options. Valid options are:
  • FFTW_LINK_FLOAT indicates to load the float type library.
  • FFTW_LINK_DOUBLE indicates to load the double float type library.
  • FFTW_NO_SSE do not load the SSE-enabled library, even if the CPU supports SSE.
  • FFTW_NO_SSE2 do not load the SSE2-enabled library, even if the CPU supports SSE2.
Returns:
1 if successful, 0 on error.
See also:
_fftw_unlink_api()

void _fftw_unlink_api unsigned  flags  ) 
 

unloads the FFTW dll.

Unloads the FFTW dll.

Parameters:
flags loading options. Valid options are:
  • FFTW_LINK_FLOAT indicates to unload the float type library.
  • FFTW_LINK_DOUBLE indicates to unload the double float type library.
See also:
_fftw_link_api()


Generated on Thu Aug 24 17:54:18 2006 for The FFTWLink Library by  doxygen 1.4.5