LCI v2.0.0-dev
For Asynchronous Multithreaded Communication
Loading...
Searching...
No Matches
lci::data_t Struct Reference

A generic type for describing or holding data. More...

#include <lci.hpp>

Collaboration diagram for lci::data_t:
[legend]

Public Types

enum  type_t { LCI_DATA_TYPE_NONE , LCI_DATA_TYPE_SCALAR , LCI_DATA_TYPE_BUFFER , LCI_DATA_TYPE_BUFFERS }
 
enum class  get_semantic_t { move , copy , view }
 Enum class of get semantic. More...
 

Public Member Functions

 data_t ()
 
 data_t (buffer_t buffer_, bool own_data_=false)
 
 data_t (buffers_t buffers_, bool own_data_=false)
 
 data_t (size_t size, allocator_base_t *allocator=nullptr)
 
 data_t (size_t sizes[], int count, allocator_base_t *allocator=nullptr)
 
 data_t (const data_t &other)
 
 data_t (data_t &&other)
 
data_toperator= (data_t other)
 
type_t get_type () const
 
void set_type (type_t type_)
 
bool get_own_data () const
 
void set_own_data (bool own_data_)
 
bool is_scalar () const
 
bool is_buffer () const
 
bool is_buffers () const
 
void copy_from (const void *data_, size_t size, allocator_base_t *allocator_=nullptr)
 
void copy_from (const buffers_t &buffers_, allocator_base_t *allocator_=nullptr)
 
template<typename T>
get_scalar () const
 Get the scalar data from the data object.
 
buffer_t get_buffer (get_semantic_t semantic=get_semantic_t::move)
 Get the buffer from the data object.
 
size_t get_buffers_count () const
 Get the number of buffers from the data object.
 
buffers_t get_buffers (get_semantic_t semantic=get_semantic_t::move)
 Get the buffers from the data object.
 

Public Attributes

union { 
 
   struct { 
 
      type_t   type: 2 
 
      bool   own_data: 1 
 
   }   common 
 
   struct { 
 
      type_t   type: 2 
 
      bool   own_data: 1 
 
      uint8_t   size: 5 
 
      char   data [MAX_SCALAR_SIZE
 
   }   scalar 
 
   struct { 
 
      type_t   type: 2 
 
      bool   own_data: 1 
 
      size_t   size: 61 
 
      void *   base 
 
      mr_t   mr 
 
   }   buffer 
 
   struct { 
 
      type_t   type: 2 
 
      bool   own_data: 1 
 
      size_t   count 
 
      buffer_t *   buffers 
 
   }   buffers 
 
};  
 

Static Public Attributes

static const int MAX_SCALAR_SIZE = 23
 

Friends

void swap (data_t &first, data_t &second)
 

Detailed Description

A generic type for describing or holding data.

This type is used to pass data from LCI to users through the completion checking APIs. It is included in the status_t struct. A data object either describes or owns the underlying memory buffer(s). It will own the memory buffer(s) if the data is allocated by the LCI runtime (a.k.a the receive buffer(s) of active messages).

If the data object owns the memory buffer(s), users can use the data_t::get_scalar/buffer/buffers to get the data. get_buffer/buffers provides three semantics to optimize the memory copy behavior, defined by data_t::get_semantic_t

  • copy: the data object will allocate new buffer(s) and copy the data from the original buffer(s) to the new buffer(s). The returned buffers needed to be freed by users through free(). Users can call data_t::get_scalar/buffer/buffers() again.
  • move: the data object will directly return the buffer(s) and users will own them afterwards. The returned buffers needed to be freed by users through free(). Users cannot call data_t::get_scalar/buffer/buffers() anymore.
  • view: the data object will directly return the buffer(s) but they are not owned by users. Users cannot access them once the data object goes out of scope. Users cannot free the buffers. Users can call data_t::get_scalar/buffer/buffers() again.

get_scalar always uses the copy semantic.

Member Enumeration Documentation

◆ get_semantic_t

enum class lci::data_t::get_semantic_t
strong

Enum class of get semantic.

The get semantic is used to optimize the memory copy behavior when users get the data from the data object.

Enumerator
move 

need to free the returned buffer; can only call get once.

copy 

need to free the returned buffer; can call get multiple times.

view 

no need to free the returned buffer; can call get multiple times.

◆ type_t

Enumerator
LCI_DATA_TYPE_NONE 
LCI_DATA_TYPE_SCALAR 
LCI_DATA_TYPE_BUFFER 
LCI_DATA_TYPE_BUFFERS 

Constructor & Destructor Documentation

◆ data_t() [1/7]

lci::data_t::data_t ( )
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ data_t() [2/7]

lci::data_t::data_t ( buffer_t buffer_,
bool own_data_ = false )
inline
Here is the call graph for this function:

◆ data_t() [3/7]

lci::data_t::data_t ( buffers_t buffers_,
bool own_data_ = false )
inline
Here is the call graph for this function:

◆ data_t() [4/7]

lci::data_t::data_t ( size_t size,
allocator_base_t * allocator = nullptr )
inline
Here is the call graph for this function:

◆ data_t() [5/7]

lci::data_t::data_t ( size_t sizes[],
int count,
allocator_base_t * allocator = nullptr )
inline
Here is the call graph for this function:

◆ data_t() [6/7]

lci::data_t::data_t ( const data_t & other)
inline
Here is the call graph for this function:

◆ data_t() [7/7]

lci::data_t::data_t ( data_t && other)
inline
Here is the call graph for this function:

Member Function Documentation

◆ copy_from() [1/2]

void lci::data_t::copy_from ( const buffers_t & buffers_,
allocator_base_t * allocator_ = nullptr )
inline
Here is the call graph for this function:

◆ copy_from() [2/2]

void lci::data_t::copy_from ( const void * data_,
size_t size,
allocator_base_t * allocator_ = nullptr )
inline
Here is the call graph for this function:

◆ get_buffer()

buffer_t lci::data_t::get_buffer ( get_semantic_t semantic = get_semantic_t::move)
inline

Get the buffer from the data object.

Parameters
semanticThe get semantic to use.
Returns
The buffer.
Here is the call graph for this function:

◆ get_buffers()

buffers_t lci::data_t::get_buffers ( get_semantic_t semantic = get_semantic_t::move)
inline

Get the buffers from the data object.

Parameters
semanticThe get semantic to use.
Returns
The buffers.
Here is the call graph for this function:

◆ get_buffers_count()

size_t lci::data_t::get_buffers_count ( ) const
inline

Get the number of buffers from the data object.

Returns
The number of buffers.
Here is the call graph for this function:

◆ get_own_data()

bool lci::data_t::get_own_data ( ) const
inline
Here is the caller graph for this function:

◆ get_scalar()

template<typename T>
T lci::data_t::get_scalar ( ) const

Get the scalar data from the data object.

Template Parameters
TThe type of the scalar data.
Returns
The scalar data.

The function always uses the copy semantic.

Here is the call graph for this function:

◆ get_type()

type_t lci::data_t::get_type ( ) const
inline
Here is the caller graph for this function:

◆ is_buffer()

bool lci::data_t::is_buffer ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_buffers()

bool lci::data_t::is_buffers ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_scalar()

bool lci::data_t::is_scalar ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

data_t & lci::data_t::operator= ( data_t other)
inline
Here is the call graph for this function:

◆ set_own_data()

void lci::data_t::set_own_data ( bool own_data_)
inline
Here is the caller graph for this function:

◆ set_type()

void lci::data_t::set_type ( type_t type_)
inline
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ swap

void swap ( data_t & first,
data_t & second )
friend

Member Data Documentation

◆ [union]

union { ... } lci::data_t

◆ base

void* lci::data_t::base

◆ [struct]

struct { ... } lci::data_t::buffer

◆ buffers [1/2]

buffer_t* lci::data_t::buffers

◆ [struct] [2/2]

struct { ... } lci::data_t::buffers

◆ [struct]

struct { ... } lci::data_t::common

◆ count

size_t lci::data_t::count

◆ data

char lci::data_t::data[MAX_SCALAR_SIZE]

◆ MAX_SCALAR_SIZE

const int lci::data_t::MAX_SCALAR_SIZE = 23
static

◆ mr

mr_t lci::data_t::mr

◆ own_data

bool lci::data_t::own_data

◆ [struct]

struct { ... } lci::data_t::scalar

◆ size [1/2]

uint8_t lci::data_t::size

◆ size [2/2]

size_t lci::data_t::size

◆ type

type_t lci::data_t::type

The documentation for this struct was generated from the following file: