📄 gpufftw.h
字号:
/******************************************************************************\
Copyright 2005 The University of North Carolina at Chapel Hill.
All Rights Reserved.
Permission to use, copy, modify and distribute this software and its
documentation for educational, research and non-profit purposes, without
fee, and without a written agreement is hereby granted, provided that the
above copyright notice and the following three paragraphs appear in all
copies. Any use in a commercial organization requires a separate license.
IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE
TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA HAVE BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Permission to use, copy, modify and distribute this software and its
documentation for educational, research and non-profit purposes, without
fee, and without a written agreement is hereby granted, provided that the
above copyright notice and the following three paragraphs appear in all
copies.
THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
"AS IS" BASIS, AND THE UNIVERSITY OF NORTH CAROLINA HAS NO OBLIGATION TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
---------------------------------
|Please send all BUG REPORTS to: |
| |
| geom@cs.unc.edu |
| |
---------------------------------
The authors may be contacted via:
US Mail: N. Govindaraju or D. Manocha
Department of Computer Science
Sitterson Hall, CB #3175
University of North Carolina
Chapel Hill, NC 27599-3175
Add functions manycgpufft1d and manyscgpufft1d
by Simon Potvin and Jerome Genest, July 2006
Centre d'optique, photonique et laser (COPL)
Universite Laval
Quebec, Canada
Mail: simon.potvin.1@ulaval.ca
\*****************************************************************************/
#include <arbfprog.h>
enum FFT_ERROR {FFT_SUCCESS, FFT_ARRAY_TOO_BIG, FFT_ARRAY_TOO_SMALL, FFT_NON_POWER_OF_TWO};
inline int comparePtr(const void *i1, const void *i2);
class GPUFFTW{
public: //methods
//ctor
/*
* Parameters:
*/
GPUFFTW();
//dtor
~GPUFFTW();
/* Returns max array size that can be handled depending on video RAM */
int maxSize(){
return(MAX_SIZE);
}
/* Sorts an input array of (key,pointer) tuples on the GPU.
* WARNING: The contents of the array will be overwritten with the sorted result.
*
* Parameters:
* array: array of tuples to sort
* size: length of array
* Return value:
* error code. FFT_SUCCESS is returned in case of no error.
* Use errorToString() to print formatted string of error code.
*/
FFT_ERROR cgpufft1d(float *array, float *ptrs, int size, int sign, int isreal=0);
FFT_ERROR scgpufft1d(float *real, int size, int sign);
FFT_ERROR setFFTParams(int size);
/*Compute many fft
* WARNING: The contents of real and imag must be transpose. For example, if you have two real array(fft_1 and fft_2) of 16 points,
* the contents of real is going to be { fft_1[1], fft_2[1], fft_1[2], fft_2[2], fft_1[3], fft_2[3], ... , fft_1[16], fft2_[16] }.
*
* Parameters:
* arraywidth : length of fft(must be power of 2)
* arrayheight : numbers of fft(must be 1 or power of 2)
* Return value:
* error code. FFT_SUCCESS is returned in case of no error.
* Use errorToString() to print formatted string of error code.
*/
FFT_ERROR manycgpufft1d(float *real, float *imag, int arraywidth, int arrayheight, int sign, int isreal);
FFT_ERROR manyscgpufft1d(float *real, int arraywidth, int arrayheight, int sign);
/* Upload float data to Video Memory.
*
* Parameters:
* array: Input data. All the required parameters not explicit here are supposed
* to have been set by a preceeding call to setSortParams().
* Return Value:
* None
*
* Assumption: All the pointers are 32-bit (float * and void *)
*
*/
void uploadData(void *array);
/* Read data back from GPU to CPU memory
*
* Parameters:
* array: an array of scalars or (key,pointer) tuples depending
* on whether tuples was set to FALSE or TRUE in the call
* to setSortParams()
* Return value:
* None
*
*/
void readbackData(void *array);
/* Print a formatted error string for errors returned from sort() */
char *FFTErrorString(FFT_ERROR error);
FFT_ERROR cGPUFFTW2d(float *real, float *imag, int arraywidth, int arrayheight, int sign, int isreal);
void CheckErrors();
private: //methods
inline void PingPong();
void PingPong2to4();
void PingPong4to2();
void cgpufft1d( float sign, int usedfor2dfft=0 );
private: //data
int W, H, MAX_SIZE, MIN_SIZE;
int Width, Height, N, LOGN;
unsigned int fb;
unsigned int textureid[6];//last two as temporary buffers
ARBFProg copyfp;
ARBFProg fullscreenrowwidthfp;
ARBFProg fftstages_twicerowwidth_to_n_fp;
ARBFProg fftstages3_to_rowwidthfp;
ARBFProg fullscreenfft1ststage;
ARBFProg fullscreenfft2ndstagefp;
int TILE_SIZE;
int source, target;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -