Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8813
Modified Files: Tag: desiredata builtins_dsp.c Log Message: merged setup procs into DSPNEW
Index: builtins_dsp.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** builtins_dsp.c 3 Jan 2007 22:15:19 -0000 1.1.2.6 --- builtins_dsp.c 3 Jan 2007 22:28:57 -0000 1.1.2.7 *************** *** 69,95 **** outlet_new(x, &s_signal); \ x->a = 0; \ ! return x;}
#define DSPDSP(NAME) \ static void NAME##_dsp(t_minus *x, t_signal **sp) { \ ! const int n = sp[0]->s_n; \ ! if(n&7) \ ! dsp_add(NAME##_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); \ ! else if(SIMD_CHECK3(n,sp[0]->s_vec,sp[1]->s_vec,sp[2]->s_vec)) \ ! dsp_add(NAME##_perf_simd, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); \ ! else \ ! dsp_add(NAME##_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); \ ! }\ ! \ ! static void scalar##NAME##_dsp(t_scalarminus *x, t_signal **sp) \ ! { \ ! const int n = sp[0]->s_n;\ ! if(n&7)\ ! dsp_add(scalar##NAME##_perform, 4, sp[0]->s_vec, &x->b,sp[1]->s_vec, n);\ ! else if(SIMD_CHECK2(n,sp[0]->s_vec,sp[1]->s_vec))\ ! dsp_add(scalar##NAME##_perf_simd, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n);\ ! else \ ! dsp_add(scalar##NAME##_perf8, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n);\ ! }
#define PERFORM(NAME,EXPR) \ --- 69,96 ---- outlet_new(x, &s_signal); \ x->a = 0; \ ! return x;} \ ! static void NAME##_setup(void) { \ ! t_class *c = NAME##_class = class_new(gensym("+~"), (t_newmethod)NAME##_new, 0, sizeof(t_dop), 0, A_GIMME, 0); \ ! class_addmethod(c, (t_method)NAME##_dsp, gensym("dsp"), 0); \ ! CLASS_MAINSIGNALIN(c, t_dop, a); \ ! class_sethelpsymbol(NAME##_class, gensym("sigbinops")); \ ! c = scalar##NAME##_class = class_new(gensym("+~"), 0, 0, sizeof(t_dop), 0, 0); \ ! CLASS_MAINSIGNALIN(c, t_dop, a); \ ! class_addmethod(c, (t_method)scalar##NAME##_dsp, gensym("dsp"), 0); \ ! class_sethelpsymbol(scalar##NAME##_class, gensym("sigbinops"));}
#define DSPDSP(NAME) \ static void NAME##_dsp(t_minus *x, t_signal **sp) { \ ! const int n = sp[0]->s_n; \ ! if(n&7) dsp_add(NAME##_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); \ ! else if(SIMD_CHECK3(n,sp[0]->s_vec,sp[1]->s_vec,sp[2]->s_vec)) \ ! dsp_add(NAME##_perf_simd, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); \ ! else dsp_add(NAME##_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n);} \ ! static void scalar##NAME##_dsp(t_scalarminus *x, t_signal **sp) { \ ! const int n = sp[0]->s_n;\ ! if(n&7) dsp_add(scalar##NAME##_perform, 4, sp[0]->s_vec, &x->b,sp[1]->s_vec, n);\ ! else if(SIMD_CHECK2(n,sp[0]->s_vec,sp[1]->s_vec)) \ ! dsp_add(scalar##NAME##_perf_simd, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n);\ ! else dsp_add(scalar##NAME##_perf8, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n);}
#define PERFORM(NAME,EXPR) \ *************** *** 131,141 **** return w+5;}
- PERFORM(plus ,a+b) DSPNEW(plus) DSPDSP(plus) - PERFORM(minus,a-b) DSPNEW(minus) DSPDSP(minus) - PERFORM(times,a*b) DSPNEW(times) /*DSPDSP(times)*/ - /*PERFORM(over,a/b)*/ DSPNEW(over) DSPDSP(over) - PERFORM(min ,a<b?a:b) DSPNEW(min) DSPDSP(min) - PERFORM(max ,a>b?a:b) DSPNEW(max) DSPDSP(max) - void dsp_add_plus(t_sample *in1, t_sample *in2, t_sample *out, int n) { if (n&7) dsp_add(plus_perform, 4, in1, in2, out, n); --- 132,135 ---- *************** *** 144,177 **** }
- static void plus_setup(void) - { - plus_class = class_new(gensym("+~"), (t_newmethod)plus_new, 0, - sizeof(t_plus), 0, A_GIMME, 0); - class_addmethod(plus_class, (t_method)plus_dsp, gensym("dsp"), 0); - CLASS_MAINSIGNALIN(plus_class, t_plus, a); - class_sethelpsymbol(plus_class, gensym("sigbinops")); - scalarplus_class = class_new(gensym("+~"), 0, 0, - sizeof(t_scalarplus), 0, 0); - CLASS_MAINSIGNALIN(scalarplus_class, t_scalarplus, a); - class_addmethod(scalarplus_class, (t_method)scalarplus_dsp, gensym("dsp"), - 0); - class_sethelpsymbol(scalarplus_class, gensym("sigbinops")); - } - - static void minus_setup(void) - { - minus_class = class_new(gensym("-~"), (t_newmethod)minus_new, 0, - sizeof(t_minus), 0, A_GIMME, 0); - CLASS_MAINSIGNALIN(minus_class, t_minus, a); - class_addmethod(minus_class, (t_method)minus_dsp, gensym("dsp"), 0); - class_sethelpsymbol(minus_class, gensym("sigbinops")); - scalarminus_class = class_new(gensym("-~"), 0, 0, - sizeof(t_scalarminus), 0, 0); - CLASS_MAINSIGNALIN(scalarminus_class, t_scalarminus, a); - class_addmethod(scalarminus_class, (t_method)scalarminus_dsp, gensym("dsp"), - 0); - class_sethelpsymbol(scalarminus_class, gensym("sigbinops")); - } - /* T.Grill - squaring: optimized * for equal input signals */ t_int *sqr_perf8(t_int *w) --- 138,141 ---- *************** *** 193,272 ****
/* T.Grill - added optimization for equal input signals */ ! static void times_dsp(t_times *x, t_signal **sp) ! { const int n = sp[0]->s_n; ! if (n&7) ! dsp_add(times_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); ! else ! if(sp[0]->s_vec == sp[1]->s_vec) ! { ! if(SIMD_CHECK2(n,sp[0]->s_vec,sp[2]->s_vec)) ! dsp_add(sqr_perf_simd, 3, sp[0]->s_vec, sp[2]->s_vec, n); ! else ! dsp_add(sqr_perf8, 3, sp[0]->s_vec, sp[2]->s_vec, n); ! } ! else ! { ! if(SIMD_CHECK3(n,sp[0]->s_vec,sp[1]->s_vec,sp[2]->s_vec)) ! dsp_add(times_perf_simd, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); ! else ! dsp_add(times_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); ! } } ! ! static void scalartimes_dsp(t_scalartimes *x, t_signal **sp) ! { ! const int n = sp[0]->s_n; ! if (n&7) ! dsp_add(scalartimes_perform, 4, sp[0]->s_vec, &x->b,sp[1]->s_vec, n); ! else if(SIMD_CHECK2(n,sp[0]->s_vec,sp[1]->s_vec)) ! dsp_add(scalartimes_perf_simd, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n); ! else ! dsp_add(scalartimes_perf8, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n); }
! static void times_setup(void) ! { ! times_class = class_new(gensym("*~"), (t_newmethod)times_new, 0, ! sizeof(t_times), 0, A_GIMME, 0); ! CLASS_MAINSIGNALIN(times_class, t_times, a); ! class_addmethod(times_class, (t_method)times_dsp, gensym("dsp"), 0); ! class_sethelpsymbol(times_class, gensym("sigbinops")); ! scalartimes_class = class_new(gensym("*~"), 0, 0, ! sizeof(t_scalartimes), 0, 0); ! CLASS_MAINSIGNALIN(scalartimes_class, t_scalartimes, a); ! class_addmethod(scalartimes_class, (t_method)scalartimes_dsp, gensym("dsp"), ! 0); ! class_sethelpsymbol(scalartimes_class, gensym("sigbinops")); ! }
! t_int *over_perform(t_int *w) ! { ! t_float *in1 = (t_float *)(w[1]); ! t_float *in2 = (t_float *)(w[2]); ! t_float *out = (t_float *)(w[3]); ! int n = (int)(w[4]); ! while (n--) ! { float g = *in2++; *out++ = (g ? *in1++ / g : 0); } ! return (w+5); } ! ! t_int *over_perf8(t_int *w) ! { ! t_float *in1 = (t_float *)(w[1]); ! t_float *in2 = (t_float *)(w[2]); ! t_float *out = (t_float *)(w[3]); ! int n = (int)(w[4]); ! for (; n; n -= 8, in1 += 8, in2 += 8, out += 8) ! { float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3]; float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7]; - float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3]; float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7]; - out[0] = (g0? f0 / g0 : 0); out[1] = (g1? f1 / g1 : 0); --- 157,207 ----
/* T.Grill - added optimization for equal input signals */ ! static void times_dsp(t_times *x, t_signal **sp) { const int n = sp[0]->s_n; ! if (n&7) dsp_add(times_perform, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); ! else if(sp[0]->s_vec == sp[1]->s_vec) { ! if(SIMD_CHECK2(n,sp[0]->s_vec,sp[2]->s_vec)) ! dsp_add(sqr_perf_simd, 3, sp[0]->s_vec, sp[2]->s_vec, n); ! else dsp_add(sqr_perf8, 3, sp[0]->s_vec, sp[2]->s_vec, n); ! } else { ! if(SIMD_CHECK3(n,sp[0]->s_vec,sp[1]->s_vec,sp[2]->s_vec)) ! dsp_add(times_perf_simd, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); ! else dsp_add(times_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, n); ! } } ! static void scalartimes_dsp(t_scalartimes *x, t_signal **sp) { ! const int n = sp[0]->s_n; ! if (n&7) dsp_add(scalartimes_perform, 4, sp[0]->s_vec, &x->b,sp[1]->s_vec, n); ! else if(SIMD_CHECK2(n,sp[0]->s_vec,sp[1]->s_vec)) ! dsp_add(scalartimes_perf_simd, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n); ! else dsp_add(scalartimes_perf8, 4, sp[0]->s_vec, &x->b, sp[1]->s_vec, n); }
! PERFORM(plus ,a+b) DSPDSP(plus) DSPNEW(plus) ! PERFORM(minus,a-b) DSPDSP(minus) DSPNEW(minus) ! PERFORM(times,a*b) /*DSPDSP(times)*/ DSPNEW(times) ! /*PERFORM(over,a/b)*/ DSPDSP(over) DSPNEW(over) ! PERFORM(min ,a<b?a:b) DSPDSP(min) DSPNEW(min) ! PERFORM(max ,a>b?a:b) DSPDSP(max) DSPNEW(max)
! t_int *over_perform(t_int *w) { ! t_float *in1 = (t_float *)w[1], *in2 = (t_float *)w[2], *out = (t_float *)w[3]; ! int n = (int)w[4]; ! while (n--) { float g = *in2++; *out++ = (g ? *in1++ / g : 0); } ! return w+5; } ! t_int *over_perf8(t_int *w) { ! t_float *in1 = (t_float *)w[1]; ! t_float *in2 = (t_float *)w[2]; ! t_float *out = (t_float *)w[3]; ! int n = (int)w[4]; ! for (; n; n -= 8, in1 += 8, in2 += 8, out += 8) { float f0 = in1[0], f1 = in1[1], f2 = in1[2], f3 = in1[3]; float f4 = in1[4], f5 = in1[5], f6 = in1[6], f7 = in1[7]; float g0 = in2[0], g1 = in2[1], g2 = in2[2], g3 = in2[3]; float g4 = in2[4], g5 = in2[5], g6 = in2[6], g7 = in2[7]; out[0] = (g0? f0 / g0 : 0); out[1] = (g1? f1 / g1 : 0); *************** *** 278,357 **** out[7] = (g7? f7 / g7 : 0); } ! return (w+5); } - /* T.Grill - added check for zero */ ! t_int *scalarover_perform(t_int *w) ! { ! t_float *in = (t_float *)(w[1]); ! t_float f = *(t_float *)(w[2]); ! t_float *out = (t_float *)(w[3]); ! int n = (int)(w[4]); if(f) f = 1./f; while (n--) *out++ = *in++ * f; return (w+5); } ! ! t_int *scalarover_perf8(t_int *w) ! { ! t_float *in = (t_float *)(w[1]); ! t_float g = *(t_float *)(w[2]); ! t_float *out = (t_float *)(w[3]); ! int n = (int)(w[4]); if (g) g = 1.f / g; ! for (; n; n -= 8, in += 8, out += 8) ! { float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3]; float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7]; - out[0] = f0 * g; out[1] = f1 * g; out[2] = f2 * g; out[3] = f3 * g; out[4] = f4 * g; out[5] = f5 * g; out[6] = f6 * g; out[7] = f7 * g; } ! return (w+5); ! } ! ! static void over_setup(void) ! { ! over_class = class_new(gensym("/~"), (t_newmethod)over_new, 0, ! sizeof(t_over), 0, A_GIMME, 0); ! CLASS_MAINSIGNALIN(over_class, t_over, a); ! class_addmethod(over_class, (t_method)over_dsp, gensym("dsp"), 0); ! class_sethelpsymbol(over_class, gensym("sigbinops")); ! scalarover_class = class_new(gensym("/~"), 0, 0, ! sizeof(t_scalarover), 0, 0); ! CLASS_MAINSIGNALIN(scalarover_class, t_scalarover, a); ! class_addmethod(scalarover_class, (t_method)scalarover_dsp, gensym("dsp"), ! 0); ! class_sethelpsymbol(scalarover_class, gensym("sigbinops")); ! } ! ! static void max_setup(void) ! { ! max_class = class_new(gensym("max~"), (t_newmethod)max_new, 0, ! sizeof(t_max), 0, A_GIMME, 0); ! CLASS_MAINSIGNALIN(max_class, t_max, a); ! class_addmethod(max_class, (t_method)max_dsp, gensym("dsp"), 0); ! class_sethelpsymbol(max_class, gensym("sigbinops")); ! scalarmax_class = class_new(gensym("max~"), 0, 0, ! sizeof(t_scalarmax), 0, 0); ! CLASS_MAINSIGNALIN(scalarmax_class, t_scalarmax, a); ! class_addmethod(scalarmax_class, (t_method)scalarmax_dsp, gensym("dsp"), ! 0); ! class_sethelpsymbol(scalarmax_class, gensym("sigbinops")); ! } ! ! static void min_setup(void) ! { ! min_class = class_new(gensym("min~"), (t_newmethod)min_new, 0, ! sizeof(t_min), 0, A_GIMME, 0); ! CLASS_MAINSIGNALIN(min_class, t_min, a); ! class_addmethod(min_class, (t_method)min_dsp, gensym("dsp"), 0); ! class_sethelpsymbol(min_class, gensym("sigbinops")); ! scalarmin_class = class_new(gensym("min~"), 0, 0, ! sizeof(t_scalarmin), 0, 0); ! CLASS_MAINSIGNALIN(scalarmin_class, t_scalarmin, a); ! class_addmethod(scalarmin_class, (t_method)scalarmin_dsp, gensym("dsp"), ! 0); ! class_sethelpsymbol(scalarmin_class, gensym("sigbinops")); }
--- 213,241 ---- out[7] = (g7? f7 / g7 : 0); } ! return w+5; } /* T.Grill - added check for zero */ ! t_int *scalarover_perform(t_int *w) { ! t_float *in = (t_float *)w[1]; ! t_float f = *(t_float *)w[2]; ! t_float *out = (t_float *)w[3]; ! int n = (int)w[4]; if(f) f = 1./f; while (n--) *out++ = *in++ * f; return (w+5); } ! t_int *scalarover_perf8(t_int *w) { ! t_float *in = (t_float *)w[1]; ! t_float g = *(t_float *)w[2]; ! t_float *out = (t_float *)w[3]; ! int n = (int)w[4]; if (g) g = 1.f / g; ! for (; n; n -= 8, in += 8, out += 8) { float f0 = in[0], f1 = in[1], f2 = in[2], f3 = in[3]; float f4 = in[4], f5 = in[5], f6 = in[6], f7 = in[7]; out[0] = f0 * g; out[1] = f1 * g; out[2] = f2 * g; out[3] = f3 * g; out[4] = f4 * g; out[5] = f5 * g; out[6] = f6 * g; out[7] = f7 * g; } ! return w+5; }