Class DataBlock
Defined in File DataBlock.h
Inheritance Relationships
Derived Types
public ska::pst::smrb::DataBlockAccessor
(Class DataBlockAccessor)public ska::pst::smrb::DataBlockCreate
(Class DataBlockCreate)
Class Documentation
-
class DataBlock
Abstract base class that provides an Object Oriented interface to a PSRDADA Shared Memory Ring Buffer (SMRB).
Subclassed by ska::pst::smrb::DataBlockAccessor, ska::pst::smrb::DataBlockCreate
Public Functions
-
explicit DataBlock(const std::string &key_string)
Construct a new DataBlock with specified key.
- Parameters
key_string – 4 character hexidecimal PSRDADA key
-
virtual ~DataBlock() = default
Destroy the Data Block object.
-
virtual void connect(int timeout)
Attempt to connect to the existing SMRB within the specified timeout.
- Parameters
timeout – timeout
-
virtual void disconnect()
Disconnect from the SMRB.
-
void page()
page the buffers from the data block into RAM by writing zero to each one
-
inline uint64_t get_data_bufsz() const
Return the size of DataBlock elements.
- Returns
const uint64_t size of data block element in bytes
-
inline uint64_t get_data_nbufs() const
Return the number of DataBlock elements.
- Returns
const uint64_t number of DataBlock elements
-
inline uint64_t get_header_bufsz() const
Return the size of HeaderBlock elements.
- Returns
const uint64_t size of HeaderBlock elements in bytes
-
inline uint64_t get_header_nbufs() const
Return the number of HeaderBlock elements.
- Returns
const uint64_t number of HeaderBlock elements
-
inline int get_device()
Return the CUDA device ID for the data block. If the DataBlock buffers exist in CUDA memory, the device will be >=0.
- Returns
int CUDA device on which the DataBlock buffers reside, -1 if in CPU memory
-
int get_nreaders()
Return the number of readers required by the DataBlock.
- Returns
int number of readers
-
void register_cuda()
Register the DataBlock buffers with the CUDA driver. Registration of the DataBlock buffers enable more efficient RDMA transfers between CPU and GPU RAM.
-
inline bool is_connected() const
Check if data block is connected.
- Returns
true data block is connected
- Returns
false data block is not connected
-
uint64_t get_header_bufs_written()
Get the number of buffers written to the header block.
- Returns
uint64_t number of header buffers written
-
uint64_t get_data_bufs_written()
Get the number of buffers written to the data block.
- Returns
uint64_t number of data buffers written
-
uint64_t get_header_bufs_read()
Get the number of buffers read from the header block.
- Returns
uint64_t number of header buffers read
-
uint64_t get_data_bufs_read()
Get the total number of buffers read in the data block.
- Returns
uint64_t number of data buffers read
-
uint64_t get_header_bufs_clear()
Get the number of clear header buffers.
- Returns
uint64_t number of clear header buffers
-
uint64_t get_data_bufs_clear()
Get the number of clear data buffers.
- Returns
uint64_t number of clear data buffers
-
uint64_t get_header_bufs_full()
Get the number of full header buffers.
- Returns
uint64_t number of full header buffers
-
uint64_t get_data_bufs_full()
Get the number of full data buffers.
- Returns
uint64_t number of full data buffers
-
uint64_t get_header_bufs_available()
Get the number of empty header buffers.
- Returns
uint64_t number of empty header buffers
-
uint64_t get_data_bufs_available()
Get the number of empty data buffers.
- Returns
uint64_t number of empty data buffers
-
uint64_t get_data_write_xfer()
Return the current observation number of the writer.
- Returns
uint64_t current observation of the writer to the DataBlock
-
uint64_t get_data_read_xfer()
Return the current observation number of reader.
- Returns
uint64_t current observation number of the reader
Public Static Functions
-
static key_t parse_psrdada_key(const std::string &key)
Parse the provided string as a PSRDADA data block key. If valid assign the data_block_key and header_block_key, else throw runtime_exception.
- Parameters
key – string representation of PSRDADA key
- Returns
key_t encoded key_t
Protected Functions
-
void check_connected(bool expected)
helper method that throws runtime_error if connected does not match expected value
-
void on_connect()
Populate connected data block properties.
-
void on_disconnect()
Reset data block properties to their default values.
Protected Attributes
-
ipcbuf_t header_block
pointer to PSRDADA header block
-
ipcio_t data_block
pointer to PSRDADA data block
-
uint64_t header_bufsz = {0}
Size of a header_block buffer in bytes.
-
uint64_t header_nbufs = {0}
Number of header_block buffers.
-
uint64_t data_bufsz = {0}
Size of a data_block buffer in bytes.
-
uint64_t data_nbufs = {0}
Number of data_block buffers.
-
int device_id = {-1}
CUDA device index on which the data_block buffers are allocated, -1 if on host.
-
int nreaders = {0}
Number of readers for the data block.
-
bool connected = {false}
True if connected to the PSRDADA SMRB.
-
key_t data_block_key
hexidecimal PSRDADA key that identifies the IPC shared memory segment for the data_block
-
key_t header_block_key
hexidecimal PSRDADA key that identifies the IPC shared memory segment for the header_block
-
explicit DataBlock(const std::string &key_string)