mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-01 13:22:24 +02:00
Moved live writer to std-det-writer
This commit is contained in:
+1
-1
@@ -38,5 +38,5 @@ add_subdirectory("std-udp-sync")
|
||||
add_subdirectory("jf-assembler")
|
||||
#add_subdirectory("sf-stream")
|
||||
#add_subdirectory("sf-writer")
|
||||
add_subdirectory("jf-live-writer")
|
||||
add_subdirectory("std-det-writer")
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
find_package(MPI REQUIRED)
|
||||
# Because of openmpi.
|
||||
add_definitions(-DOMPI_SKIP_MPICXX)
|
||||
|
||||
file(GLOB SOURCES
|
||||
src/*.cpp)
|
||||
|
||||
add_library(jf-live-writer-lib STATIC ${SOURCES})
|
||||
target_include_directories(jf-live-writer-lib
|
||||
PUBLIC include/
|
||||
SYSTEM ${MPI_INCLUDE_PATH})
|
||||
|
||||
target_link_libraries(jf-live-writer-lib
|
||||
external
|
||||
core-buffer-lib
|
||||
${MPI_LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(jf-live-writer src/main.cpp)
|
||||
|
||||
|
||||
if (USE_EIGER)
|
||||
set (LIB_NAME_UDP_RECV "eiger_live_writer")
|
||||
else()
|
||||
set (LIB_NAME_UDP_RECV "jf_live_writer")
|
||||
endif()
|
||||
|
||||
set_target_properties(jf-live-writer PROPERTIES OUTPUT_NAME ${LIB_NAME_UDP_RECV})
|
||||
|
||||
target_link_libraries(jf-live-writer
|
||||
jf-live-writer-lib
|
||||
zmq
|
||||
hdf5
|
||||
rt
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(test/)
|
||||
@@ -0,0 +1,31 @@
|
||||
find_package(MPI REQUIRED)
|
||||
# Because of openmpi.
|
||||
add_definitions(-DOMPI_SKIP_MPICXX)
|
||||
|
||||
file(GLOB SOURCES
|
||||
src/*.cpp)
|
||||
|
||||
add_library(std-det-writer-lib STATIC ${SOURCES})
|
||||
target_include_directories(std-det-writer-lib
|
||||
PUBLIC include/
|
||||
SYSTEM ${MPI_INCLUDE_PATH})
|
||||
|
||||
target_link_libraries(std-det-writer-lib
|
||||
external
|
||||
core-buffer-lib
|
||||
${MPI_LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(std-det-writer src/main.cpp)
|
||||
|
||||
set_target_properties(std-det-writer PROPERTIES OUTPUT_NAME std_det_writer)
|
||||
|
||||
target_link_libraries(std-det-writer
|
||||
std-det-writer-lib
|
||||
zmq
|
||||
hdf5
|
||||
rt
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(test/)
|
||||
@@ -1,4 +1,4 @@
|
||||
# jf-live-writer
|
||||
# std-det-writer
|
||||
|
||||
This component is a PHDF5 based MPI writer for high performance detectors
|
||||
that need more than 2GB/s of write speed. It parallelizes the HDF5 writing to
|
||||
@@ -4,7 +4,7 @@ COPY . /sf_daq_buffer/
|
||||
|
||||
RUN mkdir /sf_daq_buffer/build && \
|
||||
cd /sf_daq_buffer/build && \
|
||||
cmake3 -DBUILD_JF_LIVE_WRITER=ON .. && \
|
||||
make jf-live-writer
|
||||
cmake3 .. && \
|
||||
make std-det-writer
|
||||
|
||||
WORKDIR /sf_daq_buffer/build
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef SF_DAQ_BUFFER_UDPRECVCONFIG_HPP
|
||||
#define SF_DAQ_BUFFER_UDPRECVCONFIG_HPP
|
||||
|
||||
|
||||
#include <rapidjson/istreamwrapper.h>
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
struct UdpRecvConfig {
|
||||
static UdpRecvConfig from_json_file(const std::string& filename) {
|
||||
std::ifstream ifs(filename);
|
||||
rapidjson::IStreamWrapper isw(ifs);
|
||||
rapidjson::Document config_parameters;
|
||||
config_parameters.ParseStream(isw);
|
||||
|
||||
return {
|
||||
config_parameters["detector_name"].GetString(),
|
||||
config_parameters["detector_type"].GetString(),
|
||||
config_parameters["n_modules"].GetInt(),
|
||||
config_parameters["start_udp_port"].GetInt(),
|
||||
};
|
||||
}
|
||||
|
||||
const std::string detector_name;
|
||||
const std::string detector_type;
|
||||
const int n_modules;
|
||||
const int start_udp_port;
|
||||
};
|
||||
|
||||
|
||||
#endif //SF_DAQ_BUFFER_UDPRECVCONFIG_HPP
|
||||
@@ -40,7 +40,9 @@ int main (int argc, char *argv[])
|
||||
auto receiver = BufferUtils::connect_socket(
|
||||
ctx, config.detector_name, "writer-agent");
|
||||
|
||||
RamBuffer ram_buffer(config.detector_name, config.n_modules);
|
||||
const size_t IMAGE_N_BYTES = 12;
|
||||
RamBuffer image_buffer(config.detector_name + "_assembler",
|
||||
sizeof(ImageMetadata), IMAGE_N_BYTES, 1, RAM_BUFFER_N_SLOTS);
|
||||
|
||||
JFH5Writer writer(config);
|
||||
WriterStats stats(config.detector_name);
|
||||
@@ -60,9 +62,17 @@ int main (int argc, char *argv[])
|
||||
stats.start_run(meta);
|
||||
}
|
||||
|
||||
// i_image == n_images -> end of run.
|
||||
if (meta.i_image == meta.n_images) {
|
||||
writer.close_run();
|
||||
|
||||
stats.end_run();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fair distribution of images among writers.
|
||||
if (meta.i_image % n_writers == i_writer) {
|
||||
char* data = ram_buffer.get_slot_data(meta.image_metadata.pulse_id);
|
||||
char* data = ram_buffer.get_slot_data(meta.image_metadata.id);
|
||||
|
||||
stats.start_image_write();
|
||||
writer.write_data(meta.run_id, meta.i_image, data);
|
||||
@@ -74,11 +84,5 @@ int main (int argc, char *argv[])
|
||||
writer.write_meta(meta.run_id, meta.i_image, meta.image_metadata);
|
||||
}
|
||||
|
||||
// i_image + 1 == meta.n_images -> we received the last image.
|
||||
if (meta.i_image+1 == meta.n_images) {
|
||||
writer.close_run();
|
||||
|
||||
stats.end_run();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user