From 6d62e54a7b8f32bc68506ed6ddcaf000a871729d Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Wed, 29 Apr 2020 14:11:32 +0200 Subject: [PATCH] Rename read block size for sf_replay --- core-buffer/include/buffer_config.hpp | 2 +- sf-buffer/src/sf_replay.cpp | 28 +++++++++++++-------------- sf-buffer/src/sf_writer.cpp | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core-buffer/include/buffer_config.hpp b/core-buffer/include/buffer_config.hpp index 5d27dfd..443c360 100644 --- a/core-buffer/include/buffer_config.hpp +++ b/core-buffer/include/buffer_config.hpp @@ -23,7 +23,7 @@ namespace core_buffer { const std::string FILE_EXTENSION = ".h5"; // How many frames do we read at once during replay. - const size_t REPLAY_BLOCK_SIZE = 100; + const size_t REPLAY_READ_BLOCK_SIZE = 100; // Size of sf_buffer RB in elements. const size_t BUFFER_RB_SIZE = 1000; diff --git a/sf-buffer/src/sf_replay.cpp b/sf-buffer/src/sf_replay.cpp index f081303..5bd8c13 100644 --- a/sf-buffer/src/sf_replay.cpp +++ b/sf-buffer/src/sf_replay.cpp @@ -10,10 +10,10 @@ using namespace std; using namespace core_buffer; struct FileBufferMetadata { - uint64_t pulse_id[REPLAY_BLOCK_SIZE]; - uint64_t frame_index[REPLAY_BLOCK_SIZE]; - uint32_t daq_rec[REPLAY_BLOCK_SIZE]; - uint16_t n_received_packets[REPLAY_BLOCK_SIZE]; + uint64_t pulse_id[REPLAY_READ_BLOCK_SIZE]; + uint64_t frame_index[REPLAY_READ_BLOCK_SIZE]; + uint32_t daq_rec[REPLAY_READ_BLOCK_SIZE]; + uint16_t n_received_packets[REPLAY_READ_BLOCK_SIZE]; }; void load_data_from_file ( @@ -23,27 +23,27 @@ void load_data_from_file ( const size_t start_index) { - hsize_t b_image_dim[3] = {REPLAY_BLOCK_SIZE, 512, 1024}; + hsize_t b_image_dim[3] = {REPLAY_READ_BLOCK_SIZE, 512, 1024}; H5::DataSpace b_i_space (3, b_image_dim); - hsize_t b_i_count[] = {REPLAY_BLOCK_SIZE, 512, 1024}; + hsize_t b_i_count[] = {REPLAY_READ_BLOCK_SIZE, 512, 1024}; hsize_t b_i_start[] = {0, 0, 0}; b_i_space.selectHyperslab(H5S_SELECT_SET, b_i_count, b_i_start); hsize_t f_image_dim[3] = {FILE_MOD, 512, 1024}; H5::DataSpace f_i_space (3, f_image_dim); - hsize_t f_i_count[] = {REPLAY_BLOCK_SIZE, 512, 1024}; + hsize_t f_i_count[] = {REPLAY_READ_BLOCK_SIZE, 512, 1024}; hsize_t f_i_start[] = {start_index, 0, 0}; f_i_space.selectHyperslab(H5S_SELECT_SET, f_i_count, f_i_start); - hsize_t b_metadata_dim[2] = {REPLAY_BLOCK_SIZE, 1}; + hsize_t b_metadata_dim[2] = {REPLAY_READ_BLOCK_SIZE, 1}; H5::DataSpace b_m_space (2, b_metadata_dim); - hsize_t b_m_count[] = {REPLAY_BLOCK_SIZE, 1}; + hsize_t b_m_count[] = {REPLAY_READ_BLOCK_SIZE, 1}; hsize_t b_m_start[] = {0, 0}; b_m_space.selectHyperslab(H5S_SELECT_SET, b_m_count, b_m_start); hsize_t f_metadata_dim[2] = {FILE_MOD, 1}; H5::DataSpace f_m_space (2, f_metadata_dim); - hsize_t f_m_count[] = {REPLAY_BLOCK_SIZE, 1}; + hsize_t f_m_count[] = {REPLAY_READ_BLOCK_SIZE, 1}; hsize_t f_m_start[] = {start_index, 0}; f_m_space.selectHyperslab(H5S_SELECT_SET, f_m_count, f_m_start); @@ -88,7 +88,7 @@ void sf_replay ( { auto metadata_buffer = make_unique(); auto image_buffer = make_unique( - REPLAY_BLOCK_SIZE * MODULE_N_PIXELS); + REPLAY_READ_BLOCK_SIZE * MODULE_N_PIXELS); auto path_suffixes = BufferUtils::get_path_suffixes(start_pulse_id, stop_pulse_id); @@ -115,7 +115,7 @@ void sf_replay ( for (size_t file_index_offset=0; file_index_offset < FILE_MOD; - file_index_offset += REPLAY_BLOCK_SIZE) + file_index_offset += REPLAY_READ_BLOCK_SIZE) { auto start_time = chrono::steady_clock::now(); @@ -131,7 +131,7 @@ void sf_replay ( cout << "sf_replay:batch_read_ms " << ms_duration << endl; - for (size_t i_frame=0; i_frame < REPLAY_BLOCK_SIZE; i_frame++) { + for (size_t i_frame=0; i_frame < REPLAY_READ_BLOCK_SIZE; i_frame++) { ModuleFrame module_frame = { metadata_buffer->pulse_id[i_frame], @@ -241,7 +241,7 @@ int main (int argc, char *argv[]) { auto ctx = zmq_ctx_new(); auto socket = zmq_socket(ctx, ZMQ_PUSH); - const int sndhwm = REPLAY_BLOCK_SIZE; + const int sndhwm = REPLAY_READ_BLOCK_SIZE; if (zmq_setsockopt(socket, ZMQ_SNDHWM, &sndhwm, sizeof(sndhwm)) != 0) throw runtime_error(strerror (errno)); diff --git a/sf-buffer/src/sf_writer.cpp b/sf-buffer/src/sf_writer.cpp index 98abebf..ff108aa 100644 --- a/sf-buffer/src/sf_writer.cpp +++ b/sf-buffer/src/sf_writer.cpp @@ -24,7 +24,7 @@ void receive_replay( void *sockets[n_modules]; for (size_t i = 0; i < n_modules; i++) { sockets[i] = zmq_socket(ctx, ZMQ_PULL); - int rcvhwm = REPLAY_BLOCK_SIZE; + int rcvhwm = REPLAY_READ_BLOCK_SIZE; if (zmq_setsockopt(sockets[i], ZMQ_RCVHWM, &rcvhwm, sizeof(rcvhwm)) != 0) { throw runtime_error(strerror(errno));