Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Public Types | Public Member Functions | Friends | List of all members
ska::cheetah::data::DmTrials< Arch, NumericT, Alloc > Class Template Reference

A continuous memory container for dispersion measure trials of varying downsamplings. More...

#include <cheetah/data/DmTrials.h>

Inheritance diagram for ska::cheetah::data::DmTrials< Arch, NumericT, Alloc >:
Inheritance graph
Collaboration diagram for ska::cheetah::data::DmTrials< Arch, NumericT, Alloc >:
Collaboration graph

Public Types

typedef DedispersionMeasureType< float > DmType
 
typedef Series< Arch, NumericT, Alloc > SeriesType
 
typedef DmTrial< SeriesTypeDmTrialType
 
typedef DmTrialType::TimeType TimeType
 
typedef cheetah::utils::ModifiedJulianClock::time_point Mjd
 
typedef std::vector< DmTrialType >::iterator Iterator
 
typedef std::vector< DmTrialType >::const_iterator ConstIterator
 
typedef NumericT ValueType
 
typedef Arch Architecture
 
typedef Alloc Allocator
 

Public Member Functions

 DmTrials (std::shared_ptr< DmTrialsMetadata > metadata, Mjd start, Alloc const &allocator=Alloc())
 
template<typename OtherArch , typename OtherNumericT , typename OtherAlloc >
 DmTrials (DmTrials< OtherArch, OtherNumericT, OtherAlloc > const &, Alloc const &allocator=Alloc())
 
 ~DmTrials ()
 empty object constructor
 
Mjd const & start_time () const
 
void start_time (Mjd start_time)
 Set the absolute start time. More...
 
DmTrialTypeoperator[] (std::size_t n)
 Return reference to DmTrial instance. More...
 
DmTrialType const & operator[] (std::size_t n) const
 
Iterator begin ()
 Return an iterator pointing to the start of the DM trials container.
 
ConstIterator begin () const
 
ConstIterator cbegin () const
 
Iterator end ()
 Return an iterator pointing to the end of the DM trials container.
 
ConstIterator end () const
 
ConstIterator cend () const
 
std::size_t size () const
 Return the number of DmTrials.
 
bool is_compatible (DmTrials const &other) const
 Determines if another DmTrials object is compatible with this one. More...
 
bool is_contiguous (DmTrials const &other) const
 Determines if another DmTrials object is contiguous in time after this one. More...
 
TimeType duration () const
 Return the time duration of the DmTrials. More...
 
DmTrialsMetadata const & metadata () const
 Return the trials meta data object.
 
template<typename OtherArch , typename OtherT , typename OtherAlloc >
 DmTrials (DmTrials< OtherArch, OtherT, OtherAlloc > const &copy, Alloc const &allocator)
 

Friends

template<typename , typename , typename >
class DmTrials
 

Detailed Description

template<typename Arch, typename NumericT, typename Alloc = typename DefaultAllocator<Arch,NumericT>::type>
class ska::cheetah::data::DmTrials< Arch, NumericT, Alloc >

A continuous memory container for dispersion measure trials of varying downsamplings.

This is a continuous memory container for storing dispersion measure trials. The continuous nature of the underlying memory is a design detail rather than an implementation detail. The continuous memory is required for two reasons:

  1. Most dedispersion algorithms output their results in a continuous memory block
  2. In order to get high memory throughput on copies to and from accelerator devices it is necessary to have large amounts of memory being copied. This is usually not achievable when copying each dispersion measure trial individually.

A DmTrials object is instantiated with a shared pointer to a a DmTrialsMetadata object. This object contains information such as the DM, downsampling value and length of each DM trial to be stored in the DmTrials object.

The size of a DmTrials object is fixed at instantiation and cannot be changed afterwards. This means that DMs cannot be added or removed. To access the dispersion measure trial time series (DmTrial objects) contained within the DmTrials object one may either index the DmTrials object or iterator over it. An example of this is given below:

//Create a new DmTrials object as a shared pointer
auto dm_trials = DmTrials::make_shared(<DmTrialsMetadata shared pointer>, <MJD start of the first sample in each trial>)
//To access the nth trial we use the operator[] overload:
auto trial = (*dm_trials)[n]
//To further access the data in the trial, we simply iterate over it
for (auto const& x: trial)
{
...do something with x...
}
     A DmTrials object provides two important methods that allow the object to be used in building
     data processing pipelines, these are is_compatible and is_contiguous. The DmTrialsMetadata instance
     used to create the DmTrials instance will have a hash value associated with it.
     For DmTrials objects with the same DMs in the same order and with the same lengths and downsamplings,
     this hash value will be the same. The is_compatible method compares the value of this hash between two
     DmTrials instances and returns true if the hashes are the same. The is_contiguous method allows for the
     user to check if two DmTrials instances are contiguous in time.

Definition at line 62 of file DmTrials.h.

Constructor & Destructor Documentation

◆ DmTrials() [1/2]

template<typename Arch , typename T , typename Alloc>
ska::cheetah::data::DmTrials< Arch, T, Alloc >::DmTrials ( std::shared_ptr< DmTrialsMetadata metadata,
Mjd  start,
Alloc const &  allocator = Alloc() 
)

Construct a defined size DmTrials object

Definition at line 12 of file DmTrials.cpp.

13  : _metadata(std::move(metadata))
14  , _data((_metadata?_metadata->total_data_size():0), allocator)
15  , _start_time(std::move(start))
16 {
17  if (!_metadata || _metadata->size() == 0)
18  throw panda::Error("Empty DmTrialsMetadata passed to DmTrials constructor.");
19  _trials.reserve(_metadata->size());
20  auto it = _data.begin();
21  for (auto const& trial: *_metadata)
22  {
23  std::size_t const size = trial.size();
24  _trials.emplace_back(trial,it,it+size);
25  it+=size;
26  }
27 }
DmTrialsMetadata const & metadata() const
Return the trials meta data object.
Definition: DmTrials.cpp:53
ConstIterator begin() const
Iterators to device memory.
Definition: Series.cpp:67
std::size_t size() const
Return the number of DmTrials.
Definition: DmTrials.cpp:119
Here is the call graph for this function:

◆ DmTrials() [2/2]

template<typename Arch, typename NumericT, typename Alloc = typename DefaultAllocator<Arch,NumericT>::type>
template<typename OtherArch , typename OtherNumericT , typename OtherAlloc >
ska::cheetah::data::DmTrials< Arch, NumericT, Alloc >::DmTrials ( DmTrials< OtherArch, OtherNumericT, OtherAlloc > const &  ,
Alloc const &  allocator = Alloc() 
)

Construct a copy of the DmTrials data on another device

Member Function Documentation

◆ duration()

template<typename Arch , typename T , typename Alloc >
DmTrials< Arch, T, Alloc >::TimeType ska::cheetah::data::DmTrials< Arch, T, Alloc >::duration ( ) const

Return the time duration of the DmTrials.

Returns
A time duration

Definition at line 139 of file DmTrials.cpp.

140 {
141  return _metadata->duration();
142 }

◆ is_compatible()

template<typename Arch , typename T , typename Alloc >
bool ska::cheetah::data::DmTrials< Arch, T, Alloc >::is_compatible ( DmTrials< Arch, NumericT, Alloc > const &  other) const

Determines if another DmTrials object is compatible with this one.

Compatibility is determined by checking that both DmTrials objects have equivalent metadada. This implies that they have the same DM trial values with the same downsampling ratio in the same order.

Parameters
otherThe other DmTrials object
Returns
True if compatible, False otherwise.

Definition at line 125 of file DmTrials.cpp.

126 {
127  return *_metadata == *(other._metadata);
128 }

◆ is_contiguous()

template<typename Arch , typename T , typename Alloc >
bool ska::cheetah::data::DmTrials< Arch, T, Alloc >::is_contiguous ( DmTrials< Arch, NumericT, Alloc > const &  other) const

Determines if another DmTrials object is contiguous in time after this one.

Parameters
otherThe other DmTrials object
Returns
True if contiguous, False otherwise.

Definition at line 131 of file DmTrials.cpp.

132 {
133 
134  TimeType diff(pss::astrotypes::units::duration_cast<TimeType>(next._start_time - (_start_time + std::chrono::duration<double>(this->duration().value()))));
135  return diff < _metadata->fundamental_sampling_interval();
136 }

◆ operator[]()

template<typename Arch , typename T , typename Alloc >
DmTrials< Arch, T, Alloc >::DmTrialType & ska::cheetah::data::DmTrials< Arch, T, Alloc >::operator[] ( std::size_t  n)

Return reference to DmTrial instance.

Parameters
[in]nThe index of the DmTrial instance

Definition at line 71 of file DmTrials.cpp.

72 {
73  return _trials[n];
74 }

◆ start_time() [1/2]

template<typename Arch , typename T , typename Alloc >
DmTrials< Arch, T, Alloc >::Mjd const & ska::cheetah::data::DmTrials< Arch, T, Alloc >::start_time ( ) const
Returns
the absolute time the first time sample corresponds to

Definition at line 59 of file DmTrials.cpp.

60 {
61  return _start_time;
62 }

◆ start_time() [2/2]

template<typename Arch , typename T , typename Alloc >
void ska::cheetah::data::DmTrials< Arch, T, Alloc >::start_time ( Mjd  start_time)

Set the absolute start time.

Parameters
start_timeThe start time

Definition at line 65 of file DmTrials.cpp.

66 {
67  _start_time = start;
68 }

The documentation for this class was generated from the following files: