Files | |
file | fftwlink.h |
Functions | |
int | _fftw_link_api (TCHAR *dll_path, unsigned flags) |
void | _fftw_unlink_api (unsigned flags) |
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 ("_").
/* * 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; }
|
loads the FFTW dll. Loads the FFTW dll. Detects support for SSE and SSE2 and selects automatically the best library to load and run.
|
|
unloads the FFTW dll. Unloads the FFTW dll.
|