7.1
general documentation
cs_sles_amgx.c File Reference

handling of AmgX-based linear solvers More...

#include "cs_defs.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <amgx_c.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "cs_base.h"
#include "cs_log.h"
#include "cs_fp_exception.h"
#include "cs_halo.h"
#include "cs_matrix.h"
#include "cs_matrix_default.h"
#include "cs_timer.h"
#include "cs_sles.h"
#include "cs_sles_amgx.h"
+ Include dependency graph for cs_sles_amgx.c:

Functions

cs_sles_amgx_tcs_sles_amgx_define (int f_id, const char *name)
 Define and associate an AmgX linear system solver for a given field or equation name. More...
 
cs_sles_amgx_tcs_sles_amgx_create (void)
 Create AmgX linear system solver info and context. More...
 
void * cs_sles_amgx_copy (const void *context)
 Create AmgX linear system solver info and context based on existing info and context. More...
 
void cs_sles_amgx_destroy (void **context)
 Destroy AmgX linear system solver info and context. More...
 
const char * cs_sles_amgx_get_config (void *context)
 return the configuration for an AmgX solver. More...
 
void cs_sles_amgx_set_config (void *context, const char *config)
 Define the solver configuration for an AmgX solver. More...
 
const char * cs_sles_amgx_get_config_file (void *context)
 return the name of the solver configuration file for an AmgX solver. More...
 
void cs_sles_amgx_set_config_file (void *context, const char *path)
 Set the solver configuration file for an AmgX solver. More...
 
bool cs_sles_amgx_get_pin_memory (void *context)
 Indicate whether an AmgX solver should pin host memory. More...
 
void cs_sles_amgx_set_pin_memory (void *context, bool pin_memory)
 Define whether an AmgX solver should pin host memory. More...
 
bool cs_sles_amgx_get_use_device (void *context)
 Query whether an AmgX solver should use the device or host. More...
 
void cs_sles_amgx_set_use_device (void *context, bool use_device)
 Define whether an AmgX solver should use the device or host. More...
 
int cs_sles_amgx_get_flags (void *context)
 Query additional AmgX solver usage flags. More...
 
void cs_sles_amgx_set_flags (void *context, int flags)
 Define additional AmgX solver usage flags. More...
 
void cs_sles_amgx_setup (void *context, const char *name, const cs_matrix_t *a, int verbosity)
 Setup AmgX linear equation solver. More...
 
cs_sles_convergence_state_t cs_sles_amgx_solve (void *context, const char *name, const cs_matrix_t *a, int verbosity, double precision, double r_norm, int *n_iter, double *residue, const cs_real_t *rhs, cs_real_t *vx, size_t aux_size, void *aux_vectors)
 Call AmgX linear equation solver. More...
 
void cs_sles_amgx_free (void *context)
 Free AmgX linear equation solver setup context. More...
 
void cs_sles_amgx_log (const void *context, cs_log_t log_type)
 Log sparse linear equation solver info. More...
 
void cs_sles_amgx_library_info (cs_log_t log_type)
 Print information on AmgX library. More...
 

Detailed Description

handling of AmgX-based linear solvers

Function Documentation

◆ cs_sles_amgx_copy()

void* cs_sles_amgx_copy ( const void *  context)

Create AmgX linear system solver info and context based on existing info and context.

Parameters
[in]contextpointer to reference info and context (actual type: cs_sles_amgx_t *)
Returns
pointer to newly created solver info object. (actual type: cs_sles_amgx_t *)

◆ cs_sles_amgx_create()

cs_sles_amgx_t* cs_sles_amgx_create ( void  )

Create AmgX linear system solver info and context.

In case of rotational periodicity for a block (non-scalar) matrix, the matrix type will be forced to MATSHELL ("shell") regardless of the option used.

Returns
pointer to associated linear system object.

◆ cs_sles_amgx_define()

cs_sles_amgx_t* cs_sles_amgx_define ( int  f_id,
const char *  name 
)

Define and associate an AmgX linear system solver for a given field or equation name.

If this system did not previously exist, it is added to the list of "known" systems. Otherwise, its definition is replaced by the one defined here.

This is a utility function: if finer control is needed, see cs_sles_define and cs_sles_amgx_create.

In case of rotational periodicity for a block (non-scalar) matrix, the matrix type will be forced to MATSHELL ("shell") regardless of the option used.

Note that this function returns a pointer directly to the solver management structure. This may be used to set further options. If needed, cs_sles_find may be used to obtain a pointer to the matching cs_sles_t container.

Parameters
[in]f_idassociated field id, or < 0
[in]nameassociated name if f_id < 0, or NULL
Returns
pointer to newly created AmgX solver info object.

◆ cs_sles_amgx_destroy()

void cs_sles_amgx_destroy ( void **  context)

Destroy AmgX linear system solver info and context.

Parameters
[in,out]contextpointer to AmgX solver info and context (actual type: cs_sles_amgx_t **)

◆ cs_sles_amgx_free()

void cs_sles_amgx_free ( void *  context)

Free AmgX linear equation solver setup context.

This function frees resolution-related data, such as buffers and preconditioning but does not free the whole context, as info used for logging (especially performance data) is maintained.

Parameters
[in,out]contextpointer to AmgX solver info and context (actual type: cs_sles_amgx_t *)

◆ cs_sles_amgx_get_config()

const char* cs_sles_amgx_get_config ( void *  context)

