Molssi Driver Interface Library
Functions | Variables
mdi_global.c File Reference

Global structures used by MDI. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
#include <stdarg.h>
#include "mdi_global.h"

Functions

int vector_init (vector *v, size_t stride)
 Initialize memory allocation for a vector structure. More...
 
int vector_push_back (vector *v, void *element)
 Append a new element to the end of the vector. More...
 
int vector_delete (vector *v, int index)
 Remove an element from a vector. More...
 
int vector_free (vector *v)
 Free all data associated with a vector. More...
 
int vector_get (vector *v, int index, void **element)
 Return a pointer to an element of a vector. More...
 
int get_node_index (vector *v, const char *node_name, int *node_index)
 Determine the index of a node within a vector of nodes. More...
 
int get_command_index (node *n, const char *command_name, int *command_index)
 Determine the index of a command within a node. More...
 
int get_callback_index (node *n, const char *callback_name, int *callback_index)
 Determine the index of a callback within a node. More...
 
int free_node_vector (vector *v)
 Determine the index of a callback within a node.
 
int new_code (size_t *code_id)
 Create a new code structure and add it to the list of codes Returns the index of the new code.
 
int get_code (size_t code_id, code **ret_code)
 Get a code from a code handle Returns a pointer to the code.
 
int get_current_code (code **this_code_ptr)
 Get the currently active code Returns a pointer to the code.
 
int delete_code (size_t code_id)
 Delete a code Returns 0 on success.
 
int new_method (size_t code_id, int method_id, int *id_ptr)
 Create a new method structure and add it to the vector of methods Returns the handle of the new method.
 
int get_method (size_t code_id, int method_id, method **method_ptr)
 Get a method from a method handle Returns a pointer to the method.
 
int delete_method (size_t code_id, int method_id)
 Delete a method Returns 0 on success.
 
int free_methods_vector (vector *v)
 Free the memory associated with a methods vector.
 
int new_communicator (size_t code_id, int method, MDI_Comm_Type *comm_id_ptr)
 Create a new communicator structure and add it to the list of communicators Returns the handle of the new communicator.
 
int get_communicator (size_t code_id, MDI_Comm_Type comm_id, communicator **comm_ptr)
 Get a communicator from a communicator handle Returns a pointer to the communicator.
 
int delete_communicator (size_t code_id, MDI_Comm_Type comm_id)
 Delete a communicator. More...
 
int communicator_delete (void *comm)
 Dummy function for method-specific deletion operations for communicator deletion.
 
int file_exists (const char *file_name, int *flag)
 Print error message and exit. More...
 
void mdi_error (const char *message)
 Print error message. More...
 
void mdi_warning (const char *message)
 Print warning message. More...
 
int mdi_debug (const char *message,...)
 Print a debug message. More...
 
int datatype_info (MDI_Datatype_Type datatype, size_t *size, MDI_Datatype_Type *base)
 Get information about an MDI datatype. More...
 
int datatype_mpitype (MDI_Datatype_Type datatype, MPI_Datatype *mpitype)
 Get the MPI datatype that corresponds to an MDI datatype. More...
 
int convert_buf_datatype (void *recvbuf_in, MDI_Datatype_Type recvtype, void *sendbuf_in, MDI_Datatype_Type sendtype, int count)
 Convert a buffer from one datatype to another.
 

Variables

vector codes = { .initialized = 0 }
 Vector containing all codes that have been initiailized on this rank Typically, this will only include a single code, unless the communication method is LIBRARY. More...
 

Detailed Description

Global structures used by MDI.

Function Documentation

◆ datatype_info()

int datatype_info ( MDI_Datatype_Type  datatype,
size_t *  size,
MDI_Datatype_Type *  base 
)

Get information about an MDI datatype.

Get information about an MDI_Datatype.

Parameters
[in]datatypeMDI datatype.
[out]sizeSize of the MDI datatype.
[out]baseBase type of an MDI datatype.

◆ datatype_mpitype()

int datatype_mpitype ( MDI_Datatype_Type  datatype,
MPI_Datatype *  mpitype 
)

Get the MPI datatype that corresponds to an MDI datatype.

Parameters
[in]datatypeMDI datatype.
[out]mpitypeMPI datatype.

◆ delete_communicator()

int delete_communicator ( size_t  code_id,
MDI_Comm_Type  comm_id 
)

Delete a communicator.

The function returns 0 on a success.

◆ file_exists()

int file_exists ( const char *  file_name,
int *  flag 
)

Print error message and exit.

Check whether a file exists.

Parameters
[in]messageMessage printed before exiting.

◆ get_callback_index()

int get_callback_index ( node n,
const char *  callback_name,
int *  callback_index 
)

Determine the index of a callback within a node.

Parameters
[in]nodePointer to the node
[in]callback_nameName of the callback

◆ get_command_index()

int get_command_index ( node n,
const char *  command_name,
int *  command_index 
)

Determine the index of a command within a node.

Parameters
[in]nodePointer to the node
[in]command_nameName of the command

◆ get_node_index()

int get_node_index ( vector v,
const char *  node_name,
int *  node_index 
)

Determine the index of a node within a vector of nodes.

Parameters
[in]vPointer to the vector
[in]node_nameName of the node

◆ mdi_debug()

int mdi_debug ( const char *  message,
  ... 
)

Print a debug message.

Parameters
[in]messageMessage printed before exiting.

◆ mdi_error()

void mdi_error ( const char *  message)

Print error message.

Parameters
[in]messageMessage printed before exiting.

◆ mdi_warning()

void mdi_warning ( const char *  message)

Print warning message.

Parameters
[in]messageMessage printed before exiting.

◆ vector_delete()

int vector_delete ( vector v,
int  index 
)

Remove an element from a vector.

The function returns 0 on a success.

Parameters
[in]vPointer to the vector from which the element will be removed
[in]indexIndex of the element that will be removed from the vector

◆ vector_free()

int vector_free ( vector v)

Free all data associated with a vector.

The function returns 0 on a success.

Parameters
[in]vPointer to the vector that will be freed

◆ vector_get()

int vector_get ( vector v,
int  index,
void **  element 
)

Return a pointer to an element of a vector.

The function returns 0 on a success.

Parameters
[in]vPointer to the vector
[in]indexIndex of the element within the vector

◆ vector_init()

int vector_init ( vector v,
size_t  stride 
)

Initialize memory allocation for a vector structure.

The function returns 0 on a success.

Parameters
[in]vPointer to the vector structure for which the memory will be allocated
[in]strideStride of the vector

◆ vector_push_back()

int vector_push_back ( vector v,
void *  element 
)

Append a new element to the end of the vector.

The function returns 0 on a success.

Parameters
[in]vPointer to the vector to which the element will be appended
[in]elementPointer to the element that will be appended to the vector

Variable Documentation

◆ codes

vector codes = { .initialized = 0 }

Vector containing all codes that have been initiailized on this rank Typically, this will only include a single code, unless the communication method is LIBRARY.

Vector containing all codes that have been initiailized on this rank. Typically, this will only include a single code, unless the communication method is LINK. ALL global MDI data is stored within this vector.