Mercury
|
#include "na_config.h"
#include <limits.h>
Go to the source code of this file.
Classes | |
struct | na_segment |
struct | na_cb_info_lookup |
struct | na_cb_info_recv_unexpected |
struct | na_cb_info |
Macros | |
#define | NA_ADDR_NULL ((na_addr_t)0) |
#define | NA_OP_ID_NULL ((na_op_id_t)0) |
#define | NA_OP_ID_IGNORE ((na_op_id_t *)1) |
#define | NA_MEM_HANDLE_NULL ((na_mem_handle_t)0) |
#define | NA_MAX_IDLE_TIME (3600*1000) |
#define | NA_TAG_UB UINT_MAX |
#define | NA_MAX_ADDR_LEN 256 |
#define | NA_MEM_READWRITE 0x00 |
#define | NA_MEM_READ_ONLY 0x01 |
Typedefs | |
typedef struct na_class | na_class_t |
typedef struct na_context | na_context_t |
typedef void * | na_addr_t |
typedef na_uint64_t | na_size_t |
typedef na_uint32_t | na_tag_t |
typedef void * | na_op_id_t |
typedef void * | na_mem_handle_t |
typedef na_uint64_t | na_offset_t |
typedef enum na_return | na_return_t |
typedef enum na_cb_type | na_cb_type_t |
typedef na_return_t(* | na_cb_t )(const struct na_cb_info *callback_info) |
Functions | |
NA_EXPORT na_class_t * | NA_Initialize (const char *info_string, na_bool_t listen) NA_WARN_UNUSED_RESULT |
Initialize the network abstraction layer. More... | |
NA_EXPORT na_return_t | NA_Finalize (na_class_t *na_class) |
Finalize the network abstraction layer. More... | |
NA_EXPORT na_context_t * | NA_Context_create (na_class_t *na_class) |
Create a new context. More... | |
NA_EXPORT na_return_t | NA_Context_destroy (na_class_t *na_class, na_context_t *context) |
Destroy a context created by using NA_Context_create(). More... | |
NA_EXPORT na_return_t | NA_Addr_lookup (na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg, const char *name, na_op_id_t *op_id) |
Lookup an addr from a peer address/name. More... | |
NA_EXPORT na_return_t | NA_Addr_lookup_wait (na_class_t *na_class, const char *name, na_addr_t *addr) |
For compatibility, temporarily provide this routine, which waits until addr is returned. More... | |
NA_EXPORT na_return_t | NA_Addr_free (na_class_t *na_class, na_addr_t addr) |
Free the addr from the list of peers. More... | |
NA_EXPORT na_return_t | NA_Addr_self (na_class_t *na_class, na_addr_t *addr) |
Access self address. More... | |
NA_EXPORT na_return_t | NA_Addr_dup (na_class_t *na_class, na_addr_t addr, na_addr_t *new_addr) |
Duplicate an existing NA abstract address. More... | |
NA_EXPORT na_bool_t | NA_Addr_is_self (na_class_t *na_class, na_addr_t addr) |
Test whether address is self or not. More... | |
NA_EXPORT na_return_t | NA_Addr_to_string (na_class_t *na_class, char *buf, na_size_t buf_size, na_addr_t addr) |
Convert an addr to a string (returned string includes the terminating null byte '\0'). More... | |
NA_EXPORT na_size_t | NA_Msg_get_max_expected_size (na_class_t *na_class) NA_WARN_UNUSED_RESULT |
Get the maximum size of messages supported by expected send/recv. More... | |
NA_EXPORT na_size_t | NA_Msg_get_max_unexpected_size (na_class_t *na_class) NA_WARN_UNUSED_RESULT |
Get the maximum size of messages supported by unexpected send/recv. More... | |
NA_EXPORT na_tag_t | NA_Msg_get_max_tag (na_class_t *na_class) NA_WARN_UNUSED_RESULT |
Get the maximum tag value that can be used by send/recv. More... | |
NA_EXPORT na_return_t | NA_Msg_send_unexpected (na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg, const void *buf, na_size_t buf_size, na_addr_t dest, na_tag_t tag, na_op_id_t *op_id) |
Send an unexpected message to dest. More... | |
NA_EXPORT na_return_t | NA_Msg_recv_unexpected (na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg, void *buf, na_size_t buf_size, na_op_id_t *op_id) |
Receive an unexpected message. More... | |
NA_EXPORT na_return_t | NA_Msg_send_expected (na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg, const void *buf, na_size_t buf_size, na_addr_t dest, na_tag_t tag, na_op_id_t *op_id) |
Send an expected message to dest. More... | |
NA_EXPORT na_return_t | NA_Msg_recv_expected (na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg, void *buf, na_size_t buf_size, na_addr_t source, na_tag_t tag, na_op_id_t *op_id) |
Receive an expected message from source. More... | |
NA_EXPORT na_return_t | NA_Mem_handle_create (na_class_t *na_class, void *buf, na_size_t buf_size, unsigned long flags, na_mem_handle_t *mem_handle) |
Create memory handle for RMA operations. More... | |
NA_EXPORT na_return_t | NA_Mem_handle_create_segments (na_class_t *na_class, struct na_segment *segments, na_size_t segment_count, unsigned long flags, na_mem_handle_t *mem_handle) |
Create memory handle for RMA operations. More... | |
NA_EXPORT na_return_t | NA_Mem_handle_free (na_class_t *na_class, na_mem_handle_t mem_handle) |
Free memory handle. More... | |
NA_EXPORT na_return_t | NA_Mem_register (na_class_t *na_class, na_mem_handle_t mem_handle) |
Register memory for RMA operations. More... | |
NA_EXPORT na_return_t | NA_Mem_deregister (na_class_t *na_class, na_mem_handle_t mem_handle) |
Unregister memory. More... | |
NA_EXPORT na_size_t | NA_Mem_handle_get_serialize_size (na_class_t *na_class, na_mem_handle_t mem_handle) NA_WARN_UNUSED_RESULT |
Get size required to serialize handle. More... | |
NA_EXPORT na_return_t | NA_Mem_handle_serialize (na_class_t *na_class, void *buf, na_size_t buf_size, na_mem_handle_t mem_handle) |
Serialize memory handle into a buffer. More... | |
NA_EXPORT na_return_t | NA_Mem_handle_deserialize (na_class_t *na_class, na_mem_handle_t *mem_handle, const void *buf, na_size_t buf_size) |
Deserialize memory handle from buffer. More... | |
NA_EXPORT na_return_t | NA_Put (na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg, na_mem_handle_t local_mem_handle, na_offset_t local_offset, na_mem_handle_t remote_mem_handle, na_offset_t remote_offset, na_size_t data_size, na_addr_t remote_addr, na_op_id_t *op_id) |
Put data to remote target. More... | |
NA_EXPORT na_return_t | NA_Get (na_class_t *na_class, na_context_t *context, na_cb_t callback, void *arg, na_mem_handle_t local_mem_handle, na_offset_t local_offset, na_mem_handle_t remote_mem_handle, na_offset_t remote_offset, na_size_t data_size, na_addr_t remote_addr, na_op_id_t *op_id) |
Get data from remote target. More... | |
NA_EXPORT na_return_t | NA_Progress (na_class_t *na_class, na_context_t *context, unsigned int timeout) |
Try to progress communication for at most timeout until timeout reached or any completion has occurred. More... | |
NA_EXPORT na_return_t | NA_Trigger (na_context_t *context, unsigned int timeout, unsigned int max_count, unsigned int *actual_count) |
Execute at most max_count callbacks. More... | |
NA_EXPORT na_return_t | NA_Cancel (na_class_t *na_class, na_context_t *context, na_op_id_t op_id) |
Cancel an ongoing operation. More... | |
NA_EXPORT const char * | NA_Error_to_string (na_return_t errnum) NA_WARN_UNUSED_RESULT |
Convert error return code to string (null terminated). More... | |
#define NA_OP_ID_NULL ((na_op_id_t)0) |
#define NA_OP_ID_IGNORE ((na_op_id_t *)1) |
#define NA_MEM_HANDLE_NULL ((na_mem_handle_t)0) |
typedef struct na_class na_class_t |
typedef struct na_context na_context_t |
typedef void* na_op_id_t |
typedef void* na_mem_handle_t |
typedef na_uint64_t na_offset_t |
typedef enum na_return na_return_t |
typedef enum na_cb_type na_cb_type_t |
typedef na_return_t(* na_cb_t)(const struct na_cb_info *callback_info) |
enum na_return |
enum na_cb_type |
NA_EXPORT na_class_t* NA_Initialize | ( | const char * | info_string, |
na_bool_t | listen | ||
) |
Initialize the network abstraction layer.
info_string | [IN] host address with port number (e.g., "tcp://localhost:3344" or "bmi+tcp://localhost:3344") |
listen | [IN] listen for incoming connections |
NA_EXPORT na_return_t NA_Finalize | ( | na_class_t * | na_class | ) |
Finalize the network abstraction layer.
na_class | [IN] pointer to NA class |
NA_EXPORT na_context_t* NA_Context_create | ( | na_class_t * | na_class | ) |
Create a new context.
na_class | [IN] pointer to NA class |
NA_EXPORT na_return_t NA_Context_destroy | ( | na_class_t * | na_class, |
na_context_t * | context | ||
) |
Destroy a context created by using NA_Context_create().
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
NA_EXPORT na_return_t NA_Addr_lookup | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_cb_t | callback, | ||
void * | arg, | ||
const char * | name, | ||
na_op_id_t * | op_id | ||
) |
Lookup an addr from a peer address/name.
Addresses need to be freed by calling NA_Addr_free. Callback will be called with pointer to na_addr_t that contains addr na_cb_info_lookup
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
callback | [IN] pointer to function callback |
arg | [IN] pointer to data passed to callback |
name | [IN] lookup name |
op_id | [OUT] pointer to returned operation ID |
NA_EXPORT na_return_t NA_Addr_lookup_wait | ( | na_class_t * | na_class, |
const char * | name, | ||
na_addr_t * | addr | ||
) |
For compatibility, temporarily provide this routine, which waits until addr is returned.
na_class | [IN] pointer to NA class |
name | [IN] lookup name |
addr | [OUT] pointer to abstract address |
NA_EXPORT na_return_t NA_Addr_free | ( | na_class_t * | na_class, |
na_addr_t | addr | ||
) |
Free the addr from the list of peers.
na_class | [IN] pointer to NA class |
addr | [IN] abstract address |
NA_EXPORT na_return_t NA_Addr_self | ( | na_class_t * | na_class, |
na_addr_t * | addr | ||
) |
Access self address.
na_class | [IN] pointer to NA class |
addr | [OUT] pointer to abstract address |
NA_EXPORT na_return_t NA_Addr_dup | ( | na_class_t * | na_class, |
na_addr_t | addr, | ||
na_addr_t * | new_addr | ||
) |
Duplicate an existing NA abstract address.
The duplicated address can be stored for later use and the origin address be freed safely. The duplicated address must be freed with NA_Addr_free.
na_class | [IN] pointer to NA class |
addr | [IN] abstract address |
new_addr | [OUT] pointer to abstract address |
NA_EXPORT na_bool_t NA_Addr_is_self | ( | na_class_t * | na_class, |
na_addr_t | addr | ||
) |
Test whether address is self or not.
na_class | [IN] pointer to NA class |
addr | [IN] abstract address |
NA_EXPORT na_return_t NA_Addr_to_string | ( | na_class_t * | na_class, |
char * | buf, | ||
na_size_t | buf_size, | ||
na_addr_t | addr | ||
) |
Convert an addr to a string (returned string includes the terminating null byte '\0').
na_class | [IN] pointer to NA class |
buf | [IN/OUT] pointer to destination buffer |
buf_size | [IN] buffer size (max string length is defined by NA_MAX_ADDR_LEN) |
addr | [IN] abstract address |
NA_EXPORT na_size_t NA_Msg_get_max_expected_size | ( | na_class_t * | na_class | ) |
Get the maximum size of messages supported by expected send/recv.
Small message size that may differ from the unexpected message size.
na_class | [IN] pointer to NA class |
NA_EXPORT na_size_t NA_Msg_get_max_unexpected_size | ( | na_class_t * | na_class | ) |
Get the maximum size of messages supported by unexpected send/recv.
Small message size.
na_class | [IN] pointer to NA class |
NA_EXPORT na_tag_t NA_Msg_get_max_tag | ( | na_class_t * | na_class | ) |
Get the maximum tag value that can be used by send/recv.
(both expected and unexpected)
na_class | [IN] pointer to NA class |
NA_EXPORT na_return_t NA_Msg_send_unexpected | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_cb_t | callback, | ||
void * | arg, | ||
const void * | buf, | ||
na_size_t | buf_size, | ||
na_addr_t | dest, | ||
na_tag_t | tag, | ||
na_op_id_t * | op_id | ||
) |
Send an unexpected message to dest.
Unexpected sends do not require a matching receive to complete. Note also that unexpected messages do not require an unexpected receive to be posted at the destination before sending the message and the destination is allowed to drop the message without notification.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
callback | [IN] pointer to function callback |
arg | [IN] pointer to data passed to callback |
buf | [IN] pointer to send buffer |
buf_size | [IN] buffer size |
dest | [IN] abstract address of destination |
tag | [IN] tag attached to message |
op_id | [OUT] pointer to returned operation ID |
NA_EXPORT na_return_t NA_Msg_recv_unexpected | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_cb_t | callback, | ||
void * | arg, | ||
void * | buf, | ||
na_size_t | buf_size, | ||
na_op_id_t * | op_id | ||
) |
Receive an unexpected message.
Unexpected receives may wait on ANY_TAG and ANY_SOURCE depending on the implementation.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
callback | [IN] pointer to function callback |
arg | [IN] pointer to data passed to callback |
buf | [IN] pointer to send buffer |
buf_size | [IN] buffer size |
op_id | [OUT] pointer to returned operation ID |
NA_EXPORT na_return_t NA_Msg_send_expected | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_cb_t | callback, | ||
void * | arg, | ||
const void * | buf, | ||
na_size_t | buf_size, | ||
na_addr_t | dest, | ||
na_tag_t | tag, | ||
na_op_id_t * | op_id | ||
) |
Send an expected message to dest.
Note that expected messages require an expected receive to be posted at the destination before sending the message, otherwise the destination is allowed to drop the message without notification.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
callback | [IN] pointer to function callback |
arg | [IN] pointer to data passed to callback |
buf | [IN] pointer to send buffer |
buf_size | [IN] buffer size |
dest | [IN] abstract address of destination |
tag | [IN] tag attached to message |
op_id | [OUT] pointer to returned operation ID |
NA_EXPORT na_return_t NA_Msg_recv_expected | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_cb_t | callback, | ||
void * | arg, | ||
void * | buf, | ||
na_size_t | buf_size, | ||
na_addr_t | source, | ||
na_tag_t | tag, | ||
na_op_id_t * | op_id | ||
) |
Receive an expected message from source.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
callback | [IN] pointer to function callback |
arg | [IN] pointer to data passed to callback |
buf | [IN] pointer to receive buffer |
buf_size | [IN] buffer size |
source | [IN] abstract address of source |
tag | [IN] matching tag used to receive message |
op_id | [OUT] pointer to returned operation ID |
NA_EXPORT na_return_t NA_Mem_handle_create | ( | na_class_t * | na_class, |
void * | buf, | ||
na_size_t | buf_size, | ||
unsigned long | flags, | ||
na_mem_handle_t * | mem_handle | ||
) |
Create memory handle for RMA operations.
For non-contiguous memory, use NA_Mem_handle_create_segments instead.
Note to plugin developers: NA_Mem_handle_create may be called multiple times on the same memory region.
na_class | [IN] pointer to NA class |
buf | [IN] pointer to buffer that needs to be registered |
buf_size | [IN] buffer size |
flags | [IN] permission flag:
|
mem_handle | [OUT] pointer to returned abstract memory handle |
NA_EXPORT na_return_t NA_Mem_handle_create_segments | ( | na_class_t * | na_class, |
struct na_segment * | segments, | ||
na_size_t | segment_count, | ||
unsigned long | flags, | ||
na_mem_handle_t * | mem_handle | ||
) |
Create memory handle for RMA operations.
Create_segments can be used to register fragmented pieces and get a single memory handle. Implemented only if the network transport or hardware supports it.
na_class | [IN] pointer to NA class |
segments | [IN] pointer to array of segments composed of:
|
segment_count | [IN] segment count |
flags | [IN] permission flag:
|
mem_handle | [OUT] pointer to returned abstract memory handle |
NA_EXPORT na_return_t NA_Mem_handle_free | ( | na_class_t * | na_class, |
na_mem_handle_t | mem_handle | ||
) |
Free memory handle.
na_class | [IN] pointer to NA class |
mem_handle | [IN] abstract memory handle |
NA_EXPORT na_return_t NA_Mem_register | ( | na_class_t * | na_class, |
na_mem_handle_t | mem_handle | ||
) |
Register memory for RMA operations.
Memory pieces must be registered before one-sided transfers can be initiated.
na_class | [IN] pointer to NA class |
mem_handle | [IN] pointer to abstract memory handle |
NA_EXPORT na_return_t NA_Mem_deregister | ( | na_class_t * | na_class, |
na_mem_handle_t | mem_handle | ||
) |
Unregister memory.
na_class | [IN] pointer to NA class |
mem_handle | [IN] abstract memory handle |
NA_EXPORT na_size_t NA_Mem_handle_get_serialize_size | ( | na_class_t * | na_class, |
na_mem_handle_t | mem_handle | ||
) |
Get size required to serialize handle.
na_class | [IN] pointer to NA class |
mem_handle | [IN] abstract memory handle |
NA_EXPORT na_return_t NA_Mem_handle_serialize | ( | na_class_t * | na_class, |
void * | buf, | ||
na_size_t | buf_size, | ||
na_mem_handle_t | mem_handle | ||
) |
Serialize memory handle into a buffer.
One-sided transfers require prior exchange of memory handles between peers, serialization callbacks can be used to "pack" a memory handle and send it across the network. NB. Memory handles can be variable size, therefore the space required to serialize a handle into a buffer can be obtained using NA_Mem_handle_get_serialize_size.
na_class | [IN] pointer to NA class |
buf | [IN/OUT] pointer to buffer used for serialization |
buf_size | [IN] buffer size |
mem_handle | [IN] abstract memory handle |
NA_EXPORT na_return_t NA_Mem_handle_deserialize | ( | na_class_t * | na_class, |
na_mem_handle_t * | mem_handle, | ||
const void * | buf, | ||
na_size_t | buf_size | ||
) |
Deserialize memory handle from buffer.
na_class | [IN] pointer to NA class |
mem_handle | [OUT] pointer to abstract memory handle |
buf | [IN] pointer to buffer used for deserialization |
buf_size | [IN] buffer size |
NA_EXPORT na_return_t NA_Put | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_cb_t | callback, | ||
void * | arg, | ||
na_mem_handle_t | local_mem_handle, | ||
na_offset_t | local_offset, | ||
na_mem_handle_t | remote_mem_handle, | ||
na_offset_t | remote_offset, | ||
na_size_t | data_size, | ||
na_addr_t | remote_addr, | ||
na_op_id_t * | op_id | ||
) |
Put data to remote target.
Initiate a put or get to/from the registered memory regions with the given offset/size. NB. Memory must be registered and handles exchanged between peers.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
callback | [IN] pointer to function callback |
arg | [IN] pointer to data passed to callback |
local_mem_handle | [IN] abstract local memory handle |
local_offset | [IN] local offset |
remote_mem_handle | [IN] abstract remote memory handle |
remote_offset | [IN] remote offset |
data_size | [IN] size of data that needs to be transferred |
remote_addr | [IN] abstract address of remote destination |
op_id | [OUT] pointer to returned operation ID |
NA_EXPORT na_return_t NA_Get | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_cb_t | callback, | ||
void * | arg, | ||
na_mem_handle_t | local_mem_handle, | ||
na_offset_t | local_offset, | ||
na_mem_handle_t | remote_mem_handle, | ||
na_offset_t | remote_offset, | ||
na_size_t | data_size, | ||
na_addr_t | remote_addr, | ||
na_op_id_t * | op_id | ||
) |
Get data from remote target.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
callback | [IN] pointer to function callback |
arg | [IN] pointer to data passed to callback |
local_mem_handle | [IN] abstract local memory handle |
local_offset | [IN] local offset |
remote_mem_handle | [IN] abstract remote memory handle |
remote_offset | [IN] remote offset |
data_size | [IN] size of data that needs to be transferred |
remote_addr | [IN] abstract address of remote source |
op_id | [OUT] pointer to returned operation ID |
NA_EXPORT na_return_t NA_Progress | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
unsigned int | timeout | ||
) |
Try to progress communication for at most timeout until timeout reached or any completion has occurred.
Progress should not be considered as wait, in the sense that it cannot be assumed that completion of a specific operation will occur only when progress is called.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
timeout | [IN] timeout (in milliseconds) |
NA_EXPORT na_return_t NA_Trigger | ( | na_context_t * | context, |
unsigned int | timeout, | ||
unsigned int | max_count, | ||
unsigned int * | actual_count | ||
) |
Execute at most max_count callbacks.
If timeout is non-zero, wait up to timeout before returning. Function can return when at least one or more callbacks are triggered (at most max_count).
context | [IN] pointer to context of execution |
timeout | [IN] timeout (in milliseconds) |
max_count | [IN] maximum number of callbacks triggered |
actual_count | [IN] actual number of callbacks triggered |
NA_EXPORT na_return_t NA_Cancel | ( | na_class_t * | na_class, |
na_context_t * | context, | ||
na_op_id_t | op_id | ||
) |
Cancel an ongoing operation.
na_class | [IN] pointer to NA class |
context | [IN] pointer to context of execution |
op_id | [IN] operation ID |
NA_EXPORT const char* NA_Error_to_string | ( | na_return_t | errnum | ) |
Convert error return code to string (null terminated).
errnum | [IN] error return code |