Skip to content
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

Open
wants to merge 52 commits into
base: pipeline_dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
81bad82
First draft of the skycleaver implementation
vivekvenkris Aug 22, 2024
efeffb7
Change source name and position from default values in header
vivekvenkris Aug 22, 2024
63c854b
seek to the correct timestamp
vivekvenkris Sep 3, 2024
0201f7e
use uint8 for filterbank output
vivekvenkris Sep 4, 2024
331c1cf
Correct frequency tagging of tdb outputs
vivekvenkris Sep 4, 2024
5dc0bf4
swap beam and dm loops, convert signed to unsigned by rescaling data
vivekvenkris Sep 4, 2024
ccc6ebb
Merge commit '218f424562ce85a08af871551ef01183a00f91e0' into skycleaver
vivekvenkris Sep 4, 2024
a823587
add has key, get_or_default methods to header
vivekvenkris Sep 11, 2024
e14fc64
get-> get_or_default for few keys
vivekvenkris Sep 11, 2024
4f72d08
add basefilename to multifilewriterconfig and change it as needed in …
vivekvenkris Sep 11, 2024
36b1271
reuse bytes_seeking
vivekvenkris Sep 11, 2024
b36cb9f
reflect file writer callback changes in tester
vivekvenkris Sep 11, 2024
4826368
fix paths and filenames
vivekvenkris Sep 19, 2024
4aec59b
check for both OBS_FREQ & OBS_FREQUENCY
vivekvenkris Sep 19, 2024
2462dad
proper naming, more header parameters to read from dada files
vivekvenkris Sep 20, 2024
c55bf3c
get mjd_start from utc_offset
vivekvenkris Sep 20, 2024
819ee96
fix snake naming bug
vivekvenkris Sep 23, 2024
63b85f8
actually fix snake naming bug
vivekvenkris Sep 23, 2024
510fc01
use long double for times, incorporate downstream changes for half ch…
vivekvenkris Sep 25, 2024
4ae82ab
fixed formatting on MultiFileWriter.cuh
Sep 26, 2024
2787d00
formatting
Sep 26, 2024
6a33108
Add .tmp suffix to output filenames, and remove it when they are closed.
coclar Sep 26, 2024
bbd9fd1
Merge pull request #21 from hefehr/temporary_filenames
ewanbarr Sep 27, 2024
456719a
cleave only required samples
vivekvenkris Sep 30, 2024
48adc14
cleave only required dms and beams, code review changes
vivekvenkris Oct 2, 2024
0cfe1f9
seek to start sample after dedisp delay correction
vivekvenkris Oct 3, 2024
ee35ae2
CDD all data including overlap
vivekvenkris Oct 3, 2024
52b1ab3
fix FFT shift, change left over gulps -> fft_size where appropriate
vivekvenkris Oct 7, 2024
4bf4df1
Make skycleaver a CPP application
vivekvenkris Oct 11, 2024
70647a9
correctly set frequencies for described vectors, CDD, IDD
vivekvenkris Oct 11, 2024
0dde728
Added multiple tiling plot code, targets file, mosaic command file, p…
vishnubk Oct 21, 2024
5ca8add
removed unused class
vishnubk Oct 21, 2024
8fbb204
changed python delay creation code to plot, even if no known beams ar…
vishnubk Nov 6, 2024
0595fa9
Remove .bdm.db files and update .gitignore
vishnubk Nov 6, 2024
00fa137
typo fixes in include flags, migration from cuh to hpp
vishnubk Nov 6, 2024
e697b31
minor merge changes
vivekvenkris Nov 25, 2024
a1a2c94
get header values from header instead of user
vivekvenkris Nov 26, 2024
cbaf03b
dirty pass on scaling change
Nov 28, 2024
820efb9
compiling now and beamformer tests running
Nov 28, 2024
49c966a
linear pol output and actual beam positions in skycleaver
vivekvenkris Dec 12, 2024
ff71497
fix filename convention
vivekvenkris Dec 12, 2024
45964ca
draft documentation
vivekvenkris Dec 17, 2024
8610cab
Revert "compiling now and beamformer tests running"
vivekvenkris Dec 22, 2024
112a857
Revert "dirty pass on scaling change"
vivekvenkris Dec 22, 2024
13047bb
segregate filterbanks in beam directories
vivekvenkris Jan 2, 2025
4f15b64
Fix for incorrect S-band frequencies being reported in filenames due …
coclar Jan 29, 2025
fbb980b
Merge pull request #24 from hefehr/filename_freq_fix
ewanbarr Jan 29, 2025
03b92c5
Fix for integer overflow in SkyCleaver while computing expected bridg…
coclar Feb 13, 2025
4242cf9
Added command-line option for computing/outputing voltage statistics
coclar Feb 20, 2025
6675ae6
Added command-line option to disable writing the incoherent beam
coclar Feb 20, 2025
ab6b13e
Merge pull request #26 from hefehr/optional_outputs
ewanbarr Mar 5, 2025
0d8e6aa
Merge pull request #25 from hefehr/skycleaver_freq_fix
ewanbarr Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmake/compiler_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RELEASE")
endif ()

