--- ./gnuradio_new/src/gpu/gpu.cc 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/gpu.cc 2005-08-21 06:03:30.000000000 -0400 @@ -0,0 +1,171 @@ +#include "gpu.h" + +CGcontext context; +CGprofile vProfile, fProfile; +CGprogram fProg; +glut_simple_mouse_interactor object; +PBuffer *pbuf; +void (*current_display)(); +int gpu_size_x, gpu_size_y; + +void display() { + + pbuf->Activate(); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + object.apply_transform(); + + glEnable(GL_TEXTURE_RECTANGLE_NV); + cgGLEnableProfile(fProfile); + + if (current_display==NULL) { + fprintf(stderr, "current_display is NULL\n"); + exit(0); + } + + current_display(); + + pbuf->Deactivate(); + cgGLDisableProfile(fProfile); +} + +void cgErrorCallback(void) { + CGerror LastError = cgGetError(); + + if(LastError) { + const char *Listing = cgGetLastListing(context); + printf("\n---------------------------------------------------\n"); + printf("%s\n\n", cgGetErrorString(LastError)); + printf("%s\n", Listing); + printf("---------------------------------------------------\n"); + printf("Cg error, exiting...\n"); + cleanExit(0); + } +} + +void cleanExit(int code) { + if (fProg) cgDestroyProgram(fProg); + if (context) cgDestroyContext(context); + + delete pbuf; + +#if 0 + SAFE_DELETE(pixel_data); + SAFE_DELETE(matrix_data); + + glDeleteTextures(1, &hTexture1); + glDeleteTextures(1, &hTexture2); + glDeleteTextures(1, &hTextureDest); +#endif + + exit(code); +} + +void init_gpu() { + static string error_msg; + data_path media; + string file_fp; + CGprogram fProg; + int i; + + current_display=NULL; + + if (!glh_init_extensions( + "GL_ARB_vertex_program " + "GL_ARB_fragment_program " + "GL_ARB_multitexture " + "GL_ARB_vertex_program " + "GL_NV_texture_rectangle " + "GL_NV_texture_shader " + "GL_NV_register_combiners " + "GL_NV_float_buffer " + )) { + + printf("Unable to load the following extension(s): %s\n\nExiting...\n", + glh_get_unsupported_extensions()); + exit(0); + } + + + /* initialize pbuffer extensions */ +#define EXTENSIONS "GL_NV_texture_shader " \ + "GL_NV_register_combiners " \ + "GLX_SGIX_pbuffer " \ + "GLX_SGIX_fbconfig " + + if (!glh_init_extensions(EXTENSIONS)) { + error_msg += "need this extension(s): "; + error_msg += glh_get_unsupported_extensions(); + printf("%s\n", error_msg.c_str()); + exit(0); + } + + /* check the required extensions */ + for (i=0; iInitialize(gpu_size_x, gpu_size_y, false, true); + + /* this should be called every time before pbuf is used */ + pbuf->Activate(); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + pbuf->Deactivate(); + +} --- ./gnuradio_new/src/pspectra/lib/vr/VrMultiTask.cc 2005-10-24 10:12:13.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vr/VrMultiTask.cc 2005-09-14 05:57:12.000000000 -0400 @@ -42,12 +42,25 @@ #include #include +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include + +using namespace nv_dds; + +//extern glut_simple_mouse_interactor object; + +#endif + int BufferSizeMultiplier=1; #ifdef PERFMON //the scheduler could not find any data to mark unsigned long long couldNotMarkAnyData=0; #endif +void GrFXFIRfilterFCF_display(); // // CONSTRUCTORS @@ -56,6 +69,8 @@ : numberSinks(0), goodSinks(NULL), numSinks(0), numThreads(0), stopFlag(1) { #ifdef THREADS + printf("threads defined\n"); + FILE *f=fopen("/proc/cpuinfo","r"); numThreads=1; if(f!=NULL) { @@ -69,6 +84,38 @@ } } fprintf(stderr,"%d processors detected.\n",numThreads); +#else + + fprintf(stderr, "no threads in VrMultiTask\n"); + fflush(stderr); + +#endif + +#ifdef USE_GPU + int argc; + + argc=0; + gpu_size_x=gpu_size_y=700; + + glutInit(&argc, NULL); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); + glutInitWindowSize(gpu_size_x, gpu_size_y); + glutCreateWindow("GnuRadio on GPU"); + glutHideWindow(); + + init_gpu(); + + glutDisplayFunc(display); + glDisable(GL_DEPTH_TEST); + + current_display=NULL; + + /* + current_display = GrFXFIRfilterFCF_display; + glutPostRedisplay(); + glutMainLoopEvent(); + */ + #endif } @@ -92,6 +139,10 @@ delete [] goodSinks; if (sinks != NULL) delete [] sinks; + +#ifdef USE_GPU + cleanExit(0); +#endif } // @@ -358,11 +409,17 @@ min_index=i; } + fprintf(stderr, "min_index=%d seconds=%f\n", min_index, seconds[min_index]); + fflush(stderr); + for(i=0;igetMarkedWP() + incr * goodSinks[min_index]->getMaxOutputSize(), goodSinks[min_index]->getMaxOutputSize() }; + fprintf(stderr, "markedWP=%d maxoutputsize=%d\n", goodSinks[min_index]->getMarkedWP(), goodSinks[min_index]->getMaxOutputSize()); + fflush(stderr); + switch(goodSinks[min_index]->markData(r)) { //could add case 3 -- buffer full upstream -- compute whatever --- ./gnuradio_new/src/pspectra/lib/vr/VrSigProc.cc 2005-10-24 10:12:13.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vr/VrSigProc.cc 2005-09-14 08:54:30.000000000 -0400 @@ -47,6 +47,16 @@ VrSigProc *startMarkedModule; #endif +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +#endif + + //! has the data been computed? /*! * \return true if all data in \p r has been computed. @@ -184,10 +194,9 @@ VrSampleIndex pendingWP = markedWP; // what's already marked VrSampleIndex desiredWP = r.index + r.size; // goal - - if (DEBUG_SIGP) - printf ("[%s:%d] enter name %s WP %lld pendingWP %lld r.index %lld\n", - __FILE__, __LINE__, name(), WP, pendingWP, r.index); + // if (DEBUG_SIGP) + printf ("[%s:%d] enter name %s WP %lld pendingWP %lld desiredWP %lld r.index %lld\n", + __FILE__, __LINE__, name(), WP, pendingWP, desiredWP, r.index); // Check if data is already computed if (desiredWP <= WP) @@ -276,6 +285,10 @@ } requestSize = desiredWP - pendingWP; + + fprintf(stderr, "requestSize=%d outputSize=%d\n", requestSize, getOutputSize()); + fflush(stderr); + if(requestSize <= 0) // All data has been marked by another thread. // @@ -427,6 +440,7 @@ #else startMarkedModule = this; #endif + return MARK_READY; //continue marking downstream if possible } @@ -656,6 +670,7 @@ VrSigProc::connect_proc(VrSigProc* proc, port n) { VrConnect ** cs = new (VrConnect *[numberInputs+1]); + VrSigProc **ssp = new (VrSigProc *[numberInputs+1]); VrBuffer *b; if(n >= proc->numberOutputs) { @@ -676,16 +691,21 @@ b = proc->outBuffer[n]; cs[numberInputs] = new VrConnect((VrSigProc *) this, b); + ssp[numberInputs] = proc; + if (numberInputs > 0) { - for(unsigned int i=0; i < numberInputs; i++) + for(unsigned int i=0; i < numberInputs; i++) { + ssp[i] = inputSigProc[i]; cs[i] = inputConn[i]; + } delete inputConn; + delete inputSigProc; } + inputConn = cs; + inputSigProc = ssp; numberInputs++; - - return true; } @@ -737,6 +757,74 @@ return 0; } +#ifdef USE_GPU + +void VrSigProc::create_textures() { + + const int width=700; + const int height=200; + + create_texture(width, height, NULL, &hTextureIn); + create_texture(width, height, NULL, &hTextureOut); + create_texture(width, height, NULL, &hTextureTaps); +} + +void VrSigProc::delete_textures() { + glDeleteTextures(1, &hTextureIn); + glDeleteTextures(1, &hTextureOut); + glDeleteTextures(1, &hTextureTaps); +} + +void* VrSigProc::get_gpu_output() { + void *data_out; + int i; + + if (get_read_textures(0)) { + int w=get_texture_width(0); + int h=get_texture_height(0); + + data_out = malloc(w*h*sizeof(float)*4); + +#if 1 + pbuf->Activate(); + glReadPixels(0, 0, w, h, GL_RGBA, GL_FLOAT, data_out); + pbuf->Deactivate(); +#endif + +#if 0 + for (i=0; igpu_width; +} + +int VrSigProc::get_texture_height(int ind) { + return inputSigProc[ind]->gpu_height; +} + +int VrSigProc::get_k(int ind) { + return inputSigProc[ind]->gpu_k; +} + +int VrSigProc::get_read_textures(int ind) { + return inputSigProc[ind]->read_textures; +} + +GLuint VrSigProc::get_texture_out(int ind) { + return inputSigProc[ind]->hTextureOut; +} + +#endif + int VrSigProc::forecast(VrSampleRange output, VrSampleRange inputs[]) { /* 1:1 ratio with no history */ for(unsigned int i=0;igetNumberConnectors(); //FIX @@ -818,7 +916,10 @@ size = (size/getOutputSize()) * getOutputSize(); //round down if(size == 0) size = getOutputSize(); - + + fprintf(stderr, "setup_upstream outputsize=%d size=%u maxDSRead=%d name=%s\n", getOutputSize(), size, maxDSReadSize, name()); + fflush(stderr); + /*If our maxOutSize is changing propagate the setup upstream */ if(size!=maxOutSize) { maxOutSize=size; @@ -834,10 +935,20 @@ } unsigned int oSize = getUpstreamModuleN(i)->getOutputSize(); unsigned int size_up = mapSizeUp(i,size); + + fprintf(stderr, "size=%d size_up=%u sf=%f upstream sf=%f\n", size, size_up, getSamplingFrequency(), getUpstreamModuleN(i)->getSamplingFrequency()); + fflush(stderr); + ROUNDUP(size_up, oSize); //add an extra block in case a read is not outputSize aligned size_up += oSize; + fprintf(stderr, "setup_upstream name=%s osize=%d size=%d size_up=%d\n", getUpstreamModuleN(i)->name(), oSize, size, size_up); + fflush(stderr); getUpstreamModuleN(i)->size_setup(size_up); +#if 0 + fprintf(stderr, "new sampling freq=%f\n", getUpstreamModuleN(i)->getSamplingFrequency()); + fflush(stderr); +#endif } } } @@ -846,13 +957,22 @@ // given it has to produce size outputs unsigned int VrSigProc::mapSizeUp(int i, unsigned int size) { - return (unsigned int) (size * + unsigned int res; + res=(unsigned int) (size * (getUpstreamModuleN(i)->getSamplingFrequency() /getSamplingFrequency())); + + fprintf(stderr, "mapSizeUp returns %d\n", res); + fflush(stderr); + + return res; } void VrSigProc::size_setup(unsigned int size) { + fprintf(stderr, "size_setup size=%d\n", size); + fflush(stderr); + if(size > maxDSReadSize) maxDSReadSize = size; VrSigProc::setup(); --- ./gnuradio_new/src/gnu/lib/grbase/gr_vmcircbuf.cc 2005-10-24 10:12:31.000000000 -0400 +++ ./gnuradio/src/gnu/lib/grbase/gr_vmcircbuf.cc 2005-08-19 12:44:04.000000000 -0400 @@ -75,7 +75,7 @@ // either we don't have a default, or the default named is not in our // list of factories. Find the first factory that works. - if (verbose) + // if (verbose) fprintf (stderr, "gr_vmcircbuf_sysconfig: finding a working factory...\n"); for (unsigned int i = 0; i < all.size (); i++){ --- ./gnuradio_new/src/gpu/GrFXFIRfilterFCC.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/GrFXFIRfilterFCC.cg 2005-09-11 15:11:07.000000000 -0400 @@ -0,0 +1,140 @@ +/* -*-C-*- */ + +/* FIR filter shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2, uniform float4 Params) { + frag_out OUT; + + float4 color1, color2, color3, tmp; + float2 coord1; + float4x4 mat; + float xmod2; + float nc, nc1, nc2, cosn, sinn; + float2 rotv; + float pi2; + + float4 color0 = texRECT(tex0, IN.texcoord0); + + pi2=8.0*atan(1.0f); + + tmp=float4(0,0,0,0); + mat=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + + Params.x=floor(Params.x+1); + + xmod2=fmod(IN.texcoord0.x+0.1, 2)-1.0f; + + for (float i=0; i=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + color2=texRECT(tex2, IN.texcoord2+float2(i*2, 0)); + color3=texRECT(tex2, IN.texcoord2+float2(i*2+1, 0)); + + if (xmod2>0) { + // odd + mat[0].zw=color2.xz; + mat[1].zw=color2.yw; + mat[2].w=color2.x; + mat[3].w=color2.y; + + tmp=tmp+mul(mat, color1); + + mat[0].xy=color3.xz; + mat[1].xy=color3.yw; + mat[2].xyz=float3(color2.z, color3.x, color3.z); + mat[3].xyz=float3(color2.w, color3.y, color3.w); + + } else { + // even + mat[0]=float4(color2.x, color2.z, color3.x, color3.z); + mat[1]=float4(color2.y, color2.w, color3.y, color3.w); + mat[2].yzw=float3(color2.x, color2.z, color3.x); + mat[3].yzw=float3(color2.y, color2.w, color3.y); + + tmp=tmp+mul(mat, color1); + + mat[2].x=color3.z; + mat[3].x=color3.w; + } + } + + coord1 = IN.texcoord1+float2(Params.x, 0); + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + + if (xmod2>0) { + mat[0].zw=float2(0,0); + mat[1].zw=float2(0,0); + mat[2].w=0.0f; + mat[3].w=0.0f; + + } else { + mat[0]=float4(0,0,0,0); + mat[1]=float4(0,0,0,0); + mat[2].yzw=float3(0,0,0); + mat[3].yzw=float3(0,0,0); + } + + tmp=tmp+mul(mat, color1); + + // rotate tmp + nc=floor(IN.texcoord0.x)*2+floor(IN.texcoord0.y)*Params.x*4; + + nc1=fmod(nc+Params.z, Params.w); + nc1=frac(nc1*Params.y); + nc1=nc1*pi2; + + // first complex number + cosn=cos(nc1); + sinn=sin(nc1); + + rotv.x=tmp.x*cosn-tmp.y*sinn; + rotv.y=tmp.x*sinn+tmp.y*cosn; + + tmp.xy=rotv; + + //OUT.Color0.xy=float2(cosn, sinn); + + // second complex number + nc2=fmod(nc+Params.z+1, Params.w); + nc2=frac(nc2*Params.y); + nc2=nc2*pi2; + + cosn=cos(nc2); + sinn=sin(nc2); + + rotv.x=tmp.z*cosn-tmp.w*sinn; + rotv.y=tmp.z*sinn+tmp.w*cosn; + + tmp.zw=rotv; + + //OUT.Color0.zw=float2(cosn, sinn); + + OUT.Color0=tmp+color0; + + return OUT; +} --- ./gnuradio_new/src/gpu/GrFIRfilterFFFnc.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/GrFIRfilterFFFnc.cg 2005-09-04 11:27:09.000000000 -0400 @@ -0,0 +1,91 @@ +/* -*-C-*- */ + +/* FIR filter shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2, + uniform float4 Params) { + frag_out OUT; + + float4 color1, color2, tmp; + float2 coord1, coord2; + float4x4 mat; + float x1, x2; + float i; + + float4 color0 = texRECT(tex0, IN.texcoord0); + + tmp=float4(0,0,0,0); + mat=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + + coord1=IN.texcoord1; + coord2=IN.texcoord2; + + x1=Params.x-floor(coord1.x); + x2=floor(coord1.x); + + for (i=0.1f; i=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + mat[0]=color2; + mat[1].yzw=color2.xyz; + mat[2].zw=color2.xy; + mat[3].w=color2.x; + + tmp=tmp+mul(mat, color1); + + mat[1].x=color2.w; + mat[2].xy=color2.zw; + mat[3].xyz=color2.yzw; + } + + color1=texRECT(tex1, coord1); + + mat[0]=float4(0,0,0,0); + mat[1].yzw=float3(0,0,0); + mat[2].zw=float2(0,0); + mat[3].w=0.0f; + + tmp=tmp+mul(mat, color1); + + OUT.Color0=tmp+color0; + + /* + color1=texRECT(tex1, IN.texcoord1); + OUT.Color0=color1; + */ + + //OUT.Color0=float4(1.0f, 2.0f, 3.0f, 4.0f); + + return OUT; +} --- ./gnuradio_new/src/gpu/GrFIRfilterFFFh4.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/GrFIRfilterFFFh4.cg 2005-09-02 13:57:31.000000000 -0400 @@ -0,0 +1,109 @@ +/* -*-C-*- */ + +/* FIR filter shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2, uniform float4 Params) { + frag_out OUT; + + float4 tmp; + float4 color1, color2, color3, color4; + float4 color5, color6, color7, color8; + float2 coord1, coord2, coord3, coord4; + float2 coord5, coord6, coord7, coord8; + float4x4 mat; + + float4 color0 = texRECT(tex0, IN.texcoord0); + + tmp=float4(0,0,0,0); + mat=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + + for (float i=0; i=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + + if (coord3.x>=Params.x) { + coord3.x -= Params.x; + coord3.y += 1; + } + + color3=texRECT(tex1, coord1); + + mat[0]=color2; + mat[1].yzw=color2.xyz; + mat[2].zw=color2.xy; + mat[3].w=color2.x; + + tmp=tmp+mul(mat, color1); + + mat[1].x=color2.w; + mat[2].xy=color2.zw; + mat[3].xyz=color2.yzw; + + coord5 = IN.texcoord1+float2(i+2, 0); + coord7 = IN.texcoord1+float2(i+3, 0); + + mat[0]=color4; + mat[1].yzw=color4.xyz; + mat[2].zw=color4.xy; + mat[3].w=color4.x; + + tmp=tmp+mul(mat, color3); + + mat[1].x=color4.w; + mat[2].xy=color4.zw; + mat[3].xyz=color4.yzw; + } + + coord1 = IN.texcoord1+float2(Params.x, 0); + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + + mat[0]=float4(0,0,0,0); + mat[1].yzw=float3(0,0,0); + mat[2].zw=float2(0,0); + mat[3].w=0.0f; + + tmp=tmp+mul(mat, color1); + + OUT.Color0=tmp+color0; + + return OUT; + +} --- ./gnuradio_new/src/gpu/GRFIRfilterFFFu.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/GRFIRfilterFFFu.cg 2005-09-03 16:22:02.000000000 -0400 @@ -0,0 +1,121 @@ +/* -*-C-*- */ + +/* FIR filter shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2, + uniform float4 Params) { + frag_out OUT; + + float4 color1, color2, color3, color4, tmp; + float2 coord1, coord2, coord3, coord4; + float4x4 mat; + + float4 color0 = texRECT(tex0, IN.texcoord0); + + tmp=float4(0,0,0,0); + mat=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + + coord1=IN.texcoord1; + coord2=IN.texcoord2; + + color1=texRECT(tex1, coord1); + color2=texRECT(tex2, coord2); + + coord3=coord1; + coord4=coord2; + + coord1 += float2(1,0); + coord2 += float2(1,0); + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + for (float i=0; i=Params.x) { + coord3.x -= Params.x; + coord3.y += 1; + } + + mat[0]=color2; + mat[1].yzw=color2.xyz; + mat[2].zw=color2.xy; + mat[3].w=color2.x; + + color4=texRECT(tex2, coord2); + tmp=tmp+mul(mat, color1); + color1=texRECT(tex1, coord3); + + mat[1].x=color2.w; + mat[2].xy=color2.zw; + mat[3].xyz=color2.yzw; + + coord1 += float2(2,0); + coord2 += float2(2,0); + + + if (coord2.x>=Params.x) { + coord2.x -= Params.x; + coord2.y += 1; + } + + + mat[0]=color4; + mat[1].yzw=color4.xyz; + mat[2].zw=color4.xy; + mat[3].w=color4.x; + + + color2=texRECT(tex2, coord4); + tmp=tmp+mul(mat, color3); + + mat[1].x=color4.w; + mat[2].xy=color4.zw; + mat[3].xyz=color4.yzw; + + } + + /* + coord1 = IN.texcoord1+float2(Params.x, 0); + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + */ + + /* + color1=texRECT(tex1, coord1); + */ + + mat[0]=float4(0,0,0,0); + mat[1].yzw=float3(0,0,0); + mat[2].zw=float2(0,0); + mat[3].w=0.0f; + + tmp=tmp+mul(mat, color3); + + OUT.Color0=tmp+color0; + + return OUT; +} --- ./gnuradio_new/src/gpu/GrFIRfilterFFFh2.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/GrFIRfilterFFFh2.cg 2005-09-03 10:50:53.000000000 -0400 @@ -0,0 +1,124 @@ +/* -*-C-*- */ + +/* FIR filter shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; + float2 texcoord3 : TEXCOORD3; + float2 texcoord4 : TEXCOORD4; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2, uniform samplerRECT tex3, uniform samplerRECT tex4, + uniform float4 Params) { + frag_out OUT; + + float4 color1, color2, color3, color4, tmp; + float2 coord1, coord2, coord3, coord4; + float4x4 mat1, mat2; + + float4 color0 = texRECT(tex0, IN.texcoord0); + + tmp=float4(0,0,0,0); + mat1=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + mat2=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + + coord1=IN.texcoord1; + coord2=IN.texcoord2; + coord3=IN.texcoord3; + coord4=IN.texcoord4; + + for (float i=0; i=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color3=texRECT(tex3, coord3); + color4=texRECT(tex4, coord4); + + /* first matrix update */ + mat1[0]=color2; + mat1[1].yzw=color2.xyz; + mat1[2].zw=color2.xy; + mat1[3].w=color2.x; + + tmp=tmp+mul(mat1, color1); + + mat1[1].x=color2.w; + mat1[2].xy=color2.zw; + mat1[3].xyz=color2.yzw; + + coord3.x += 1.0f; + coord4.x += 1.0f; + + if (coord3.x>=Params.x) { + coord3.x -= Params.x; + coord3.y += 1; + } + + mat2[0]=color4; + mat2[1].yzw=color4.xyz; + mat2[2].zw=color4.xy; + mat2[3].w=color4.x; + + //tmp=tmp+mul(mat2, color3); + + mat2[1].x=color4.w; + mat2[2].xy=color4.zw; + mat2[3].xyz=color4.yzw; + + } + + coord1 = IN.texcoord1+float2(Params.x, 0); + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + + coord3 = IN.texcoord3+float2(Params.x, 0); + + if (coord3.x>=Params.x) { + coord3.x -= Params.x; + coord3.y += 1; + } + + color3=color1; + //color3=texRECT(tex3, coord3); + + mat1[0]=float4(0,0,0,0); + mat1[1].yzw=float3(0,0,0); + mat1[2].zw=float2(0,0); + mat1[3].w=0.0f; + + tmp=tmp+mul(mat1, color1); + + mat2[0]=float4(0,0,0,0); + mat2[1].yzw=float3(0,0,0); + mat2[2].zw=float2(0,0); + mat2[3].w=0.0f; + + tmp=tmp+mul(mat2, color3); + + OUT.Color0=tmp+color0; + + return OUT; +} --- ./gnuradio_new/src/gpu/test1_fp.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/test1_fp.cg 2005-08-22 10:13:14.000000000 -0400 @@ -0,0 +1,42 @@ +/* -*-C-*- */ + +/* Sample pixel shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2) { + + frag_out OUT; + float4 tmp; + + /* + float4 color1 = texRECT(tex0, IN.texcoord0); + float4 color2 = texRECT(tex1, IN.texcoord1); + + float4 color31 = texRECT(tex2, IN.texcoord2); + float4 color32 = texRECT(tex2, IN.texcoord2+float2(0.0,1.0)); + float4 color33 = texRECT(tex2, IN.texcoord2+float2(0.0,2.0)); + float4 color34 = texRECT(tex2, IN.texcoord2+float2(0.0,3.0)); + */ + + //OUT.Color0 = color2; + //tmp = color1 + color2.xxxx*color31 + color2.yyyy*color32 + color2.zzzz*color33 + color2.wwww*color34; + //OUT.Color0 = tmp; + + OUT.Color0.x = 1.0; + OUT.Color0.y = 2.0; + OUT.Color0.z = 3.0; + OUT.Color0.w = 4.0; + + return OUT; +} --- ./gnuradio_new/src/gpu/GrFIRfilterFFFnc2.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/GrFIRfilterFFFnc2.cg 2005-09-04 11:49:18.000000000 -0400 @@ -0,0 +1,141 @@ +/* -*-C-*- */ + +/* FIR filter shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2, + uniform float4 Params) { + frag_out OUT; + + float4 color1, color2, color3, color4, tmp; + float2 coord1, coord2, coord3, coord4; + float4x4 mat; + float x1, x2; + float i; + + float4 color0 = texRECT(tex0, IN.texcoord0); + + tmp=float4(0,0,0,0); + mat=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + + coord1=IN.texcoord1; + coord2=IN.texcoord2; + + color1=texRECT(tex1, coord1); + color2=texRECT(tex2, coord2); + + coord3=coord1+float2(1,0); + coord4=coord2+float2(1,0); + + x1=Params.x-floor(coord1.x); + x2=floor(coord1.x); + + for (i=1.0f; i=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + + // second sample + coord1.x=floor(IN.texcoord1.x)+Params.z+1; + coord1.y=floor(IN.texcoord1.y)+Params.w; + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color2=texRECT(tex1, coord1); + + if (xmod2>0) { + OUT.Color0.x = dot(ParamZ1, color1)+dot(ParamZ2, color2); + OUT.Color0.z = dot(ParamW1, color1)+dot(ParamW2, color2); + } else { + OUT.Color0.x = dot(ParamX1, color1)+dot(ParamX2, color2); + OUT.Color0.z = dot(ParamY1, color1)+dot(ParamY2, color2); + } + + // compute the imag component + for (float j=0; j=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + color2=texRECT(tex2, coord2); + + mat[0]=color2; + mat[1].yzw=color2.xyz; + mat[2].zw=color2.xy; + mat[3].w=color2.x; + + tmp=tmp+mul(mat, color1); + + mat[1].x=color2.w; + mat[2].xy=color2.zw; + mat[3].xyz=color2.yzw; + } + + coord1 = IN.texcoord1+float2(Params.x, j); + //coord1 = IN.texcoord1+float2(Params1.x, 0); + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + } + + color1=texRECT(tex1, coord1); + + mat[0]=float4(0,0,0,0); + mat[1].yzw=float3(0,0,0); + mat[2].zw=float2(0,0); + mat[3].w=0.0f; + + tmp=tmp+mul(mat, color1); + } + + if (xmod2>0) { + // odd + OUT.Color0.yw=tmp.zw; + } else { + // even + OUT.Color0.yw=tmp.xy; + } + + /* + coord1=IN.texcoord1; + color1=texRECT(tex1, coord1); + OUT.Color0=color1; + */ + + return OUT; +} --- ./gnuradio_new/src/gpu/GrFIRfilterFFFv2.cg 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/GrFIRfilterFFFv2.cg 2005-09-02 13:24:14.000000000 -0400 @@ -0,0 +1,105 @@ +/* -*-C-*- */ + +/* FIR filter shader */ + +struct vert_out { + float4 HPosition : POSITION; + float4 Color0 : COLOR0; + float2 texcoord0 : TEXCOORD0; + float2 texcoord1 : TEXCOORD1; + float2 texcoord2 : TEXCOORD2; +}; + +struct frag_out { + float4 Color0 : COLOR0; +}; + +frag_out main(vert_out IN, uniform samplerRECT tex0, uniform samplerRECT tex1, uniform samplerRECT tex2, uniform float4 Params) { + frag_out OUT; + + float4 color1, color2, color3, color4, tmp; + float2 coord1, coord2, coord3, coord4; + float4x4 mat1, mat2; + + float4 color0 = texRECT(tex0, IN.texcoord0); + + tmp=float4(0,0,0,0); + mat1=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + mat2=float4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + + for (float i=0; i=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + coord3.x -= Params.x; + coord3.y += 1; + } + + color1=texRECT(tex1, coord1); + color3=texRECT(tex1, coord1); + + mat1[0]=color2; + mat1[1].yzw=color2.xyz; + mat1[2].zw=color2.xy; + mat1[3].w=color2.x; + + tmp=tmp+mul(mat1, color1); + + mat1[1].x=color2.w; + mat1[2].xy=color2.zw; + mat1[3].xyz=color2.yzw; + + mat2[0]=color4; + mat2[1].yzw=color4.xyz; + mat2[2].zw=color4.xy; + mat2[3].w=color4.x; + + tmp=tmp+mul(mat2, color3); + + mat2[1].x=color4.w; + mat2[2].xy=color4.zw; + mat2[3].xyz=color4.yzw; + } + + coord1 = IN.texcoord1+float2(Params.x, 0); + coord3 = IN.texcoord1+float2(Params.x, 1); + + if (coord1.x>=Params.x) { + coord1.x -= Params.x; + coord1.y += 1; + coord3.x -= Params.x; + coord3.y += 1; + } + + color1=texRECT(tex1, coord1); + color3=texRECT(tex1, coord3); + + mat1[0]=float4(0,0,0,0); + mat1[1].yzw=float3(0,0,0); + mat1[2].zw=float2(0,0); + mat1[3].w=0.0f; + + tmp=tmp+mul(mat1, color1); + + mat2[0]=float4(0,0,0,0); + mat2[1].yzw=float3(0,0,0); + mat2[2].zw=float2(0,0); + mat2[3].w=0.0f; + + tmp=tmp+mul(mat2, color3); + + OUT.Color0=tmp+color0; + + return OUT; + +} --- ./gnuradio_new/src/gpu/gpu.h 1969-12-31 19:00:00.000000000 -0500 +++ ./gnuradio/src/gpu/gpu.h 2005-08-24 13:26:47.000000000 -0400 @@ -0,0 +1,36 @@ +#ifndef GPU_H_INCLUDED +#define GPU_H_INCLUDED + +#include +#include + +#include +#include + +#include +#include +#include +#include + +void display(); +void cleanExit(int code); +void init_gpu(); +void cgErrorCallback(void); +void create_texture(int size_x, int size_y, void *data, GLuint *hTexture); + +extern CGcontext context; +extern CGprofile vProfile, fProfile; +extern PBuffer *pbuf; +extern void (*current_display)(); +extern int gpu_size_x, gpu_size_y; +extern CGprogram *fProg; +extern int numProgs; + +struct nv_profile { + char *name; + CGprofile id; +}; + +extern struct nv_profile profiles[]; + +#endif --- ./gnuradio_new/src/pspectra/lib/vrp/VrHistoryProc.h 2005-10-24 10:12:12.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vrp/VrHistoryProc.h 2005-08-20 09:10:52.000000000 -0400 @@ -24,10 +24,12 @@ // to the maximum history that will ever be needed. template class VrHistoryProc : public VrSigProc { -protected: - unsigned int history; + //protected: public: + + unsigned int history; + VrHistoryProc(int outputs) : VrSigProc(outputs, sizeof(iType), sizeof(oType)), history(1) {} virtual int forecast(VrSampleRange output, VrSampleRange inputs[]); @@ -48,6 +50,10 @@ template unsigned int VrHistoryProc::mapSizeUp(int i, unsigned int size) { + + fprintf(stderr, "vrHistoryProc::mapSizeup\n"); + fflush(stderr); + return (unsigned int) (size * (getUpstreamModuleN(i)->getSamplingFrequency() /getSamplingFrequency())+history-1); --- ./gnuradio_new/src/pspectra/lib/vrp/VrQuadratureDemod.h 2005-10-24 10:12:12.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vrp/VrQuadratureDemod.h 2005-09-12 11:21:17.000000000 -0400 @@ -21,6 +21,16 @@ #include #include +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +#endif + + template class VrQuadratureDemod : public VrHistoryProc { protected: @@ -42,15 +52,46 @@ complex **i = (complex **)ai; oType **o = (oType **)ao; complex product,val; - complex lastVal = *i[0]++; + complex lastVal; unsigned int size=output.size; + complex *data, *data_new; + + data=i[0]; + +#ifdef USE_GPU + data_new=(complex*)get_gpu_output(); + if (data_new) { + data=data_new; + } +#endif + +#if 1 + lastVal= *data++; + + for (; size>0; data++,size--) { + val = *data; + product = val * conj(lastVal); + lastVal = val; + *o[0]++=(oType)(gain * arg(product)); + } +#endif + +#if 0 for (; size>0; i[0]++,size--) { val = *i[0]; product = val * conj(lastVal); lastVal = val; *o[0]++=(oType)(gain * arg(product)); } +#endif + +#ifdef USE_GPU + if (get_read_textures(0)) { + free(data_new); + } +#endif + return output.size; } --- ./gnuradio_new/src/pspectra/lib/vrp/VrDecimatingSigProc.h 2005-10-24 10:12:12.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vrp/VrDecimatingSigProc.h 2005-08-20 12:38:29.000000000 -0400 @@ -93,6 +93,10 @@ template unsigned int VrDecimatingSigProc::mapSizeUp(int i, unsigned int size) { + + fprintf(stderr, "VrDeciminatingsigproc::mapSizeUp size=%d history=%d decimation=%d\n", size, history, decimation); + fflush(stderr); + if(size==1) return history; else return size * decimation+history-1; } --- ./gnuradio_new/src/pspectra/lib/vr/VrSink.h 2005-10-24 10:12:12.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vr/VrSink.h 2005-08-19 08:55:43.000000000 -0400 @@ -81,6 +81,9 @@ //(every input and output stays in cache for entire length of chain) unsigned int cachedSize = (int) (cacheSize * (getSamplingFrequency() / m)); + fprintf(stderr, "getSF=%f m=%f\n", getSamplingFrequency(), m); + fflush(stderr); + fprintf(stderr,"%s cachedSize = %d\n",name(),cachedSize); if(cachedSize/getSamplingFrequency() > maxLatency) { fprintf(stderr," reducing latency from %f",cachedSize/getSamplingFrequency()); --- ./gnuradio_new/src/pspectra/lib/vr/VrSigProc.h 2005-10-24 10:12:13.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vr/VrSigProc.h 2005-09-14 05:45:07.000000000 -0400 @@ -40,6 +40,15 @@ #include #include +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +#endif + extern unsigned int cacheSize; extern float maxLatency; class VrBuffer; @@ -95,6 +104,7 @@ #endif /*** Input Connectors ***/ VrConnect ** inputConn; + VrSigProc **inputSigProc; unsigned int setupCalled; unsigned int outputSize; unsigned int type_size; @@ -171,6 +181,7 @@ bool *dataMarkedUpstream); //!compute the marked data virtual bool compute(); + protected: @@ -185,7 +196,7 @@ double getInputSamplingFrequencyN(port p); //! set required multiple for number of items produced - void setOutputSize(int o) { outputSize=o; } + void setOutputSize(int o) { outputSize=o; fprintf(stderr, "setOutputSize %d name=%s\n", outputSize, name()); fflush(stderr); } unsigned int getOutputSize() {return outputSize;} void setup_upstream(); @@ -203,11 +214,31 @@ void sync (VrSampleIndex arg_index); VrSampleIndex proc_minRP(); + +#ifdef USE_GPU + virtual void create_textures(); + virtual void delete_textures(); + + int get_k(int ind); + int get_texture_width(int ind); + int get_texture_height(int ind); + int get_read_textures(int ind); + GLuint get_texture_out(int ind); + void *get_gpu_output(); + +#endif + public: VrSigProc(int number_of_outputs, unsigned int arg_itype_size, unsigned int arg_type_size); virtual ~VrSigProc(); +#ifdef USE_GPU + GLuint hTextureIn, hTextureTaps, hTextureOut; + int read_textures; /* use textures for input */ + int gpu_width, gpu_height, gpu_k; +#endif + //! connect our next input to \p proc's nth output bool connect_proc(VrSigProc* proc, port n); --- ./gnuradio_new/src/pspectra/lib/vrio/VrFileSink.h 2005-10-24 10:12:13.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vrio/VrFileSink.h 2005-09-13 12:35:52.000000000 -0400 @@ -53,6 +53,15 @@ #define OUR_O_LARGEFILE 0 #endif +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +#endif + //VrFileSink appends raw data to a file. // default filename is "tmp" @@ -103,15 +112,26 @@ VrSampleRange inputs[], void *ai[]) { iType **i = (iType **)ai; + iType *data, *data_new; sync (output.index); int count = 0; - count = fwrite(i[0],sizeof(iType),output.size,fp); + data=i[0]; + +#ifdef USE_GPU + data_new=(iType*)get_gpu_output(); + + if (data_new) { + data=data_new; + } +#endif + + count = fwrite(data, sizeof(iType),output.size,fp); while ((count < 0) && (errno == EAGAIN)) { YIELD(); - count = fwrite(i[0],sizeof(iType),output.size,fp); + count = fwrite(data, sizeof(iType),output.size,fp); } if(count<0) { @@ -122,6 +142,13 @@ fprintf(stderr, "VrConnect.fileWrite(): warning: not all bytes written\n"); } + +#ifdef USE_GPU + if (get_read_textures(0)) { + free(data_new); + } +#endif + return count; } --- ./gnuradio_new/src/pspectra/lib/vrio/VrSigSource.h 2005-10-24 10:12:13.000000000 -0400 +++ ./gnuradio/src/pspectra/lib/vrio/VrSigSource.h 2005-08-20 13:22:04.000000000 -0400 @@ -195,6 +195,10 @@ { oType **o = (oType **)ao; unsigned int size = output.size; + + fprintf(stderr, "VrSigSource size=%d\n", size); + fflush(stderr); + while (size > 0) { memcpy((char *)(o[0]),(char *)buffer,getOutputSize()*sizeof(oType)); size -= getOutputSize(); diff -Pru ./gr1/src/gnu/examples/gpu.cc ./gr2/src/gnu/examples/gpu.cc --- ./gr1/src/gnu/examples/gpu.cc 1969-12-31 19:00:00.000000000 -0500 +++ ./gr2/src/gnu/examples/gpu.cc 2005-10-24 15:08:37.000000000 -0400 @@ -0,0 +1,332 @@ + +#define GLH_EXT_SINGLE_FILE +#define GLH_NVEB_USING_CGGL + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +using namespace glh; +using namespace nv_dds; + + +void display(); +void cleanExit(int code); +void init_gpu(); +void cgErrorCallback(void); + +extern CGcontext context; +extern CGprofile vProfile, fProfile; +extern PBuffer *pbuf; +extern void (*current_display)(); +extern int gpu_size_x, gpu_size_y; +extern CGprogram *fProg; +extern int numProgs; + +struct nv_profile { + char *name; + CGprofile id; +}; + +extern struct nv_profile profiles[]; + +CGcontext context; +CGprofile vProfile, fProfile; +//glut_simple_mouse_interactor object; +PBuffer *pbuf; +void (*current_display)(); +int gpu_size_x, gpu_size_y; +CGprogram *fProg; +int numProgs; + +struct nv_profile profiles[] = { + {"NV_vertex_program 1.0", CG_PROFILE_VP20}, + {"NV_texture_sharder and NV_register_combiners", CG_PROFILE_FP20}, + {"NV_vertex_program 2.0", CG_PROFILE_VP30}, + {"NV_fragment program", CG_PROFILE_FP30}, + {"ARB Vertex program", CG_PROFILE_ARBVP1}, + {"ARB Fragment program", CG_PROFILE_ARBFP1}, + {"vp40", CG_PROFILE_VP40}, + {"fp40", CG_PROFILE_FP40}, +}; + +void display() { + + if (current_display==NULL) { + fprintf(stderr, "current_display is NULL\n"); + fflush(stderr); + + exit(0); + return; + } + +#if 0 + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + fprintf(stderr, "gpu.cc:display\n"); + fflush(stderr); +#endif + + current_display(); + +} + +void draw_rect(int k_cur) { + + glNormal3f(0.0, 0.0, 1.0); + + glBegin(GL_QUADS); + + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(-1, -1, 0.0); + + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(-1, 1, 0.0); + + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(1, 1, 0.0); + + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(1, -1, 0.0); + + glEnd(); +} + + +void cgErrorCallback(void) { + CGerror LastError = cgGetError(); + + if(LastError) { + const char *Listing = cgGetLastListing(context); + printf("\n---------------------------------------------------\n"); + printf("%s\n\n", cgGetErrorString(LastError)); + printf("%s\n", Listing); + printf("---------------------------------------------------\n"); + printf("Cg error, exiting...\n"); + cleanExit(0); + } +} + +void cleanExit(int code) { + int i; + + cgGLDisableProfile(fProfile); + pbuf->Deactivate(); + + for (i=0; iInitialize(gpu_size_x, gpu_size_y, false, true); + + /* this should be called every time before pbuf is used */ + pbuf->Activate(); + + glEnable(GL_TEXTURE_RECTANGLE_NV); + cgGLEnableProfile(fProfile); + + pbuf->Deactivate(); +} + +void create_texture(int size_x, int size_y, void *data, GLuint *hTexture) { + + glGenTextures(1, hTexture); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, *hTexture); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + size_x, + size_y, + 0, + GL_RGBA, + GL_FLOAT, + data); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + +} + +/**********************************************************************/ + +#if 0 + /* create dest texture */ + glGenTextures(1, &hTextureDest); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureDest); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + 10, + 10, + 0, + GL_RGBA, + GL_FLOAT, + NULL); +#endif + +#if 0 +void display() { + int k_cur; + + printf("display is called\n"); + + pbuf->Activate(); + + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glEnable(GL_TEXTURE_RECTANGLE_NV); + cgGLEnableProfile(fProfile); + + cgGLBindProgram(fProg[0]); + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureDest); + + draw_rect(k_cur); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureDest); + + /* copy results from framebuffer into texture 0 */ + glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, 10, 10); + + /* + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureDest); + */ + + glGetTexImage(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, GL_FLOAT, pixel_data); + + pbuf->Deactivate(); + cgGLDisableProfile(fProfile); + + FILE *fp_out; + int i,j; + + fp_out = fopen("m3_gpu", "w"); + if (!fp_out) { + printf("cannot open fp_out\n"); + exit(0); + } + + for (i=0; i<10; i++) { + for (j=0; j<10; j++) { + fprintf(fp_out, "%f ", pixel_data[i*m+j]); + } + fprintf(fp_out,"\n"); + } + fprintf(fp_out,"\n\n"); + + fclose(fp_out); +} +#endif diff -Pru ./gr1/src/gnu/examples/Makefile.in ./gr2/src/gnu/examples/Makefile.in --- ./gr1/src/gnu/examples/Makefile.in 2005-10-24 14:53:07.000000000 -0400 +++ ./gr2/src/gnu/examples/Makefile.in 2005-10-25 07:11:25.000000000 -0400 @@ -35,6 +35,10 @@ # Boston, MA 02111-1307, USA. # +NVSDK=/home/alexey/NVSDK +NVSDK_DEMOS=$(NVSDK)/DEMOS/OpenGL + + SOURCES = $(adc3_fft_SOURCES) $(adc3_fftavg_SOURCES) $(adc_fft_SOURCES) $(adc_file_SOURCES) $(adc_scope_SOURCES) $(audio_scope_SOURCES) $(benchmark_dotprod_SOURCES) $(benchmark_dotprod_FCC_SOURCES) $(benchmark_dotprod_SCC_SOURCES) $(chirp_fft_SOURCES) $(chirp_file_SOURCES) $(complex_audio_fft_SOURCES) $(dump_circfile_SOURCES) $(elenco_fm_demo_SOURCES) $(elenco_fm_demo_no_gui_SOURCES) $(fastchan_demo_SOURCES) $(fm_demod1_SOURCES) $(fm_demod1_tng_SOURCES) $(fm_demod2_SOURCES) $(fm_demod2_no_gui_SOURCES) $(fm_demod2_no_gui_no_fixoffset_SOURCES) $(full_duplex_audio_demo_SOURCES) $(givelp1_SOURCES) $(hifi_fm_SOURCES) $(microtune_SOURCES) $(microtune_fm_demo_SOURCES) $(mixer_SOURCES) $(mono_audio_out_SOURCES) $(nbfm_SOURCES) $(raw_fm_to_file_SOURCES) $(set_agc_SOURCES) $(simple_fft_SOURCES) $(simple_scope_SOURCES) $(stereo_audio_out_SOURCES) $(sweep_agc_SOURCES) $(test_filecopy_SOURCES) $(test_microtune_SOURCES) $(tester_SOURCES) $(wiggle_pp_SOURCES) srcdir = @srcdir@ @@ -157,6 +161,11 @@ elenco_fm_demo_no_gui_OBJECTS = $(am_elenco_fm_demo_no_gui_OBJECTS) elenco_fm_demo_no_gui_DEPENDENCIES = \ $(top_builddir)/src/gnu/lib/libgnuradio.la + +test1_OBJECTS = test1.$(OBJEXT) gpu.$(OBJEXT) +test1_DEPENDENCIES = \ + $(top_builddir)/src/gnu/lib/libgnuradio.la + am_fastchan_demo_OBJECTS = fastchan_demo.$(OBJEXT) fastchan_demo_OBJECTS = $(am_fastchan_demo_OBJECTS) fastchan_demo_DEPENDENCIES = \ @@ -323,7 +332,7 @@ CXX_FOR_BUILD = @CXX_FOR_BUILD@ CYGPATH_W = @CYGPATH_W@ DEFINES = @DEFINES@ -DEFS = @DEFS@ +DEFS = @DEFS@ -DUSE_GPU -DUNIX DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_FALSE = @DOC_FALSE@ @@ -356,7 +365,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IPC_LIBS = @IPC_LIBS@ -LDFLAGS = @LDFLAGS@ +LDFLAGS = @LDFLAGS@ -L$(NVSDK_DEMOS)/src/shared -lnvsdk -lCgGL -lCg -lglut -lGLU -lGL -lpthread LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ @@ -476,7 +485,7 @@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ -INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(QT_CXXFLAGS) +INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(QT_CXXFLAGS) -I$(NVSDK_DEMOS)/inc -I$(NVSDK)/inc -I../../gpu TESTS = EXTRA_DIST = \ benchmark_results @@ -523,6 +532,10 @@ elenco_fm_demo_LDADD = $(top_builddir)/src/gnu/lib/libgnuradio.la elenco_fm_demo_no_gui_SOURCES = elenco_fm_demo_no_gui.cc elenco_fm_demo_no_gui_LDADD = $(top_builddir)/src/gnu/lib/libgnuradio.la + +test1_SOURCES = test1.cc gpu.cc +test1_LDADD = $(top_builddir)/src/gnu/lib/libgnuradio.la -L$(NVSDK_DEMOS)/src/shared -lnvsdk -lCgGL -lCg -lglut -lGLU -lGL -lpthread + fastchan_demo_SOURCES = fastchan_demo.cc fastchan_demo_LDADD = $(top_builddir)/src/gnu/lib/libgnuradio.la full_duplex_audio_demo_SOURCES = full_duplex_audio_demo.cc @@ -733,6 +746,10 @@ @rm -f wiggle_pp$(EXEEXT) $(CXXLINK) $(wiggle_pp_LDFLAGS) $(wiggle_pp_OBJECTS) $(wiggle_pp_LDADD) $(LIBS) +test1$(EXEEXT): $(test1_OBJECTS) $(test1_DEPENDENCIES) + @rm -f test1$(EXEEXT) + $(CXXLINK) $(test1_LDFLAGS) $(test1_OBJECTS) $(test1_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) diff -Pru ./gr1/src/gnu/examples/test1.cc ./gr2/src/gnu/examples/test1.cc --- ./gr1/src/gnu/examples/test1.cc 1969-12-31 19:00:00.000000000 -0500 +++ ./gr2/src/gnu/examples/test1.cc 2005-10-24 15:07:40.000000000 -0400 @@ -0,0 +1,194 @@ +/* + My test 1 + Generating a sine wave and modulating it. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const int SAMPLING_FREQ = 500; +const float FREQ_OFFSET = 0.5; +const int numIter = 5; + +int main() { + int i; + float width_of_band; + + //VrSigSource *source0 = new VrSigSource(SAMPLING_FREQ, VR_SIN_WAVE, 1000, 8192); + VrSigSource *source0 = new VrSigSource(SAMPLING_FREQ, VR_SIN_WAVE, 10, 8192); + GrHilbert *hilbert1 = new GrHilbert(31); + GrHilbert *hilbert2 = new GrHilbert(31); + + /* modulation */ + GrSSBMod *mod = new GrSSBMod(2*M_PI*FREQ_OFFSET/SAMPLING_FREQ, 1); + + width_of_band=1.18f; + /* + vector channel_coeffs = gr_firdes::low_pass(1.0, + 25000, + SAMPLING_FREQ, + 300, + gr_firdes::WIN_HAMMING); + + */ + + /* insert channel filter here */ + vector channel_coeffs = gr_firdes::low_pass(1.0, + 25000, + SAMPLING_FREQ, + width_of_band, + gr_firdes::WIN_HAMMING); + + GrFreqXlatingFIRfilterFCF *chan_filter = new GrFreqXlatingFIRfilterFCF(1, channel_coeffs, 15); + + GrReal *conv_real = new GrReal(); + + /* demodulation */ + VrQuadratureDemod *demod = new VrQuadratureDemod(1.0f); + + /* filter */ + vector audio_coeffs1 = + gr_firdes::low_pass (1.0, // gain + 25000, // sampling rate + 150/2 - width_of_band, // low-pass cutoff freq + width_of_band, + gr_firdes::WIN_HAMMING); + + vector audio_coeffs2 = + gr_firdes::low_pass (1.0, // gain + 25000, // sampling rate + 150/2 - width_of_band, // low-pass cutoff freq + width_of_band, + gr_firdes::WIN_HAMMING); + +#if 0 + /* filter */ + width_of_band=100; + + vector audio_coeffs = + gr_firdes::low_pass (1.0, + 2500000, + 400/2 - width_of_band, + width_of_band, + gr_firdes::WIN_HAMMING); +#endif + + cerr << "Number of audio_coeffs1: " << audio_coeffs1.size () << endl; + cerr << "Number of audio_coeffs2: " << audio_coeffs2.size () << endl; + + GrFIRfilterFFF *audio_filter1 = new GrFIRfilterFFF(1, audio_coeffs1); + GrFIRfilterFFF *audio_filter2 = new GrFIRfilterFFF(1, audio_coeffs2); + + //VrSink *file_sink = new VrFileSink("signal.dat"); + //VrSink *file_sink = new VrFileSink("test1.out"); + + VrFileSource *file_source = new VrFileSource(SAMPLING_FREQ, "signal.dat"); + VrSink *file_sink1 = new VrFileSink("test1.out"); + + /* performance tests */ + +#if 0 + /* performance of a FIR filter */ + NWO_CONNECT(source0, audio_filter1); + NWO_CONNECT(audio_filter1, audio_filter2); + NWO_CONNECT(audio_filter2, file_sink); +#endif + +#if 0 + /* performance of a FreqXlating FIR filter */ + NWO_CONNECT(source0, chan_filter); + NWO_CONNECT(chan_filter, conv_real); + NWO_CONNECT(conv_real, audio_filter1); + NWO_CONNECT(audio_filter1, file_sink); +#endif + +#if 0 + /* performance of Hilbert transformation */ + NWO_CONNECT(source0, hilbert1); + NWO_CONNECT(hilbert1, conv_real); + NWO_CONNECT(conv_real, audio_filter1); + NWO_CONNECT(audio_filter1, file_sink); +#endif + +#if 0 + /* FIR filter */ + NWO_CONNECT(source0, audio_filter1); + NWO_CONNECT(audio_filter1, file_sink); +#endif + +#if 0 + /* Hilbert transform */ + NWO_CONNECT(source0, hilbert1); + NWO_CONNECT(hilbert1, file_sink); +#endif + +#if 0 + /* FreqXlating FIR filter */ + NWO_CONNECT(source0, chan_filter); + NWO_CONNECT(chan_filter, file_sink); +#endif + +#if 0 + NWO_CONNECT(source0, hilbert1); + NWO_CONNECT(hilbert1, mod); + + //NWO_CONNECT(mod, file_sink); + + NWO_CONNECT(mod, chan_filter); + NWO_CONNECT(chan_filter, conv_real); + //NWO_CONNECT(chan_filter, file_sink); + NWO_CONNECT(conv_real, hilbert2); + NWO_CONNECT(hilbert2, demod); + //NWO_CONNECT(demod, file_sink); + + NWO_CONNECT(demod, audio_filter); + NWO_CONNECT(audio_filter, file_sink); + +#endif + +#if 0 + /* generate source signal */ + NWO_CONNECT(source0, file_sink); + NWO_CONNECT(source0, hilbert1); + NWO_CONNECT(hilbert1, mod); + NWO_CONNECT(mod, file_sink); +#endif + +#if 1 + /* read signal from file and demodulate it */ + + NWO_CONNECT(file_source, chan_filter); + NWO_CONNECT(chan_filter, conv_real); + NWO_CONNECT(conv_real, hilbert2); + NWO_CONNECT(hilbert2, demod); + //NWO_CONNECT(demod, file_sink1); + + NWO_CONNECT(demod, audio_filter1); + NWO_CONNECT(audio_filter1, file_sink1); +#endif + + VrMultiTask *m = new VrMultiTask(); + m->add(file_sink1); + m->start(); + + for (i=0; iprocess(); + } + + return 0; +} + diff -Pru ./gr1/src/gnu/lib/gr/Makefile.in ./gr2/src/gnu/lib/gr/Makefile.in --- ./gr1/src/gnu/lib/gr/Makefile.in 2005-10-24 14:50:06.000000000 -0400 +++ ./gr2/src/gnu/lib/gr/Makefile.in 2005-10-24 15:00:51.000000000 -0400 @@ -14,6 +14,9 @@ @SET_MAKE@ +NVSDK=/home/alexey/NVSDK +NVSDK_DEMOS=$(NVSDK)/DEMOS/OpenGL + SOURCES = $(libgr_la_SOURCES) $(EXTRA_libgr_la_SOURCES) @@ -198,7 +201,7 @@ CXX_FOR_BUILD = @CXX_FOR_BUILD@ CYGPATH_W = @CYGPATH_W@ DEFINES = @DEFINES@ -DEFS = @DEFS@ +DEFS = @DEFS@ -DUSE_GPU -DUNIX DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_FALSE = @DOC_FALSE@ @@ -231,7 +234,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IPC_LIBS = @IPC_LIBS@ -LDFLAGS = @LDFLAGS@ +LDFLAGS = @LDFLAGS@ -L$(NVSDK_DEMOS)/src/shared -lnvsdk -lCgGL -lCg -lglut -lGLU -lGL -lpthread LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ @@ -372,7 +375,7 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # -INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) +INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) -I$(NVSDK_DEMOS)/inc -I$(NVSDK)/inc -I../../../gpu noinst_LTLIBRARIES = libgr.la # ---------------------------------------------------------------- diff -Pru ./gr1/src/gnu/lib/grbase/Makefile.in ./gr2/src/gnu/lib/grbase/Makefile.in --- ./gr1/src/gnu/lib/grbase/Makefile.in 2005-10-24 14:50:15.000000000 -0400 +++ ./gr2/src/gnu/lib/grbase/Makefile.in 2005-10-24 15:01:49.000000000 -0400 @@ -36,6 +36,10 @@ # +NVSDK=/home/alexey/NVSDK +NVSDK_DEMOS=$(NVSDK)/DEMOS/OpenGL + + SOURCES = $(libgrbase_la_SOURCES) srcdir = @srcdir@ @@ -147,7 +151,7 @@ CXX_FOR_BUILD = @CXX_FOR_BUILD@ CYGPATH_W = @CYGPATH_W@ DEFINES = @DEFINES@ -DEFS = @DEFS@ +DEFS = @DEFS@ -DUSE_GPU DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_FALSE = @DOC_FALSE@ @@ -300,7 +304,7 @@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ -INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) +INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) -I$(NVSDK_DEMOS)/inc -I$(NVSDK)/inc -I../../../gpu noinst_LTLIBRARIES = libgrbase.la libgrbase_la_LIBADD = \ $(SHM_OPEN_LIBS) diff -Pru ./gr1/src/pspectra/lib/vr/Makefile.in ./gr2/src/pspectra/lib/vr/Makefile.in --- ./gr1/src/pspectra/lib/vr/Makefile.in 2005-10-24 14:49:18.000000000 -0400 +++ ./gr2/src/pspectra/lib/vr/Makefile.in 2005-10-24 14:57:47.000000000 -0400 @@ -17,6 +17,9 @@ SOURCES = $(libvr_la_SOURCES) +NVSDK=/home/alexey/NVSDK +NVSDK_DEMOS=$(NVSDK)/DEMOS/OpenGL + srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -124,7 +127,7 @@ CXX_FOR_BUILD = @CXX_FOR_BUILD@ CYGPATH_W = @CYGPATH_W@ DEFINES = @DEFINES@ -DEFS = @DEFS@ +DEFS = @DEFS@ -DUSE_GPU -DUNIX DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_FALSE = @DOC_FALSE@ @@ -157,7 +160,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IPC_LIBS = @IPC_LIBS@ -LDFLAGS = @LDFLAGS@ +LDFLAGS = @LDFLAGS@ -L$(NVSDK_DEMOS)/src/shared -lnvsdk -lCgGL -lCg -lglut -lGLU -lGL -lpthread LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ @@ -298,7 +301,7 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # -INCLUDES = $(STD_DEFINES_AND_INCLUDES) +INCLUDES = $(STD_DEFINES_AND_INCLUDES) -I$(NVSDK_DEMOS)/inc -I$(NVSDK)/inc -I../../../gpu EXTRA_DIST = atomic.s.old noinst_LTLIBRARIES = libvr.la libvr_la_SOURCES = \ --- ./gnuradio_new/src/gnu/lib/gr/GrFIRfilterXXX_h.t 2005-10-24 10:12:22.000000000 -0400 +++ ./gnuradio/src/gnu/lib/gr/GrFIRfilterXXX_h.t 2005-10-24 09:50:54.000000000 -0400 @@ -31,6 +31,25 @@ #include #include <@FIR_BUILDER@.h> +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +#define GrFIRfilterFFF_prog 2 +/* these programs do not exist yet */ +#define GrFIRfilterCCF_prog 100 +#define GrFIRfilterFCC_prog 101 +#define GrFIRfilterCCC_prog 102 +#define GrFIRfilterSCC_prog 103 +#define GrFIRfilterSIS_prog 104 +#define GrFIRfilterFSF_prog 105 + +#endif + + class @FIR_TYPE@; /*! @@ -62,11 +81,12 @@ void setTaps (const std::vector<@TAP_TYPE@> &taps); - protected: +protected: @FIR_BUILDER@ *d_builder; @FIR_TYPE@ *d_fir; std::vector<@TAP_TYPE@> d_new_taps; int d_updated; + }; #endif // _@NAME@_H_ --- ./gnuradio_new/src/gnu/lib/gr/GrFreqXlatingFIRfilterXXX_h.t 2005-10-24 10:12:22.000000000 -0400 +++ ./gnuradio/src/gnu/lib/gr/GrFreqXlatingFIRfilterXXX_h.t 2005-09-11 16:08:10.000000000 -0400 @@ -35,6 +35,24 @@ #include #include +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +#define GrFXFIRfilterFCF_prog 3 + +/* these programs have not been implemented yet */ +#define GrFXFIRfilterSCF_prog 200 +#define GrFXFIRfilterSCC_prog 201 +#define GrFXFIRfilterFCC_prog 202 +#define GrFXFIRfilterCCF_prog 203 +#define GrFXFIRfilterCCC_prog 204 + +#endif + class @FIR_TYPE@; /*! @@ -93,7 +111,11 @@ float d_center_freq; int d_updated; + std::vector ctaps; + float phase_incr; + virtual void build_composite_fir (); + }; #endif /* _@NAME@_H_ */ --- ./gnuradio_new/src/gnu/lib/gr/GrFreqXlatingFIRfilterXXX_cc.t 2005-10-24 10:12:25.000000000 -0400 +++ ./gnuradio/src/gnu/lib/gr/GrFreqXlatingFIRfilterXXX_cc.t 2005-09-14 09:12:15.000000000 -0400 @@ -30,6 +30,40 @@ #include #include <@FIR_TYPE@.h> +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +CGparameter @SHORTNAME@_Params; +GLuint @SHORTNAME@_hTextureIn, @SHORTNAME@_hTextureTaps, @SHORTNAME@_hTextureOut; +int @SHORTNAME@_m, @SHORTNAME@_n, @SHORTNAME@_k; +float @SHORTNAME@_phase_incr; +int @SHORTNAME@_phase_start; +float @SHORTNAME@_sampling_freq; +int @SHORTNAME@_num_taps; +VrComplex *@SHORTNAME@_out; + +#endif + +#define rdtsc() \ + ({ \ + union { \ + struct { \ + unsigned l, h; \ + } p; \ + unsigned long long f; \ + } t; \ + asm volatile ("rdtsc" : "=a" (t.p.l), "=d" (t.p.h)); \ + t.f; \ + }) + +#undef MEASURE_TIME +//#define MEASURE_TIME + + @NAME@::@NAME@ ( int decimation_factor, @@ -77,7 +111,7 @@ void @NAME@::build_composite_fir () { - std::vector ctaps (d_proto_taps.size ()); + ctaps.resize(d_proto_taps.size ()); float fwT0 = 2 * M_PI * d_center_freq / getInputSamplingFrequencyN (0); for (unsigned int i = 0; i < d_proto_taps.size (); i++) @@ -85,6 +119,13 @@ d_composite_fir->set_taps (ctaps); d_r.set_phase_incr (exp (VrComplex (0, fwT0 * decimation))); + + phase_incr=(float)d_center_freq / getInputSamplingFrequencyN (0) * decimation; + +#ifdef USE_GPU + @SHORTNAME@_phase_start=1; + @SHORTNAME@_sampling_freq=getInputSamplingFrequencyN(0); +#endif } void @@ -103,13 +144,354 @@ d_updated = 1; } +//#ifdef USE_GPU +#if 0 + +void @SHORTNAME@_display() { + int k_cur; + + fprintf(stderr, "@SHORTNAME@_display()\n"); + fflush(stderr); + + pbuf->Activate(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glViewport(0, 0, @SHORTNAME@_k/2, @SHORTNAME@_n-@SHORTNAME@_m); + + /* clear texture hTextureOut */ + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @SHORTNAME@_hTextureOut); + glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, @SHORTNAME@_k/2, (@SHORTNAME@_n-@SHORTNAME@_m)); + + /* set parameters*/ + @SHORTNAME@_Params = cgGetNamedParameter(fProg[@SHORTNAME@_prog], "Params"); + cgGLSetParameter4f(@SHORTNAME@_Params, @SHORTNAME@_k/4-0.001f, @SHORTNAME@_phase_incr, (float)@SHORTNAME@_phase_start, @SHORTNAME@_sampling_freq); + + /* input matrix */ + glActiveTextureARB(GL_TEXTURE1_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @SHORTNAME@_hTextureIn); + + /* taps matrix */ + glActiveTextureARB(GL_TEXTURE2_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @SHORTNAME@_hTextureTaps); + + glActiveTextureARB(GL_TEXTURE0_ARB); + + /* enable programs */ + cgGLBindProgram(fProg[@SHORTNAME@_prog]); + cgGLEnableProfile(fProfile); + + for (k_cur=0; k_cur<@SHORTNAME@_m; k_cur++) { + //for (k_cur=0; k_cur<2; k_cur++) { + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @SHORTNAME@_hTextureOut); + + glNormal3f(0.0, 0.0, 1.0); + + glBegin(GL_QUADS); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, k_cur); + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(-1, -1, 0.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, (@SHORTNAME@_n-@SHORTNAME@_m)); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, k_cur+(@SHORTNAME@_n-@SHORTNAME@_m)); + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(-1, 1, 0.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, @SHORTNAME@_k/2, (@SHORTNAME@_n-@SHORTNAME@_m)); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, @SHORTNAME@_k/4, k_cur+(@SHORTNAME@_n-@SHORTNAME@_m)); + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(1, 1, 0.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, @SHORTNAME@_k/2, 0.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, @SHORTNAME@_k/4, k_cur); + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(1, -1, 0.0); + + glEnd(); + + /* copy results from framebuffer into texture 0 */ + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @SHORTNAME@_hTextureOut); + glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, @SHORTNAME@_k/2, (@SHORTNAME@_n-@SHORTNAME@_m)); + } + + pbuf->Deactivate(); +} + +int +@NAME@::work (VrSampleRange output, void *ao[], + VrSampleRange inputs[], void *ai[]) { + + int i; + +#ifdef MEASURE_TIME + unsigned long long t1, t2; +#endif + + @I_TYPE@ *in_data=NULL; + @TAP_TYPE@ *taps_data; + + fprintf(stderr, "GPU verion of @SHORTNAME@::work input size=%d output size=%d taps=%d freq=%f\n", inputs[0].size, output.size, ctaps.size(), (float)getInputSamplingFrequencyN (0)); + fflush(stderr); + + @SHORTNAME@_out=NULL; + @SHORTNAME@_num_taps=ctaps.size(); + + if (hTextureIn==0) { + create_textures(); + } + + /* determine texture sizes */ + if (get_read_textures(0)) { + @SHORTNAME@_k = get_k(0); + + } else { + @SHORTNAME@_k = (int)sqrt((float)ctaps.size())*4; + while (@SHORTNAME@_k%4) @SHORTNAME@_k++; + } + + @SHORTNAME@_m = (int)(ctaps.size()/@SHORTNAME@_k)+1; + if ((@SHORTNAME@_m-1)*@SHORTNAME@_k >= (int)ctaps.size()) { + @SHORTNAME@_m--; + } + + @SHORTNAME@_n=(int)(output.size/@SHORTNAME@_k)+1; + if ((@SHORTNAME@_n-1)*@SHORTNAME@_k >= (int)output.size) { + @SHORTNAME@_n--; + } + + @SHORTNAME@_n+=@SHORTNAME@_m; + + fprintf(stderr, "m=%d n=%d k=%d\n", @SHORTNAME@_m, @SHORTNAME@_n, @SHORTNAME@_k); + fflush(stderr); + + gpu_width=@SHORTNAME@_k/2; + gpu_height=@SHORTNAME@_n-@SHORTNAME@_m; + gpu_k=@SHORTNAME@_k; + read_textures=1; /* next block should read this block's output texture */ + + if (get_read_textures(0)) { + @SHORTNAME@_hTextureIn = get_texture_out(0); + + } else { + /* create input texture */ + + in_data = (@I_TYPE@*)malloc(@SHORTNAME@_n*@SHORTNAME@_k*sizeof(@I_TYPE@)); + memset(in_data, 0, sizeof(@I_TYPE@)*@SHORTNAME@_n*@SHORTNAME@_k); + memcpy(in_data, (@I_TYPE@*)ai[0], sizeof(@I_TYPE@)*inputs[0].size); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureIn); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + @SHORTNAME@_k/4, + @SHORTNAME@_n, + 0, + GL_RGBA, + GL_FLOAT, + in_data); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + @SHORTNAME@_hTextureIn = hTextureIn; + } + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureOut); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + 700, + 200, + 0, + GL_RGBA, + GL_FLOAT, + NULL); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + @SHORTNAME@_hTextureTaps = hTextureTaps; + @SHORTNAME@_hTextureOut = hTextureOut; + + /* create taps texture */ + taps_data = (@TAP_TYPE@*)malloc(@SHORTNAME@_m*@SHORTNAME@_k*2*sizeof(@TAP_TYPE@)); + memset(taps_data, 0, sizeof(@TAP_TYPE@)*@SHORTNAME@_m*@SHORTNAME@_k*2); + + for (i=0; i<(int)ctaps.size(); i++) { + taps_data[i*2]=ctaps[i].real(); + taps_data[i*2+1]=ctaps[i].imag(); + } + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureTaps); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + @SHORTNAME@_k/2, + @SHORTNAME@_m, + 0, + GL_RGBA, + GL_FLOAT, + taps_data); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + +#if 0 + /* compute FIR filter here */ + + int j, k, l, x, y; + + @SHORTNAME@_out = (@O_TYPE@*)malloc(sizeof(@O_TYPE@)*@SHORTNAME@_k*(@SHORTNAME@_n-@SHORTNAME@_m)); + memset(@SHORTNAME@_out, 0, sizeof(@O_TYPE@)*@SHORTNAME@_k*(@SHORTNAME@_n-@SHORTNAME@_m)); + + fprintf(stderr, "CPU computation of FreqXlatingFIRfilter\n"); + fflush(stderr); + + for (k=0; k<@SHORTNAME@_m; k++) { + for (l=0; l<(@SHORTNAME@_n-@SHORTNAME@_m); l++) { + for (i=0; i<@SHORTNAME@_k; i++) { + for (j=0; j<@SHORTNAME@_k; j++) { + + x=i+j; + y=l+k; + + if (x>=@SHORTNAME@_k) { + x-=@SHORTNAME@_k; + y+=1; + } + + tmpval=@SHORTNAME@_out[l*@SHORTNAME@_k+i].real(); + VrComplex tmpt1(taps_data[(j+k*@SHORTNAME@_k)*2]); + VrComplex tmpc1(tmpval+tmpt1.real() * in_data[x+y*@SHORTNAME@_k]); + + @SHORTNAME@_out[l*@SHORTNAME@_k+i].real(tmpc1.real()); + + tmpval=@SHORTNAME@_out[l*@SHORTNAME@_k+i].imag(); + VrComplex tmpt2(taps_data[(j+k*@SHORTNAME@_k)*2+1]); + VrComplex tmpc2(tmpval+tmpt2.real()*in_data[x+y*@SHORTNAME@_k]); + + @SHORTNAME@_out[l*@SHORTNAME@_k+i].imag(tmpc2.real()); + } + } + } + } + + for (i=0; i10.0f) { + fprintf(stderr, "ERR: %f\n", tmpval); + fflush(stderr); + } + */ + + //fprintf(stderr, "(%f, %f) ", @SHORTNAME@_out[i].real()-out_ptr[i].real(), @SHORTNAME@_out[i].imag()-out_ptr[i].imag()); + fprintf(stderr, "(%f, %f) ", @SHORTNAME@_out[i].real(), @SHORTNAME@_out[i].imag()); + + err+=tmpval; + } + + fprintf(stderr, "\n"); + fflush(stdout); + + /* + fprintf(stderr, "error=%f\n", err); + fflush(stderr); + */ +#endif + + if (in_data) { + free(in_data); + } + + free(taps_data); + + if (@SHORTNAME@_out) { + free(@SHORTNAME@_out); + } + + @SHORTNAME@_phase_start+=output.size; + @SHORTNAME@_phase_start%=(int)(getInputSamplingFrequencyN(0)+0.5f); + + return output.size; +} + +#else + int @NAME@::work (VrSampleRange output, void *ao[], VrSampleRange inputs[], void *ai[]) { + unsigned i; + +#ifdef MEASURE_TIME + unsigned long long t1, t2; +#endif + @I_TYPE@ *in = (@I_TYPE@ *) ai[0]; @O_TYPE@ *out = (@O_TYPE@ *) ao[0]; + fprintf(stderr, "CPU verion of @SHORTNAME@::work input size=%d output size=%d taps=%d\n", inputs[0].size, output.size, ctaps.size()); + fflush(stderr); + // rebuild composite FIR if the center freq has changed if (d_updated){ @@ -117,11 +499,35 @@ d_updated = 0; } +#ifdef MEASURE_TIME + t1=rdtsc(); +#endif + unsigned j = 0; - for (unsigned i = 0; i < output.size; i++){ + for (i = 0; i < output.size; i++){ out[i] = d_r.rotate (d_composite_fir->filter (&in[j])); j += decimation; } - + +#if 0 + for (i = 0; i < output.size; i++){ + fprintf(stderr, "(%f %f) ", out[i].real(), out[i].imag()); + } + + fprintf(stderr, "\n"); + fflush(stderr); +#endif + +#ifdef MEASURE_TIME + t2=rdtsc(); + fprintf(stderr, "diff=%llu\n", (t2-t1)); + fflush(stderr); +#endif + return output.size; } + +#endif + +/***********************************************************************/ + --- ./gnuradio_new/src/gnu/lib/gr/GrFIRfilterXXX_cc.t 2005-10-24 10:12:25.000000000 -0400 +++ ./gnuradio/src/gnu/lib/gr/GrFIRfilterXXX_cc.t 2005-10-24 09:49:22.000000000 -0400 @@ -29,12 +29,38 @@ #include <@FIR_TYPE@.h> #include +#ifdef USE_GPU + +#define GLH_NVEB_USING_CGGL + +#include "gpu.h" +using namespace nv_dds; + +#endif + +#define rdtsc() \ + ({ \ + union { \ + struct { \ + unsigned l, h; \ + } p; \ + unsigned long long f; \ + } t; \ + asm volatile ("rdtsc" : "=a" (t.p.l), "=d" (t.p.h)); \ + t.f; \ + }) + +#undef MEASURE_TIME +//#define MEASURE_TIME + + @NAME@::@NAME@ (int decimation_factor, const std::vector<@TAP_TYPE@> &taps) : VrDecimatingSigProc<@I_TYPE@, @O_TYPE@>(1, decimation_factor), d_builder (0), d_updated (0) { d_fir = gr_fir_util::create_@FIR_TYPE@ (taps); + d_new_taps = taps; } @NAME@::@NAME@ (int decimation_factor, @FIR_BUILDER@ *builder) @@ -69,10 +95,331 @@ d_updated = 1; } + +#ifdef USE_GPU + +CGparameter @NAME@_Params; +GLuint @NAME@_hTextureIn, @NAME@_hTextureTaps, @NAME@_hTextureOut; +int @NAME@_m, @NAME@_n, @NAME@_k; +@O_TYPE@* @NAME@_out; + +void @NAME@_display() { + int k_cur; + + fprintf(stderr, "@NAME@_display()\n"); + fflush(stderr); + + pbuf->Activate(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glViewport(0, 0, @NAME@_k/4, @NAME@_n-@NAME@_m); + + /* set parameters*/ + @NAME@_Params = cgGetNamedParameter(fProg[@NAME@_prog], "Params"); + cgGLSetParameter4f(@NAME@_Params, @NAME@_k/4-0.001f, @NAME@_m, 0.0f, 0.0f); + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @NAME@_hTextureOut); + + /* clean texture hTextureOut here */ + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, @NAME@_k/4, (@NAME@_n-@NAME@_m)); + + /* input matrix */ + glActiveTextureARB(GL_TEXTURE1_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @NAME@_hTextureIn); + + glActiveTextureARB(GL_TEXTURE3_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @NAME@_hTextureIn); + + /* taps matrix */ + glActiveTextureARB(GL_TEXTURE2_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @NAME@_hTextureTaps); + + glActiveTextureARB(GL_TEXTURE4_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @NAME@_hTextureTaps); + + glActiveTextureARB(GL_TEXTURE0_ARB); + + /* enable programs */ + cgGLBindProgram(fProg[@NAME@_prog]); + cgGLEnableProfile(fProfile); + + for (k_cur=0; k_cur<@NAME@_m; k_cur++) { + //for (k_cur=0; k_cur<@NAME@_m; k_cur+=2) { + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @NAME@_hTextureOut); + + glNormal3f(0.0, 0.0, 1.0); + + glBegin(GL_QUADS); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, k_cur); // input + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); // taps + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(-1, -1, 0.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, (@NAME@_n-@NAME@_m)); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, k_cur+(@NAME@_n-@NAME@_m)); // input + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); // taps + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(-1, 1, 0.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, @NAME@_k/4, (@NAME@_n-@NAME@_m)); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, @NAME@_k/4, k_cur+(@NAME@_n-@NAME@_m)); // input + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); // taps + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(1, 1, 0.0); + + glMultiTexCoord2fARB(GL_TEXTURE0_ARB, @NAME@_k/4, 0.0); + glMultiTexCoord2fARB(GL_TEXTURE1_ARB, @NAME@_k/4, k_cur); // input + glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, k_cur); // taps + glColor3f(0.0f, 0.0f, 0.0); + glVertex3f(1, -1, 0.0); + + glEnd(); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, @NAME@_hTextureOut); + + /* copy results from framebuffer into texture 0 */ + glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, @NAME@_k/4, (@NAME@_n-@NAME@_m)); + } + + pbuf->Deactivate(); +} + + +int +@NAME@::work (VrSampleRange output, void *ao[], + VrSampleRange inputs[], void *ai[]) { + + @I_TYPE@ *in_data=NULL; + @TAP_TYPE@ *taps_data; + + int i; + +#ifdef MEASURE_TIME + unsigned long long t1, t2; +#endif + + fprintf(stderr, "GPU verion of @NAME@::work input size=%d output size=%d number of taps=%d\n", inputs[0].size, output.size, d_new_taps.size()); + fflush(stderr); + + @NAME@_out=NULL; + + if (hTextureIn==0) { + create_textures(); + } + + if (get_read_textures(0)) { + /* use the input texture from the upstream node */ + @NAME@_k = get_k(0); + + } else { + /* use the input from arguments */ + @NAME@_k = (int)sqrt((float)d_new_taps.size())*4; + while (@NAME@_k%4) @NAME@_k++; + } + + @NAME@_m = (int)(d_new_taps.size()/@NAME@_k)+1; + if ((@NAME@_m-1)*@NAME@_k >= (int)d_new_taps.size()) { + @NAME@_m--; + } + + @NAME@_n=(int)(output.size/@NAME@_k)+1; + if ((@NAME@_n-1)*@NAME@_k >= (int)output.size) { + @NAME@_n--; + } + + @NAME@_n+=@NAME@_m; + + /* set global variables */ + fprintf(stderr, "m=%d n=%d k=%d\n", @NAME@_m, @NAME@_n, @NAME@_k); + fflush(stderr); + + gpu_width=@NAME@_k/4; + gpu_height=@NAME@_n-@NAME@_m; + gpu_k = @NAME@_k; + read_textures=1; /* next block should read this block's output texture */ + + if (get_read_textures(0)) { + @NAME@_hTextureIn = get_texture_out(0); + + } else { + /* create input texture */ + + in_data = (@I_TYPE@*)malloc(@NAME@_n*@NAME@_k*sizeof(@I_TYPE@)); + memset(in_data, 0, sizeof(@I_TYPE@)*@NAME@_n*@NAME@_k); + memcpy(in_data, (@I_TYPE@*)ai[0], sizeof(@I_TYPE@)*inputs[0].size); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureIn); + + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + @NAME@_k/4, + @NAME@_n, + 0, + GL_RGBA, + GL_FLOAT, + in_data); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + @NAME@_hTextureIn = hTextureIn; + } + + /* create taps texture */ + taps_data = (@TAP_TYPE@*)malloc(@NAME@_m*@NAME@_k*sizeof(@TAP_TYPE@)); + memset(taps_data, 0, sizeof(@TAP_TYPE@)*@NAME@_m*@NAME@_k); + + for (i=0; i<(int)d_new_taps.size(); i++) { + taps_data[i]=d_new_taps[i]; + } + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureTaps); + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + @NAME@_k/4, + @NAME@_m, + 0, + GL_RGBA, + GL_FLOAT, + taps_data); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + glBindTexture(GL_TEXTURE_RECTANGLE_NV, hTextureOut); + glTexImage2D(GL_TEXTURE_RECTANGLE_NV, + 0, + GL_FLOAT_RGBA32_NV, + 700, + 200, + 0, + GL_RGBA, + GL_FLOAT, + NULL); + glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); + + @NAME@_hTextureTaps = hTextureTaps; + @NAME@_hTextureOut = hTextureOut; + +#if 0 + + int j,k,l,x,y; + + /* compute FIR filter here */ + @NAME@_out = (@O_TYPE@*)malloc((@NAME@_n-@NAME@_m)*@NAME@_k*sizeof(@O_TYPE@)); + memset(@NAME@_out, 0, sizeof(@O_TYPE@)*@NAME@_k*(@NAME@_n-@NAME@_m)); + + for (k=0; k<@NAME@_m; k++) { + //for (k=0; k<1; k++) { + for (l=0; l<(@NAME@_n-@NAME@_m); l++) { + for (i=0; i<@NAME@_k; i++) { + for (j=0; j<@NAME@_k; j++) { + + x=i+j; + y=l+k; + if (x>=@NAME@_k) { + x-=@NAME@_k; + y+=1; + } + + //@NAME@_out[l*@NAME@_k+i]=in_data[l*@NAME@_k+i]; + @NAME@_out[l*@NAME@_k+i] += taps_data[j+k*@NAME@_k] * in_data[x+y*@NAME@_k]; + } + } + } + } + +#if 1 + for (i=0; i 0.1f) { + fprintf(stderr, "ERR %f\n", re_err*re_err + im_err*im_err); + } +#endif + + fprintf(stderr, "%f ", @NAME@_out[i]); + } + + fprintf(stderr, "total error %f\n", total_err); + fflush(stderr); +#endif + + if (in_data) { + free(in_data); + } + + if (@NAME@_out) { + free(@NAME@_out); + } + + free(taps_data); + + return output.size; +} + +#else + int @NAME@::work (VrSampleRange output, void *ao[], VrSampleRange inputs[], void *ai[]) { + +#ifdef MEASURE_TIME + unsigned long long t1, t2; +#endif + + fprintf(stderr, "CPU FIR filter work input size=%d output size=%d number of taps=%d\n", inputs[0].size, output.size, d_new_taps.size()); + fflush(stderr); + @I_TYPE@ *in = (@I_TYPE@ *) ai[0]; @O_TYPE@ *out = (@O_TYPE@ *) ao[0]; @@ -82,11 +429,29 @@ d_updated = 0; } +#ifdef MEASURE_TIME + t1=rdtsc(); +#endif + if (decimation == 1) d_fir->filterN (out, in, output.size); else d_fir->filterNdec (out, in, output.size, decimation); +#ifdef MEASURE_TIME + t2=rdtsc(); + fprintf(stderr, "diff=%llu\n", (t2-t1)); + fflush(stderr); +#endif + return output.size; } + +#endif + + +#undef rdtsc + +/************************************* JUNK *************************************/ + --- ./gnuradio_new/src/gnu/lib/gr/generate_GrFreqXlatingFIRfilterXXX.py 2005-10-24 10:12:24.000000000 -0400 +++ ./gnuradio/src/gnu/lib/gr/generate_GrFreqXlatingFIRfilterXXX.py 2005-08-26 16:50:59.000000000 -0400 @@ -35,6 +35,7 @@ d['O_TYPE'] = o_type (code3) d['TAP_TYPE'] = tap_type (code3) d['FIR_BUILDER'] = char_to_builder[tap_code (code3)] + d['SHORTNAME'] = 'GrFXFIRfilter' +code3 return d