-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorporating skycleaver functionality to skyweaver #20
base: pipeline_dev
Are you sure you want to change the base?
Changes from 20 commits
81bad82
efeffb7
63c854b
0201f7e
331c1cf
5dc0bf4
ccc6ebb
a823587
e14fc64
4f72d08
36b1271
b36cb9f
4826368
4aec59b
2462dad
c55bf3c
819ee96
63b85f8
510fc01
4ae82ab
2787d00
6a33108
bbd9fd1
456719a
48adc14
0cfe1f9
ee35ae2
52b1ab3
4bf4df1
70647a9
0dde728
5ca8add
8fbb204
0595fa9
00fa137
e697b31
a1a2c94
cbaf03b
820efb9
49c966a
ff71497
45964ca
8610cab
112a857
13047bb
4f15b64
fbb980b
03b92c5
4242cf9
6675ae6
ab6b13e
0d8e6aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,23 @@ struct DescribedVector { | |
_vector.resize(calculate_nelements()); | ||
} | ||
|
||
/** | ||
* @brief Construct a new Described Vector object of specific size | ||
* | ||
* @param sizes The sizes of the dimensions (must match the number of | ||
* dimensions) | ||
*/ | ||
DescribedVector(std::initializer_list<std::size_t> sizes, value_type default_value) | ||
: _dms_stale(true), _frequencies_stale(true), _sizes(sizes), | ||
_dims{dims...}, _tsamp(0.0) | ||
{ | ||
if(_sizes.size() != sizeof...(dims)) { | ||
throw std::invalid_argument( | ||
"Number of sizes must match number of dimensions"); | ||
} | ||
_vector.resize(calculate_nelements(), default_value); | ||
} | ||
|
||
/** | ||
* @brief Destroy the Described Vector object | ||
* | ||
|
@@ -213,6 +230,12 @@ struct DescribedVector { | |
*/ | ||
auto const& operator[](std::size_t idx) const { return _vector[idx]; } | ||
|
||
|
||
// also the at() method | ||
auto& at(std::size_t idx) { return _vector[idx]; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What purpose does this serve? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is another function in std::vector that I tried to mimic here. Not required but good to have. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After discussion, we decided to keep this in. |
||
auto const& at(std::size_t idx) const { return _vector[idx]; } | ||
|
||
|
||
/** | ||
* @brief Resize the dimensions of the vector | ||
* | ||
|
@@ -648,7 +671,7 @@ using BTFPowersH = DescribedVector<thrust::host_vector<T, PinnedAllocator<T>>, | |
template <typename T> | ||
using BTFPowersD = | ||
DescribedVector<thrust::device_vector<T>, BeamDim, TimeDim, FreqDim>; | ||
// Incoherent dedisperser outputs | ||
// Incoherent dedisperser outputs, also used for skycleaver | ||
template <typename T> | ||
using TDBPowersH = DescribedVector<thrust::host_vector<T, PinnedAllocator<T>>, | ||
TimeDim, | ||
|
@@ -667,6 +690,13 @@ template <typename T> | |
using FPAStatsD = | ||
DescribedVector<thrust::device_vector<T>, FreqDim, PolnDim, AntennaDim>; | ||
|
||
//skycleaver output vectors | ||
|
||
template <typename T> | ||
using TFPowersH = DescribedVector<thrust::host_vector<T, PinnedAllocator<T>>, | ||
TimeDim, | ||
FreqDim>; | ||
|
||
} // namespace skyweaver | ||
|
||
#endif // SKYWEAVER_DESCRIBEDVECTORS_HPP |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,72 @@ | |
|
||
namespace skyweaver | ||
{ | ||
|
||
struct MultiFileWriterConfig { | ||
std::size_t header_size; | ||
std::size_t max_file_size; | ||
std::string stokes_mode; | ||
std::string output_dir; | ||
std::string base_output_dir; | ||
std::string prefix; | ||
std::string extension; | ||
std::string output_basename; | ||
|
||
MultiFileWriterConfig() | ||
: header_size(4096), max_file_size(2147483647), stokes_mode("I"), | ||
output_dir("default/"), prefix(""), extension("") {}; | ||
MultiFileWriterConfig(std::size_t header_size, | ||
std::size_t max_file_size, | ||
std::string stokes_mode, | ||
std::string output_dir, | ||
std::string prefix, | ||
std::string extension) | ||
: header_size(header_size), max_file_size(max_file_size), | ||
stokes_mode(stokes_mode), output_dir(output_dir), prefix(prefix), | ||
extension(extension), output_basename("") {}; | ||
MultiFileWriterConfig(MultiFileWriterConfig const& other) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for implementing these constructors? The class member variables are all either trivial types or types with RAII behaviour, so you shouldn't need to write custom copy constructors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was originally not RAII, but now they are, but the constructors were left over. I will delete them. |
||
: header_size(other.header_size), max_file_size(other.max_file_size), | ||
stokes_mode(other.stokes_mode), output_dir(other.output_dir), | ||
base_output_dir(other.base_output_dir), prefix(other.prefix), | ||
extension(other.extension), output_basename(other.output_basename) {}; | ||
MultiFileWriterConfig& operator=(MultiFileWriterConfig const& other) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see previous comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
{ | ||
header_size = other.header_size; | ||
max_file_size = other.max_file_size; | ||
stokes_mode = other.stokes_mode; | ||
output_dir = other.output_dir; | ||
prefix = other.prefix; | ||
extension = other.extension; | ||
output_basename = other.output_basename; | ||
base_output_dir = other.base_output_dir; | ||
return *this; | ||
} | ||
|
||
std::string to_string() | ||
{ | ||
return "header_size: " + std::to_string(header_size) + | ||
", max_file_size: " + std::to_string(max_file_size) + | ||
", stokes_mode: " + stokes_mode + ", output_dir: " + output_dir + | ||
", prefix: " + prefix + ", extension: " + extension + | ||
", output_basename: " + output_basename + | ||
", base_output_dir: " + base_output_dir; | ||
} | ||
}; | ||
/** | ||
* @brief A class for handling writing of DescribedVectors | ||
* | ||
*/ | ||
template <typename VectorType> | ||
class MultiFileWriter | ||
{ | ||
public: | ||
using CreateStreamCallBackType = | ||
std::function<std::unique_ptr<FileOutputStream>( | ||
MultiFileWriterConfig const&, | ||
ObservationHeader const&, | ||
VectorType const&, | ||
std::size_t)>; | ||
|
||
public: | ||
/** | ||
* @brief Construct a new Multi File Writer object | ||
|
@@ -27,7 +86,13 @@ class MultiFileWriter | |
* @param tag A string tag to be added to the file name | ||
* (used to avoid clashing file names). | ||
*/ | ||
MultiFileWriter(PipelineConfig const& config, std::string tag = ""); | ||
// MultiFileWriter(PipelineConfig const& config, std::string tag = ""); | ||
MultiFileWriter(PipelineConfig const& config, | ||
std::string tag, | ||
CreateStreamCallBackType create_stream_callback); | ||
MultiFileWriter(MultiFileWriterConfig config, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this pass by value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be const& or you will get a double copy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can't be const as I will edit some values inside, but it can be pass by reference. |
||
std::string tag, | ||
CreateStreamCallBackType create_stream_callback); | ||
MultiFileWriter(MultiFileWriter const&) = delete; | ||
|
||
/** | ||
|
@@ -62,17 +127,19 @@ class MultiFileWriter | |
*/ | ||
bool operator()(VectorType const& stream_data, std::size_t stream_idx = 0); | ||
|
||
bool write(VectorType const& stream_data, std::size_t stream_idx = 0); | ||
|
||
private: | ||
bool has_stream(std::size_t stream_idx); | ||
FileOutputStream& create_stream(VectorType const& stream_data, | ||
std::size_t stream_idx); | ||
std::size_t stream_idx); | ||
std::string get_output_dir(VectorType const& stream_data, | ||
std::size_t stream_idx); | ||
std::string get_basefilename(VectorType const& stream_data, | ||
std::size_t stream_idx); | ||
std::string get_extension(VectorType const& stream_data); | ||
|
||
PipelineConfig const& _config; | ||
CreateStreamCallBackType _create_stream_callback; | ||
MultiFileWriterConfig _config; | ||
std::string _tag; | ||
ObservationHeader _header; | ||
std::map<std::size_t, std::unique_ptr<FileOutputStream>> _file_streams; | ||
|
@@ -83,5 +150,6 @@ class MultiFileWriter | |
} // namespace skyweaver | ||
|
||
#include "skyweaver/detail/MultiFileWriter.cu" | ||
#include "skyweaver/detail/file_writer_callbacks.cpp" | ||
|
||
#endif // SKYWEAVER_MULTIFILEWRITER_CUH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++ standard should be set in compiler_settings.cmake with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this and added
set (CMAKE_CXX_STANDARD 20)