return the configuration for an AmgX solver.

return the solver configuration for an AmgX solver.

Check the AmgX docummentation for configuration strings syntax.

Parameters
[in,out]contextpointer to AmgX solver info and context
Returns
configuration string

◆ cs_sles_amgx_get_config_file()

const char* cs_sles_amgx_get_config_file ( void *  context)

return the name of the solver configuration file for an AmgX solver.

Check the AmgX docummentation for configuration file syntax.

Parameters
[in,out]contextpointer to AmgX solver info and context
Returns
configuration file name, or NULL

◆ cs_sles_amgx_get_flags()

int cs_sles_amgx_get_flags ( void *  context)

Query additional AmgX solver usage flags.

Parameters
[in]contextpointer to AmgX solver info and context
Returns
associated flags

◆ cs_sles_amgx_get_pin_memory()

bool cs_sles_amgx_get_pin_memory ( void *  context)

Indicate whether an AmgX solver should pin host memory.

By default, host memory will be pinned for faster transfers. This setting is relevant only when not using unified memory.

Parameters
[in]contextpointer to AmgX solver info and context
Returns
true for device, false for host only

◆ cs_sles_amgx_get_use_device()

bool cs_sles_amgx_get_use_device ( void *  context)

Query whether an AmgX solver should use the device or host.

Define whether an AmgX solver should use the device or host.

Parameters
[in]contextpointer to AmgX solver info and context
Returns
true for device, false for host only

◆ cs_sles_amgx_library_info()

void cs_sles_amgx_library_info ( cs_log_t  log_type)

Print information on AmgX library.

Parameters
[in]log_typelog type

◆ cs_sles_amgx_log()

void cs_sles_amgx_log ( const void *  context,
cs_log_t  log_type 
)

Log sparse linear equation solver info.

Parameters
[in]contextpointer to AmgX solver info and context (actual type: cs_sles_amgx_t *)
[in]log_typelog type

◆ cs_sles_amgx_set_config()

void cs_sles_amgx_set_config ( void *  context,
const char *  config 
)

Define the solver configuration for an AmgX solver.

Define the configuration for an AmgX solver.

Check the AmgX docummentation for configuration strings syntax.

If this function is not called, a default configuration will be used.

Parameters
[in,out]contextpointer to AmgX solver info and context
[in]configstring defining configuration to use

◆ cs_sles_amgx_set_config_file()

void cs_sles_amgx_set_config_file ( void *  context,
const char *  path 
)

Set the solver configuration file for an AmgX solver.

Check the AmgX docummentation for configuration file syntax.

If this function is not called, a default configuration will be used.

Parameters
[in,out]contextpointer to AmgX solver info and context
[in]pathpath to configuration file

◆ cs_sles_amgx_set_flags()

void cs_sles_amgx_set_flags ( void *  context,
int  flags 
)

Define additional AmgX solver usage flags.

By default, the device will be used, but by calling this function with "use_device = false", only the host will be used.

Parameters
[in,out]contextpointer to AmgX solver info and context
[in]flagsflags (sum/bitwise of) for AmgX usage options.

◆ cs_sles_amgx_set_pin_memory()

void cs_sles_amgx_set_pin_memory ( void *  context,
bool  pin_memory 
)

Define whether an AmgX solver should pin host memory.

By default, host memory will be pinned for faster transfers, but by calling this function with "pin_memory = false", this may be deactivated. This setting is relevant only when not using unified memory.

Parameters
[in,out]contextpointer to AmgX solver info and context
[in]pin_memorytrue for devince, false for host only

◆ cs_sles_amgx_set_use_device()

void cs_sles_amgx_set_use_device ( void *  context,
bool  use_device 
)

Define whether an AmgX solver should use the device or host.

By default, the device will be used, but by calling this function with "use_device = false", only the host will be used.

Parameters
[in,out]contextpointer to AmgX solver info and context
[in]use_devicetrue for devince, false for host only

◆ cs_sles_amgx_setup()

void cs_sles_amgx_setup ( void *  context,
const char *  name,
const cs_matrix_t a,
int  verbosity 
)

Setup AmgX linear equation solver.

Parameters
[in,out]contextpointer to AmgX solver info and context (actual type: cs_sles_amgx_t *)
[in]namepointer to system name
[in]aassociated matrix
[in]verbosityassociated verbosity

◆ cs_sles_amgx_solve()

cs_sles_convergence_state_t cs_sles_amgx_solve ( void *  context,
const char *  name,
const cs_matrix_t a,
int  verbosity,
double  precision,
double  r_norm,
int *  n_iter,
double *  residue,
const cs_real_t rhs,
cs_real_t vx,
size_t  aux_size,
void *  aux_vectors 
)

Call AmgX linear equation solver.

Warning
The precision, r_norm, and n_iter parameters are ignored here. the matching configuration options should be set earlier, using the cs_sles_amgx_set_config function
Parameters
[in,out]contextpointer to AmgX solver info and context (actual type: cs_sles_amgx_t *)
[in]namepointer to system name
[in]amatrix
[in]verbosityassociated verbosity
[in]precisionsolver precision
[in]r_normresidue normalization
[out]n_iternumber of "equivalent" iterations
[out]residueresidue
[in]rhsright hand side
[in,out]vxsystem solution
[in]aux_sizenumber of elements in aux_vectors (in bytes)
aux_vectorsoptional working area (internal allocation if NULL)
Returns
convergence state