LCI v2.0.0-dev
For Asynchronous Multithreaded Communication
|
A generic type for describing or holding data. More...
#include <lci.hpp>
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_t & | operator= (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> | |
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) |
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
free()
. Users can call data_t::get_scalar/buffer/buffers()
again.free()
. Users cannot call data_t::get_scalar/buffer/buffers()
anymore.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.
|
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.
enum lci::data_t::type_t |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the buffer from the data
object.
semantic | The get semantic to use. |
|
inline |
Get the buffers from the data
object.
semantic | The get semantic to use. |
|
inline |
Get the number of buffers from the data
object.
|
inline |
T lci::data_t::get_scalar | ( | ) | const |
Get the scalar data from the data
object.
T | The type of the scalar data. |
The function always uses the copy semantic.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
union { ... } lci::data_t |
void* lci::data_t::base |
struct { ... } lci::data_t::buffer |
buffer_t* lci::data_t::buffers |
struct { ... } lci::data_t::buffers |
struct { ... } lci::data_t::common |
size_t lci::data_t::count |
char lci::data_t::data[MAX_SCALAR_SIZE] |
|
static |
mr_t lci::data_t::mr |
bool lci::data_t::own_data |
struct { ... } lci::data_t::scalar |
uint8_t lci::data_t::size |
size_t lci::data_t::size |
type_t lci::data_t::type |