File abstract_scatter_device.hpp
This file contains the interface definition for all scattering devices and implements an abstract scattering device from which all other devices are derived.
- Author
Benjamin Lindner ben@benlabs.net
- Version
See VERSION in CMakeLists.txt
- Copyright
GNU General Public License
-
template<typename Data>
class concurrent_queue - #include <abstract_scatter_device.hpp>
Efficent Thread-safe version of a queue
-
class AbstractScatterDevice : public IScatterDevice
- #include <abstract_scatter_device.hpp>
Base class for scatter devices (currently for CPU based calculations).
This class provides the common runtime structure for calculating scattering patterns, specifically for CPU-based implementations.
Subclassed by AbstractVectorsScatterDevice, MPCylinderScatterDevice, MPSphereScatterDevice
Public Functions
-
AbstractScatterDevice(boost::mpi::communicator allcomm, boost::mpi::communicator partitioncomm, Sample &sample, std::vector<CartesianCoor3D> vectors, size_t NAF, boost::asio::ip::tcp::endpoint fileservice_endpoint, boost::asio::ip::tcp::endpoint monitorservice_endpoint)
Constructs the abstract scatter device.
- Parameters:
allcomm – The MPI communicator for all participating ranks.
partitioncomm – The MPI communicator for the local rank partition.
sample – The sample data (see
Sampleclass), including set of atom coordinates and types.vectors – The list of q-vectors assigned to this device.
NAF – The total number of atoms in each frame.
fileservice_endpoint – Network endpoint for the HDF5 writer service.
monitorservice_endpoint – Network endpoint for the monitoring service.
-
~AbstractScatterDevice()
-
virtual void run() override
Main entry point to start the scattering computation for this device.
This method orchestrates the entire top-level workflow for this device. It executes a sequence of operations for all assigned q-vectors:
Performs memory checks.
Calls
stage_data()to prepare necessary data.Calls
runner()to execute the main computation loop over all q-vectors.Finalizes service clients.
Protected Functions
-
virtual void stage_data() = 0
Pure virtual function to prepare data for computation.
Derived classes must implement this to load or rearrange data (e.g., coordinates) before the calculation begins.
-
virtual void compute() = 0
Pure virtual function for the main calculation step.
This function is called once per q-vector and is responsible for generating and dispatching the work items that the omp threads will execute.
-
void next()
Compute next Q-vector.
-
void write()
-
virtual void runner() override
-
inline virtual tf::Taskflow create_flow()
-
inline virtual void print_pre_stage_info()
-
inline virtual void print_post_stage_info()
-
inline virtual void print_pre_runner_info()
-
inline virtual void print_post_runner_info()
-
virtual bool ram_check()
-
virtual bool status() override
If there are still Q-vectors left to compute.
- Returns:
0 if there are still Q-vectors left to compute, else 1
-
virtual double progress() override
Protected Attributes
-
tf::Taskflow flow_
-
boost::mpi::communicator allcomm_
-
boost::mpi::communicator partitioncomm_
-
std::vector<CartesianCoor3D> vectors_
-
size_t current_vector_
-
std::shared_ptr<MonitorClient> p_monitor_
-
std::shared_ptr<HDF5WriterClient> p_hdf5writer_
-
size_t NN
-
size_t NF
-
size_t NA
-
fftw_complex *atfinal_ = nullptr
-
ScatterFactors scatterfactors
-
AbstractScatterDevice(boost::mpi::communicator allcomm, boost::mpi::communicator partitioncomm, Sample &sample, std::vector<CartesianCoor3D> vectors, size_t NAF, boost::asio::ip::tcp::endpoint fileservice_endpoint, boost::asio::ip::tcp::endpoint monitorservice_endpoint)