📄 fftw-int.h
字号:
extern fftw_time fftw_get_time(void); -- a function returning the current time. (We have implemented this as a macro in most cases.) extern fftw_time fftw_time_diff(fftw_time t1, fftw_time t2); -- returns the time difference (t1 - t2). If t1 < t2, it may simply return zero (although this is not required). (We have implemented this as a macro in most cases.) extern double fftw_time_to_sec(fftw_time t); -- returns the time t expressed in seconds, as a double. (Implemented as a macro in most cases.) FFTW_TIME_MIN -- a double-precision macro holding the minimum time interval (in seconds) for accurate time measurements. This should probably be at least 100 times the precision of your clock (we use even longer intervals, to be conservative). This will determine how long the planner takes to measure the speeds of different possible plans. Bracket all of your definitions with an appropriate #ifdef so that they will be enabled on your machine. If you do add your own high-precision timer code, let us know (at fftw@fftw.org). Only declarations should go in this file. Any function definitions that you need should go into timer.c. *//* * define a symbol so that we know that we have the fftw_time_diff * function/macro (it did not exist prior to FFTW 1.2) */#define FFTW_HAS_TIME_DIFF/********************************************** * SOLARIS **********************************************/#if defined(HAVE_GETHRTIME) && defined(HAVE_HRTIME_T)/* we use the nanosecond virtual timer */#ifdef HAVE_SYS_TIME_H#include <sys/time.h>#endiftypedef hrtime_t fftw_time;#define fftw_get_time() gethrtime()#define fftw_time_diff(t1,t2) ((t1) - (t2))#define fftw_time_to_sec(t) ((double) t / 1.0e9)/* * a measurement is valid if it runs for at least * FFTW_TIME_MIN seconds. */#define FFTW_TIME_MIN (1.0e-4) /* for Solaris nanosecond timer */#define FFTW_TIME_REPEAT 8/********************************************** * Pentium time stamp counter **********************************************/#elif defined(__GNUC__) && defined(__i386__) && defined(FFTW_ENABLE_PENTIUM_TIMER)/* * Use internal Pentium register (time stamp counter). Resolution * is 1/FFTW_CYCLES_PER_SEC seconds (e.g. 5 ns for Pentium 200 MHz). * (This code was contributed by Wolfgang Reimer) */#ifndef FFTW_CYCLES_PER_SEC#error "Must define FFTW_CYCLES_PER_SEC in fftw/config.h to use the Pentium cycle counter"#endiftypedef unsigned long long fftw_time;static __inline__ fftw_time read_tsc(){ fftw_time ret; __asm__ __volatile__("rdtsc": "=A" (ret)); /* no input, nothing else clobbered */ return ret;}#define fftw_get_time() read_tsc()#define fftw_time_diff(t1,t2) ((t1) - (t2))#define fftw_time_to_sec(t) (((double) (t)) / FFTW_CYCLES_PER_SEC)#define FFTW_TIME_MIN (1.0e-4) /* for Pentium TSC register *//************* generic systems having gettimeofday ************/#elif defined(HAVE_GETTIMEOFDAY) || defined(HAVE_BSDGETTIMEOFDAY)#ifdef HAVE_SYS_TIME_H#include <sys/time.h>#endif#ifdef HAVE_UNISTD_H#include <unistd.h>#endif#define FFTW_USE_GETTIMEOFDAYtypedef struct timeval fftw_time;extern fftw_time fftw_gettimeofday_get_time(void);extern fftw_time fftw_gettimeofday_time_diff(fftw_time t1, fftw_time t2);#define fftw_get_time() fftw_gettimeofday_get_time()#define fftw_time_diff(t1, t2) fftw_gettimeofday_time_diff(t1, t2)#define fftw_time_to_sec(t) ((double)(t).tv_sec + (double)(t).tv_usec * 1.0E-6)#ifndef FFTW_TIME_MIN/* this should be fine on any system claiming a microsecond timer */#define FFTW_TIME_MIN (1.0e-2)#endif/********************************************** * MACINTOSH **********************************************/#elif defined(HAVE_MAC_TIMER)/* * By default, use the microsecond-timer in the Mac Time Manager. * Alternatively, by changing the following #if 1 to #if 0, you * can use the nanosecond timer available *only* on PCI PowerMacs. * WARNING: the nanosecond timer was just a little experiment; * I haven't gotten it to work reliably. Tips/patches are welcome. */#ifndef HAVE_MAC_PCI_TIMER /* use time manager *//* * Use Macintosh Time Manager routines (maximum resolution is about 20 * microseconds). */typedef struct fftw_time_struct { unsigned long hi, lo;} fftw_time;extern fftw_time get_Mac_microseconds(void);#define fftw_get_time() get_Mac_microseconds()/* define as a function instead of a macro: */extern fftw_time fftw_time_diff(fftw_time t1, fftw_time t2);#define fftw_time_to_sec(t) ((t).lo * 1.0e-6 + 4294967295.0e-6 * (t).hi)/* very conservative, since timer should be accurate to 20e-6: *//* (although this seems not to be the case in practice) */#define FFTW_TIME_MIN (5.0e-2) /* for MacOS Time Manager timer */#else /* use nanosecond timer *//* Use the nanosecond timer available on PCI PowerMacs. */#include <DriverServices.h>typedef AbsoluteTime fftw_time;#define fftw_get_time() UpTime()#define fftw_time_diff(t1,t2) SubAbsoluteFromAbsolute(t1,t2)#define fftw_time_to_sec(t) (AbsoluteToNanoseconds(t).lo * 1.0e-9)/* Extremely conservative minimum time: *//* for MacOS PCI PowerMac nanosecond timer */#define FFTW_TIME_MIN (5.0e-3) #endif /* use nanosecond timer *//********************************************** * WINDOWS **********************************************/#elif defined(HAVE_WIN32_TIMER)#include <time.h>typedef unsigned long fftw_time;extern unsigned long GetPerfTime(void);extern double GetPerfSec(double ticks);#define fftw_get_time() GetPerfTime()#define fftw_time_diff(t1,t2) ((t1) - (t2))#define fftw_time_to_sec(t) GetPerfSec(t)#define FFTW_TIME_MIN (5.0e-2) /* for Win32 timer *//********************************************** * CRAY **********************************************/#elif defined(_CRAYMPP) /* Cray MPP system */double SECONDR(void); /* * I think you have to link with -lsci to * get this */typedef double fftw_time;#define fftw_get_time() SECONDR()#define fftw_time_diff(t1,t2) ((t1) - (t2))#define fftw_time_to_sec(t) (t)#define FFTW_TIME_MIN (1.0e-1) /* for Cray MPP SECONDR timer *//********************************************** * VANILLA UNIX/ISO C SYSTEMS **********************************************//* last resort: use good old Unix clock() */#else#include <time.h>typedef clock_t fftw_time;#ifndef CLOCKS_PER_SEC#ifdef sun/* stupid sunos4 prototypes */#define CLOCKS_PER_SEC 1000000extern long clock(void);#else /* not sun, we don't know CLOCKS_PER_SEC */#error Please define CLOCKS_PER_SEC#endif#endif#define fftw_get_time() clock()#define fftw_time_diff(t1,t2) ((t1) - (t2))#define fftw_time_to_sec(t) (((double) (t)) / CLOCKS_PER_SEC)/* * ***VERY*** conservative constant: this says that a * measurement must run for 200ms in order to be valid. * You had better check the manual of your machine * to discover if it can do better than this */#define FFTW_TIME_MIN (2.0e-1) /* for default clock() timer */#endif /* UNIX clock() *//* take FFTW_TIME_REPEAT measurements... */#ifndef FFTW_TIME_REPEAT#define FFTW_TIME_REPEAT 4#endif/* but do not run for more than TIME_LIMIT seconds while measuring one FFT */#ifndef FFTW_TIME_LIMIT#define FFTW_TIME_LIMIT 2.0#endif#ifdef __cplusplus} /* extern "C" */#endif /* __cplusplus */#endif /* FFTW_INT_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -