UnloaderShare.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2002 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // dspsr/Signal/Pulsar/dsp/UnloaderShare.h
10 
11 #ifndef __UnloaderShare_h
12 #define __UnloaderShare_h
13 
14 #include "dsp/PhaseSeriesUnloader.h"
15 #include "dsp/SignalPath.h"
16 #include "dsp/TimeDivide.h"
17 
18 class ThreadContext;
19 
20 namespace dsp {
21 
22  class PhaseSeries;
23  class PhaseSeriesUnloader;
24 
26 
31  class UnloaderShare : public Reference::Able {
32 
33  public:
34 
36  UnloaderShare (unsigned contributors);
37 
39  virtual ~UnloaderShare ();
40 
42  void set_context (ThreadContext*);
43 
45  void set_wait_all (bool);
46 
48  class Submit;
49 
51  Submit* new_Submit (unsigned contributor);
52 
54  void unload (const PhaseSeries*, Submit*);
55 
57  void finish_all (unsigned contributor);
58 
60  void copy (const TimeDivide*);
61 
63  void set_start_time (const MJD& start_time);
64 
66  MJD get_start_time () const;
67 
69  void set_subint_seconds (double subint_seconds);
70 
72  double get_subint_seconds () const;
73 
75  void set_subint_turns (unsigned subint_turns);
76 
78  unsigned get_subint_turns () const;
79 
84 
87 
90 
92  void finish ();
93 
94  protected:
95 
96  class Storage;
97 
99  void unload (Storage*);
100 
102  void nonblocking_unload (unsigned istore, Submit*);
103 
105  std::vector< Reference::To<Storage> > storage;
106 
109 
112 
115 
117  unsigned contributors;
118 
120  std::vector<uint64_t> last_division;
121 
124 
126  bool wait_all;
127 
129  std::vector<bool> finished_all;
130 
132  bool all_finished ();
133  };
134 
135  class UnloaderShare::Submit : public PhaseSeriesUnloader
136  {
137  public:
138 
140  Submit (UnloaderShare* parent, unsigned contributor);
141 
143  Submit* clone () const;
144 
147 
149  void unload (const PhaseSeries*);
150 
152  void partial (const PhaseSeries*);
153 
155  void finish ();
156 
158  void set_minimum_integration_length (double seconds);
159 
161  void set_cerr (std::ostream& os) const;
162 
163  protected:
164 
165  friend class UnloaderShare;
166 
169  unsigned contributor;
170  };
171 
172  class UnloaderShare::Storage : public Reference::Able
173  {
174  public:
175 
177  Storage (unsigned contributors, const std::vector<bool>& finished);
178 
180  ~Storage ();
181 
183  void set_profiles (const PhaseSeries*);
184 
186  PhaseSeries* get_profiles ();
187 
189  void set_division (uint64_t);
190 
192  uint64_t get_division ();
193 
195  bool integrate (unsigned contributor, uint64_t division, const PhaseSeries*);
196 
198  void set_finished (unsigned contributor);
199 
201  bool get_finished ();
202 
204  void wait_all (ThreadContext*);
205 
206  protected:
207 
209 
210  std::vector<bool> finished;
211  uint64_t division;
212 
213  void print_finished ();
214 
215  };
216 
217 }
218 
219 #endif // !defined(__UnloaderShare_h)
220 
221 
PhaseSeriesUnloader * get_unloader() const
Get the shared file unloader.
Definition: UnloaderShare.C:53
void unload(const PhaseSeries *, Submit *)
Unload the PhaseSeries data.
Definition: UnloaderShare.C:101
void nonblocking_unload(unsigned istore, Submit *)
Unload the storage in parallel.
Definition: UnloaderShare.C:341
void finish_all(unsigned contributor)
Inform any waiting threads that contributor is finished.
Definition: UnloaderShare.C:258
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
void set_wait_all(bool)
When sub-integration is finished, wait for all other threads to finish.
Definition: UnloaderShare.C:41
void finish()
Unload all cached subintegrations.
Definition: UnloaderShare.C:286
ThreadContext * context
Thread coordination used in unload method.
Definition: UnloaderShare.h:123
Data as a function of pulse phase.
Definition: PhaseSeries.h:28
bool wait_all
First contributor to complete a division waits for all others.
Definition: UnloaderShare.h:126
double get_integration_length() const
Get the number of seconds integrated.
Definition: PhaseSeries.h:87
Unload PhaseSeries data from multiple threads.
Definition: UnloaderShare.h:31
TimeDivide divider
The time divider.
Definition: UnloaderShare.h:111
unsigned contributors
The number of contributors.
Definition: UnloaderShare.h:117
Type * get() const
void set_context(ThreadContext *)
Set the context for control of shared resources.
Definition: UnloaderShare.C:36
unsigned get_subint_turns() const
Get the number of turns to fold into each sub-integration.
Definition: UnloaderShare.C:82
void set_start_time(const MJD &start_time)
Set the start time from which to begin counting sub-integrations.
Definition: UnloaderShare.C:64
double get_subint_seconds() const
Get the number of seconds to fold into each sub-integration.
Definition: UnloaderShare.C:76
Base class for things that can unload PhaseSeries data somewhere.
Definition: PhaseSeriesUnloader.h:30
Reference::To< PhaseSeriesUnloader > unloader
File unloader.
Definition: UnloaderShare.h:108
void set_unloader(PhaseSeriesUnloader *unloader)
Set the shared file unloader.
Definition: UnloaderShare.C:47
static bool verbose
Global verbosity flag.
Definition: Operation.h:48
bool all_finished()
Return true when all threads have finished.
Definition: UnloaderShare.C:278
MJD get_end_time() const
Get the end time.
Definition: PhaseSeries.h:94
void set_subint_seconds(double subint_seconds)
Set the number of seconds to fold into each sub-integration.
Definition: UnloaderShare.C:88
MJD get_start_time() const
Get the start time from which to begin counting sub-integrations.
Definition: UnloaderShare.C:70
std::vector< bool > finished_all
Flags set when a contributor calls finish_all.
Definition: UnloaderShare.h:129
std::vector< uint64_t > last_division
The last division completed by a contributor.
Definition: UnloaderShare.h:120
void set_subint_turns(unsigned subint_turns)
Set the number of turns to fold into each sub-integration.
Definition: UnloaderShare.C:94
Submit * new_Submit(unsigned contributor)
Get submission interface for the specified contributor.
Definition: UnloaderShare.C:458
std::vector< Reference::To< Storage > > storage
Temporary storage of incomplete sub-integrations.
Definition: UnloaderShare.h:105
PhaseSeries * clone() const
Clone operator.
Definition: PhaseSeries.C:88
UnloaderShare(unsigned contributors)
Constructor.
Definition: UnloaderShare.C:21
MJD get_start_time() const
Return the start time of the leading edge of the first time sample.
Definition: Observation.h:152
Calculates the boundaries of a division of time.
Definition: TimeDivide.h:28
virtual ~UnloaderShare()
Destructor.
Definition: UnloaderShare.C:30
const TimeDivide * divider_copy
Pointer to TimeDivide to be copied when needed.
Definition: UnloaderShare.h:114
void copy(const TimeDivide *)
Copy the Divider configuration.
Definition: UnloaderShare.C:58
virtual void set_cerr(std::ostream &) const

Generated using doxygen 1.8.17