#set(CMAKE_VERBOSE_MAKEFILE 1)

# Set compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fopenmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fopenmp -std=gnu++20")
Copy link
Contributor

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

set (CMAKE_CXX_STANDARD 20)

Copy link
Member Author

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)


set(ARCH "broadwell" CACHE STRING "target architecture (-march=native, x86-64), defautls to broadwell")

Expand Down
12 changes: 12 additions & 0 deletions cpp/skyweaver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ set(skyweaver_src
src/Timer.cpp
src/Transposer.cu
src/WeightsManager.cu
src/SkyCleaver.cu
src/SigprocHeader.cpp

)

set(skyweaver_inc
Expand All @@ -38,6 +41,8 @@ set(skyweaver_inc
Timer.hpp
Transposer.cuh
WeightsManager.cuh
MultiFileWriter.cuh
SigprocHeader.hpp
)

set(SKYWEAVER_LIBRARIES ${CMAKE_PROJECT_NAME} ${DEPENDENCY_LIBRARIES})
Expand Down Expand Up @@ -106,6 +111,13 @@ target_link_libraries(skyweavercpp
OpenMP::OpenMP_CXX)
install(TARGETS skyweavercpp DESTINATION bin)

cuda_add_executable(skycleaver src/skycleaver_cli.cu)
target_link_libraries(skycleaver
${SKYWEAVER_LIBRARIES}
${DEPENDENCY_LIBRARIES}
OpenMP::OpenMP_CXX)
install(TARGETS skycleaver DESTINATION bin)

#install (TARGETS ... DESTINATION bin)
#install (TARGETS ${CMAKE_PROJECT_NAME}
# RUNTIME DESTINATION bin
Expand Down
32 changes: 31 additions & 1 deletion cpp/skyweaver/DescribedVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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]; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What purpose does this serve?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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
*
Expand Down Expand Up @@ -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,
Expand All @@ -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
21 changes: 21 additions & 0 deletions cpp/skyweaver/Header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ class Header
template <typename T>
T get(char const* key) const;


/**
* @brief Get a value from the header or return a default value
*
* @param key An ASCII key (the name of the value to get)
* @param[in] default_value The default value to return if the key is not found
*
* @tparam T The data type of the parameter to be read
*
* @return The value corresponding to the given key or the default value
*/
template <typename T>
T get_or_default(char const* key, T default_value) const{
if(has_key(key)){
return get<T>(key);
}
BOOST_LOG_TRIVIAL(warning) << "Header did not have key: " << key << ". Returning default value: " << default_value;
return default_value;
}

/**
* @brief Set a value in the header
*
Expand Down Expand Up @@ -72,6 +92,7 @@ class Header

private:
void fetch_header_string(char const* key) const;
bool has_key(char const* key) const;

private:
psrdada_cpp::RawBytes& _header;
Expand Down
43 changes: 0 additions & 43 deletions cpp/skyweaver/MultiBeamWriter.hpp

This file was deleted.

5 changes: 5 additions & 0 deletions cpp/skyweaver/MultiFileReader.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class skyweaver::MultiFileReader
std::size_t _dada_header_size;
std::size_t _total_size;
bool _is_open;


void read_header(std::vector<char>& headerBytes);
void check_contiguity();
Expand All @@ -49,14 +50,18 @@ class skyweaver::MultiFileReader
void open_previous();
void close();
void seekg(long pos, std::ios_base::seekdir dir = std::ios_base::beg);

std::size_t tellg() const;
bool eof() const;
bool good() const;
bool can_read(std::size_t bytes) const;
std::streamsize read(char* raw_ptr, std::streamsize bytes);


bool is_open() const;
std::size_t
safe_read(std::ifstream& input_stream, char* buffer, std::size_t nbytes);
std::vector<std::string> const& get_dada_files() const;

std::size_t get_total_size() const;

Expand Down
79 changes: 75 additions & 4 deletions cpp/skyweaver/MultiFileWriter.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,75 @@

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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment

Copy link
Member Author

Choose a reason for hiding this comment

The 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
Expand All @@ -27,7 +89,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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this pass by value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be const& or you will get a double copy

Copy link
Member Author

Choose a reason for hiding this comment

The 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;

/**
Expand Down Expand Up @@ -62,17 +130,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;
Expand All @@ -83,5 +153,6 @@ class MultiFileWriter
} // namespace skyweaver

#include "skyweaver/detail/MultiFileWriter.cu"
#include "skyweaver/detail/file_writer_callbacks.cpp"

#endif // SKYWEAVER_MULTIFILEWRITER_CUH
Loading