SKFilterbank.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2010 by Willem van Straten and Andrew Jameson
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Signal/General/dsp/SKFilterbank.h
10 
11 #ifndef __SKFilterbank_h
12 #define __SKFilterbank_h
13 
14 #include "dsp/Filterbank.h"
15 #include "ThreadContext.h"
16 
17 namespace dsp {
18 
20 
22  class SKFilterbank: public Filterbank {
23 
24  public:
25 
27  SKFilterbank ( unsigned _n_threads=1 );
28  ~SKFilterbank ();
29 
31  class Engine;
32 
33  void set_engine (Engine*);
34 
35  void set_M (unsigned _M) { tscrunch = _M; }
36 
37  uint64_t get_skfb_inc (uint64_t blocksize);
38 
39  void set_output_tscr (TimeSeries * _output_tscr);
40 
41  protected:
42 
44  virtual void filterbank ();
45  virtual void custom_prepare ();
46 
49 
50  private:
51 
53  unsigned tscrunch;
54 
55  unsigned debugd;
56 
58  ThreadContext* context;
59 
61  unsigned n_threads;
62 
64  unsigned thread_count;
65 
67  std::vector <pthread_t> ids;
68 
70  void start_threads ();
71 
73  void wait_threads ();
74 
76  void stop_threads ();
77 
79  void join_threads ();
80 
82  static void* sk_thread (void*);
83 
85  void thread ();
86 
87  enum State { Idle, Active, Quit };
88 
90  State state;
91 
93  std::vector <State> states;
94 
96  Reference::To<TimeSeries> output_tscr;
97 
99  std::vector <float> S1_tscr;
100  std::vector <float> S2_tscr;
101 
102  };
103 
104  class SKFilterbank::Engine : public Reference::Able
105  {
106  public:
107 
108  virtual void setup () = 0;
109 
110  virtual void prepare (const dsp::TimeSeries* input, unsigned _nfft) = 0;
111 
112  virtual void perform (const dsp::TimeSeries* input, dsp::TimeSeries* output,
113  dsp::TimeSeries *output_tscr) = 0;
114 
115  };
116 }
117 
118 #endif
119 
virtual void filterbank()
Perform the filterbank step.
Definition: SKFilterbank.C:107
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
void tscrunch(Container *, const ScrunchFactor &)
virtual void set_buffering_policy(BufferingPolicy *policy)
Set the policy for buffering input and/or output data.
Definition: Transformation.h:85
Buffers the Transformation input.
Definition: InputBuffering.h:26
Arrays of consecutive samples for each polarization and frequency channel.
Definition: TimeSeries.h:29
Reference::To< Engine > engine
Interface to alternate processing engine (e.g. GPU)
Definition: SKFilterbank.h:58
void prepare()
Prepare all relevant attributes.
Definition: Filterbank.C:46
SKFilterbank(unsigned _n_threads=1)
Null constructor.
Definition: SKFilterbank.C:17
Breaks a single-band TimeSeries into multiple frequency channels.
Definition: Filterbank.h:27
Breaks a single-band TimeSeries into multiple frequency channels.
Definition: SKFilterbank.h:27
Reference::To< const TimeSeries > input
Container from which input data will be read.
Definition: HasInput.h:49
@ OrderTFP
Time, Frequency, Polarization (better for many things)
Definition: TimeSeries.h:50
Reference::To< TimeSeries > output
Container into which output data will be written.
Definition: HasOutput.h:49

Generated using doxygen 1.8.17