CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
libfabric_api.c File Reference

This file contains definitions and functions for accessing libfabric 1.9 and mainline through a generic V-table interface. It is used to generate two shared libraries, each linking to a unique version of libfabric as shown below: More...

#include "adapter_efa.h"
#include "libfabric_api.h"
#include <dlfcn.h>

Macros

#define LOAD_LIBRARY(filename_str)   (dlopen(filename_str, RTLD_LAZY))
 Macro used to dynamically load a library.
 
#define GET_PROC_ADDRESS(handle, name_str)   (dlsym(handle, name_str))
 Macro used to get an address to function in a dynamically loaded library using its name.
 
#define FREE_LIBRARY(handle)   (dlclose(handle))
 Macro used to free resources used by a dynmically loaded library.
 

Functions

 CDI_STATIC_ASSERT (FI_MAJOR_VERSION==1 &&FI_MINOR_VERSION==9, "Incorrect libfabric version.")
 To provide backwards compatibility with previous versions of the SDK, libfabric version 1.9.x must be used here.
 
static struct fi_info * fi_allocinfo_internal (void)
 Forward reference.
 
static CdiReturnStatus DynamicallyLoadLibrary (const char *libfabric_filename_str, LibfabricApi **ret_api_ptr)
 Dynamically load a version of the libfabric library.
 
CdiReturnStatus LoadLibfabric1_9 (LibfabricApi **ret_api_ptr)
 Dynamically load libfabric 1.9 and return a V-table to the API used by the SDK.
 

Variables

static LibfabricApi api_vtable
 API V-table for libfabric API.
 
static void * lib_handle = NULL
 Handle for libfabric library.
 
static struct fi_info *(* internal_fi_dupinfo_ptr )(const struct fi_info *info)
 Pointer to fi_dupinfo, which is dynamically loaded.
 

Detailed Description

This file contains definitions and functions for accessing libfabric 1.9 and mainline through a generic V-table interface. It is used to generate two shared libraries, each linking to a unique version of libfabric as shown below:

libfabric_api.so -> links to libfabric 1.9 libfabric_api_new.so -> links to libfabric new

Function Documentation

◆ DynamicallyLoadLibrary()

static CdiReturnStatus DynamicallyLoadLibrary ( const char * libfabric_filename_str,
LibfabricApi ** ret_api_ptr )
static

Dynamically load a version of the libfabric library.

Parameters
libfabric_filename_strPointer to name of libfabric library to load.
ret_api_ptrAddress where to write pointer to the V-table API.
Returns
CdiReturnStatus kCdiStausOk if successful, otherwise a value indicating the nature of failure.

◆ fi_allocinfo_internal()

static struct fi_info * fi_allocinfo_internal ( void )
static

Forward reference.

Wrapper function for fi_allocinfo(), which is a static line function that simply calls the non-static function fi_dupinfo(). Wrapper required here since we want to dynamically load and use libfabric's non-static functions.

Returns
Pointer to allocated fi_info structure.

◆ LoadLibfabric1_9()

CdiReturnStatus LoadLibfabric1_9 ( LibfabricApi ** ret_api_ptr)

Dynamically load libfabric 1.9 and return a V-table to the API used by the SDK.

Parameters
ret_api_ptrAddress where to write pointer to the V-table API.
Returns
CdiReturnStatus kCdiStausOk if successful, otherwise a value indicating the nature of failure.

Variable Documentation

◆ api_vtable

LibfabricApi api_vtable
static
Initial value:
= {
.version_major = FI_MAJOR_VERSION,
.version_minor = FI_MINOR_VERSION,
.fi_version = NULL,
.fi_allocinfo = fi_allocinfo_internal,
.fi_av_insert = fi_av_insert,
.fi_av_open = fi_av_open,
.fi_av_remove = fi_av_remove,
.fi_close = fi_close,
.fi_cq_open = fi_cq_open,
.fi_cq_read = fi_cq_read,
.fi_cq_readerr = fi_cq_readerr,
.fi_domain = fi_domain,
.fi_enable = fi_enable,
.fi_endpoint = fi_endpoint,
.fi_ep_bind = fi_ep_bind,
.fi_fabric = NULL,
.fi_freeinfo = NULL,
.fi_getinfo = NULL,
.fi_getname = fi_getname,
.fi_mr_desc = fi_mr_desc,
.fi_mr_reg = fi_mr_reg,
.fi_recvmsg = fi_recvmsg,
.fi_sendmsg = fi_sendmsg,
.fi_strerror = NULL,
}
static struct fi_info * fi_allocinfo_internal(void)
Forward reference.
Definition libfabric_api.c:108

API V-table for libfabric API.