3 * Copyright 2002 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
25 #include <gr_fir_sysconfig_x86.h>
28 #include <gr_fir_ccf.h>
29 #include <gr_fir_ccf_generic.h>
30 #include <gr_fir_ccf_x86.h>
31 #include <gr_fir_fcc.h>
32 #include <gr_fir_fcc_generic.h>
33 #include <gr_fir_fcc_x86.h>
34 #include <gr_fir_fff.h>
35 #include <gr_fir_fff_generic.h>
36 #include <gr_fir_fff_x86.h>
37 #include <gr_fir_fsf.h>
38 #include <gr_fir_fsf_generic.h>
39 #include <gr_fir_fsf_x86.h>
40 #include <gr_fir_ccc.h>
41 #include <gr_fir_ccc_generic.h>
42 #include <gr_fir_ccc_x86.h>
43 #include <gr_fir_scc.h>
44 #include <gr_fir_scc_generic.h>
45 #include <gr_fir_scc_x86.h>
46 // #include <gr_fir_sss.h>
47 // #include <gr_fir_sss_generic.h>
48 // #include <gr_fir_sss_mmx.h>
49 // #include <gr_fir_sss_sse2.h>
55 * ----------------------------------------------------------------
56 * static functions that serve as constructors...
57 * Is it possible to take the address of a normal constructor?
58 * ----------------------------------------------------------------
62 make_gr_fir_ccf_3dnow(const std::vector<float> &taps)
64 return new gr_fir_ccf_3dnow(taps);
68 make_gr_fir_ccf_sse(const std::vector<float> &taps)
70 return new gr_fir_ccf_sse(taps);
74 make_gr_fir_fcc_3dnow(const std::vector<gr_complex> &taps)
76 return new gr_fir_fcc_3dnow(taps);
80 make_gr_fir_fcc_sse(const std::vector<gr_complex> &taps)
82 return new gr_fir_fcc_sse(taps);
86 make_gr_fir_ccc_3dnow (const std::vector<gr_complex> &taps)
88 return new gr_fir_ccc_3dnow (taps);
92 make_gr_fir_ccc_3dnowext (const std::vector<gr_complex> &taps)
94 return new gr_fir_ccc_3dnowext (taps);
98 make_gr_fir_ccc_sse (const std::vector<gr_complex> &taps)
100 return new gr_fir_ccc_sse (taps);
104 make_gr_fir_fff_3dnow (const std::vector<float> &taps)
106 return new gr_fir_fff_3dnow (taps);
110 make_gr_fir_fff_sse (const std::vector<float> &taps)
112 return new gr_fir_fff_sse (taps);
116 make_gr_fir_fsf_3dnow (const std::vector<float> &taps)
118 return new gr_fir_fsf_3dnow (taps);
122 make_gr_fir_fsf_sse (const std::vector<float> &taps)
124 return new gr_fir_fsf_sse (taps);
129 make_gr_fir_sss_mmx (const std::vector<short> &taps)
131 return new gr_fir_sss_mmx (taps);
135 make_gr_fir_sss_sse2 (const std::vector<short> &taps)
137 return new gr_fir_sss_sse2 (taps);
142 make_gr_fir_scc_3dnow(const std::vector<gr_complex> &taps)
144 return new gr_fir_scc_3dnow(taps);
148 make_gr_fir_scc_3dnowext(const std::vector<gr_complex> &taps)
150 return new gr_fir_scc_3dnowext(taps);
154 make_gr_fir_scc_sse(const std::vector<gr_complex> &taps)
156 return new gr_fir_scc_sse(taps);
160 * ----------------------------------------------------------------
161 * Return instances of the fastest x86 versions of these classes.
163 * check CPUID, if has 3DNowExt, return 3DNow!Ext version,
164 * else if 3DNow, return 3DNow! version,
165 * else if SSE2, return SSE2 version,
166 * else if SSE, return SSE version,
167 * else if MMX, return MMX version,
168 * else return generic version.
170 * FIXME: benchmark, store result, use stored result to
171 * select the fastest version.
172 * ----------------------------------------------------------------
176 gr_fir_sysconfig_x86::create_gr_fir_ccf (const std::vector<float> &taps)
178 static bool first = true;
180 if (gr_cpu::has_3dnow ()){
182 cerr << ">>> gr_fir_ccf: using 3DNow!\n";
185 return make_gr_fir_ccf_3dnow (taps);
188 if (gr_cpu::has_sse ()){
190 cerr << ">>> gr_fir_ccf: using SSE\n";
193 return make_gr_fir_ccf_sse (taps);
197 cerr << ">>> gr_fir_ccf: handing off to parent class\n";
200 return gr_fir_sysconfig_generic::create_gr_fir_ccf (taps);
204 gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps)
206 static bool first = true;
208 if (gr_cpu::has_3dnow ()){
210 cerr << ">>> gr_fir_fcc: using 3DNow!\n";
213 return make_gr_fir_fcc_3dnow (taps);
216 if (gr_cpu::has_sse ()){
218 cerr << ">>> gr_fir_fcc: using SSE\n";
221 return make_gr_fir_fcc_sse (taps);
225 cerr << ">>> gr_fir_fcc: handing off to parent class\n";
228 return gr_fir_sysconfig_generic::create_gr_fir_fcc (taps);
232 gr_fir_sysconfig_x86::create_gr_fir_ccc (const std::vector<gr_complex> &taps)
234 static bool first = true;
236 if (gr_cpu::has_3dnowext ()){
238 cerr << ">>> gr_fir_ccc: using 3DNow!Ext\n";
241 return make_gr_fir_ccc_3dnowext (taps);
244 if (gr_cpu::has_3dnow ()){
246 cerr << ">>> gr_fir_ccc: using 3DNow!\n";
249 return make_gr_fir_ccc_3dnow (taps);
252 if (gr_cpu::has_sse ()){
254 cerr << ">>> gr_fir_ccc: using SSE\n";
257 return make_gr_fir_ccc_sse (taps);
261 cerr << ">>> gr_fir_ccc: handing off to parent class\n";
264 return gr_fir_sysconfig_generic::create_gr_fir_ccc (taps);
268 gr_fir_sysconfig_x86::create_gr_fir_fff (const std::vector<float> &taps)
270 static bool first = true;
272 if (gr_cpu::has_3dnow ()){
274 cerr << ">>> gr_fir_fff: using 3DNow!\n";
277 return make_gr_fir_fff_3dnow (taps);
280 if (gr_cpu::has_sse ()){
282 cerr << ">>> gr_fir_fff: using SSE\n";
285 return make_gr_fir_fff_sse (taps);
289 cerr << ">>> gr_fir_fff: handing off to parent class\n";
292 return gr_fir_sysconfig_generic::create_gr_fir_fff (taps);
296 gr_fir_sysconfig_x86::create_gr_fir_fsf (const std::vector<float> &taps)
298 static bool first = true;
300 if (gr_cpu::has_3dnow ()){
302 cerr << ">>> gr_fir_fsf: using 3DNow!\n";
305 return make_gr_fir_fsf_3dnow (taps);
308 if (gr_cpu::has_sse ()){
310 cerr << ">>> gr_fir_fsf: using SSE\n";
313 return make_gr_fir_fsf_sse (taps);
317 cerr << ">>> gr_fir_fsf: handing off to parent class\n";
320 return gr_fir_sysconfig_generic::create_gr_fir_fsf (taps);
325 gr_fir_sysconfig_x86::create_gr_fir_sss (const std::vector<short> &taps)
327 // FIXME -- probably want to figure out best answer for Athlon and code
328 // add code to select it here...
330 if (gr_cpu::has_sse2 ()){
331 cerr << ">>> gr_fir_sss: using SSE2\n";
332 return make_gr_fir_sss_sse2 (taps);
335 if (gr_cpu::has_mmx ()){
336 cerr << ">>> gr_fir_sss: using MMX\n";
337 return make_gr_fir_sss_mmx (taps);
340 cerr << ">>> gr_fir_sss: handing off to parent class\n";
341 return gr_fir_sysconfig_generic::create_gr_fir_sss (taps);
346 gr_fir_sysconfig_x86::create_gr_fir_scc (const std::vector<gr_complex> &taps)
348 static bool first = true;
350 if (gr_cpu::has_3dnowext ()){
352 cerr << ">>> gr_fir_scc: using 3DNow!Ext\n";
355 return make_gr_fir_scc_3dnowext (taps);
358 if (gr_cpu::has_3dnow ()){
360 cerr << ">>> gr_fir_scc: using 3DNow!\n";
363 return make_gr_fir_scc_3dnow (taps);
366 if (gr_cpu::has_sse ()){
368 cerr << ">>> gr_fir_scc: using SSE\n";
371 return make_gr_fir_scc_sse (taps);
375 cerr << ">>> gr_fir_scc: handing off to parent class\n";
378 return gr_fir_sysconfig_generic::create_gr_fir_scc (taps);
382 * ----------------------------------------------------------------
383 * Return info about available implementations
384 * ----------------------------------------------------------------
388 gr_fir_sysconfig_x86::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info> *info)
393 gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info);
396 if (gr_cpu::has_3dnow ()){
398 t.create = make_gr_fir_ccf_3dnow;
399 (*info).push_back (t);
402 if (gr_cpu::has_sse ()){
404 t.create = make_gr_fir_ccf_sse;
405 (*info).push_back (t);
410 gr_fir_sysconfig_x86::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info> *info)
415 gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info);
418 if (gr_cpu::has_3dnow ()){
420 t.create = make_gr_fir_fcc_3dnow;
421 (*info).push_back (t);
424 if (gr_cpu::has_sse ()){
426 t.create = make_gr_fir_fcc_sse;
427 (*info).push_back (t);
432 gr_fir_sysconfig_x86::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info> *info)
437 gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info);
440 if (gr_cpu::has_3dnowext ()){
441 t.name = "3DNow!Ext";
442 t.create = make_gr_fir_ccc_3dnowext;
443 (*info).push_back (t);
446 if (gr_cpu::has_3dnow ()){
448 t.create = make_gr_fir_ccc_3dnow;
449 (*info).push_back (t);
452 if (gr_cpu::has_sse ()){
454 t.create = make_gr_fir_ccc_sse;
455 (*info).push_back (t);
460 gr_fir_sysconfig_x86::get_gr_fir_fff_info (std::vector<gr_fir_fff_info> *info)
465 gr_fir_sysconfig_generic::get_gr_fir_fff_info (info);
468 if (gr_cpu::has_3dnow ()){
470 t.create = make_gr_fir_fff_3dnow;
471 (*info).push_back (t);
474 if (gr_cpu::has_sse ()){
476 t.create = make_gr_fir_fff_sse;
477 (*info).push_back (t);
482 gr_fir_sysconfig_x86::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info> *info)
487 gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info);
490 if (gr_cpu::has_3dnow ()){
492 t.create = make_gr_fir_fsf_3dnow;
493 (*info).push_back (t);
496 if (gr_cpu::has_sse ()){
498 t.create = make_gr_fir_fsf_sse;
499 (*info).push_back (t);
504 gr_fir_sysconfig_x86::get_gr_fir_scc_info (std::vector<gr_fir_scc_info> *info)
509 gr_fir_sysconfig_generic::get_gr_fir_scc_info (info);
512 if (gr_cpu::has_3dnowext ()){
513 t.name = "3DNow!Ext";
514 t.create = make_gr_fir_scc_3dnowext;
515 (*info).push_back (t);
518 if (gr_cpu::has_3dnow ()){
520 t.create = make_gr_fir_scc_3dnow;
521 (*info).push_back (t);
524 if (gr_cpu::has_sse ()){
526 t.create = make_gr_fir_scc_sse;
527 (*info).push_back (t);
533 gr_fir_sysconfig_x86::get_gr_fir_sss_info (std::vector<gr_fir_sss_info> *info)
538 gr_fir_sysconfig_generic::get_gr_fir_sss_info (info);
541 if (gr_cpu::has_mmx ()){
543 t.create = make_gr_fir_sss_mmx;
544 (*info).push_back (t);
547 if (gr_cpu::has_sse2 ()){
549 t.create = make_gr_fir_sss_sse2;
550 (*info).push_back (t);