YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
param_utils.c File Reference
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "parameter/param.h"
#include "parameter/param_utils.h"
#include "utils_common.h"
#include "yac_assert.h"
#include "yac_mpi_internal.h"
Include dependency graph for param_utils.c:

Go to the source code of this file.

Functions

static size_t get_mpi_pack_size (int count, MPI_Datatype datatype, MPI_Comm comm)
 Get the size in bytes required to pack a given number of elements of a specified MPI datatype using MPI_Pack_size.
 
static char * get_scalar_string_dup (struct yac_param *param)
 Get a dynamically allocated copy of the scalar string value of a parameter.
 
static size_t get_param_record_pack_size (struct yac_param *param, MPI_Comm comm, char const *routine)
 Get the size in bytes required to pack a parameter record.
 
static size_t get_scalar_record_pack_size (struct yac_param *param, MPI_Comm comm, char const *routine)
 Get the size in bytes required to pack a scalar parameter record.
 
static int sub_requires_packing (int sub_is_default, size_t sub_count)
 Check whether a sub-parameter of a struct parameter has to be packed.
 
static size_t get_struct_record_pack_size (struct yac_param *param, MPI_Comm comm, char const *routine)
 Get the size in bytes required to pack a struct parameter record.
 
static size_t get_list_record_pack_size (struct yac_param *param, MPI_Comm comm, char const *routine)
 Get the size in bytes required to pack a list parameter record.
 
size_t yac_param_get_pack_size (struct yac_param *param, MPI_Comm comm, char const *routine)
 Public function to get the size in bytes required to pack a parameter record.
 
static void pack_param_record (struct yac_param *param, void *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Pack a parameter record into a buffer.
 
static void pack_param_record_scalar (struct yac_param *param, void *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Pack a scalar parameter record into a buffer.
 
static void pack_param_record_struct (struct yac_param *param, void *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Pack a struct parameter record into a buffer.
 
static void pack_param_record_list (struct yac_param *param, void *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Pack a list parameter record into a buffer.
 
void yac_param_pack (struct yac_param *param, void *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Public function to pack a parameter record into a buffer.
 
static void unpack_and_apply_param_record (struct yac_param *param, void const *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Unpack a parameter record from a buffer and apply it to the given parameter, including its type, default state, and value.
 
static void unpack_and_apply_param_record_scalar (struct yac_param *param, void const *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 
static void unpack_and_apply_param_record_struct (struct yac_param *param, void const *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Unpack a struct parameter record from a buffer and apply it to the given parameter.
 
static void unpack_and_apply_param_record_list (struct yac_param *param, void const *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 
void yac_param_unpack (struct yac_param *param, void const *buffer, int buffer_size, int *position, MPI_Comm comm, char const *routine)
 Unpack a parameter from an MPI buffer and apply its values to the given parameter.
 

Function Documentation

◆ get_list_record_pack_size()

static size_t get_list_record_pack_size ( struct yac_param * param,
MPI_Comm comm,
char const * routine )
static

Get the size in bytes required to pack a list parameter record.

Definition at line 186 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_mpi_pack_size()

static size_t get_mpi_pack_size ( int count,
MPI_Datatype datatype,
MPI_Comm comm )
static

Get the size in bytes required to pack a given number of elements of a specified MPI datatype using MPI_Pack_size.

Definition at line 20 of file param_utils.c.

Here is the caller graph for this function:

◆ get_param_record_pack_size()

static size_t get_param_record_pack_size ( struct yac_param * param,
MPI_Comm comm,
char const * routine )
static

Get the size in bytes required to pack a parameter record.

Definition at line 216 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_scalar_record_pack_size()

static size_t get_scalar_record_pack_size ( struct yac_param * param,
MPI_Comm comm,
char const * routine )
static

Get the size in bytes required to pack a scalar parameter record.

Definition at line 75 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_scalar_string_dup()

static char * get_scalar_string_dup ( struct yac_param * param)
static

Get a dynamically allocated copy of the scalar string value of a parameter.

This function attempts to retrieve the scalar string value of the given parameter. It dynamically allocates a buffer to hold the string and resizes it if necessary. The caller is responsible for freeing the returned string.

Parameters
paramThe parameter from which to retrieve the string value.
Returns
Dynamically allocated copy of the scalar string value

Definition at line 40 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_struct_record_pack_size()

static size_t get_struct_record_pack_size ( struct yac_param * param,
MPI_Comm comm,
char const * routine )
static

Get the size in bytes required to pack a struct parameter record.

Definition at line 129 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_param_record()

static void pack_param_record ( struct yac_param * param,
void * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Pack a parameter record into a buffer.

Definition at line 447 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_param_record_list()

static void pack_param_record_list ( struct yac_param * param,
void * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Pack a list parameter record into a buffer.

Definition at line 412 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_param_record_scalar()

static void pack_param_record_scalar ( struct yac_param * param,
void * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Pack a scalar parameter record into a buffer.

Definition at line 273 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_param_record_struct()

static void pack_param_record_struct ( struct yac_param * param,
void * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Pack a struct parameter record into a buffer.

Definition at line 337 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sub_requires_packing()

static int sub_requires_packing ( int sub_is_default,
size_t sub_count )
static

Check whether a sub-parameter of a struct parameter has to be packed.

Non-default sub-parameters always have to be packed. In addition, the single sub-parameter of a one-of parameter has to be packed even if it is at its default state: a one-of parameter is non-default as soon as an alternative other than the default one is selected, and packing the name of the selected alternative (with an empty record) is what allows the receiving side to select it as well.

Return values
0the sub-parameter does not have to be packed
1the sub-parameter has to be packed

Definition at line 121 of file param_utils.c.

Here is the caller graph for this function:

◆ unpack_and_apply_param_record()

static void unpack_and_apply_param_record ( struct yac_param * param,
void const * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Unpack a parameter record from a buffer and apply it to the given parameter, including its type, default state, and value.

Definition at line 651 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack_and_apply_param_record_list()

static void unpack_and_apply_param_record_list ( struct yac_param * param,
void const * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Definition at line 619 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack_and_apply_param_record_scalar()

static void unpack_and_apply_param_record_scalar ( struct yac_param * param,
void const * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Definition at line 508 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack_and_apply_param_record_struct()

static void unpack_and_apply_param_record_struct ( struct yac_param * param,
void const * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )
static

Unpack a struct parameter record from a buffer and apply it to the given parameter.

Definition at line 581 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_param_get_pack_size()

size_t yac_param_get_pack_size ( struct yac_param * param,
MPI_Comm comm,
char const * routine )

Public function to get the size in bytes required to pack a parameter record.

Get the size in bytes required to pack a given parameter using MPI_Pack_size.

Definition at line 257 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_param_pack()

void yac_param_pack ( struct yac_param * param,
void * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )

Public function to pack a parameter record into a buffer.

Pack a parameter into an MPI buffer.

Definition at line 493 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_param_unpack()

void yac_param_unpack ( struct yac_param * param,
void const * buffer,
int buffer_size,
int * position,
MPI_Comm comm,
char const * routine )

Unpack a parameter from an MPI buffer and apply its values to the given parameter.

Parameters
paramPointer to parameter that will receive the unpacked values.
bufferBuffer to unpack from.
buffer_sizeSize of buffer.
positionPosition in buffer (as in MPI_Unpack).
commMPI communicator.
routineName of the calling routine (for error messages).
Remarks
This routine assumes, that the provided parameter is at its default state before unpacking. Only non-default parameters are unpacked and applied.

Definition at line 703 of file param_utils.c.

Here is the call graph for this function:
Here is the caller graph for this function: