我要评分
获取效率
正确性
完整性
易理解

KmlMgSolverCreate

Create a solver handle.

Interface Definition

C interface:

KmlMgStatus KmlMgSolverCreate(KmlMgSolverH* pSolver, MPI_Comm comm, const KmlMgSolverOptions* options);

Parameters

Parameter

Type

Description

Input/Output

pSolver

KmlMgSolverH*

Solver handle. solver cannot be a null pointer.

Input/Output

comm

MPI_Comm

Solver communicator, which must be the same as that in the matrix to be solved. Otherwise, unknown problems may occur.

Input

options

const KmlMgSolverOptions*

Solver configuration.

Input

Return Value

Return Value

Type

Description

KML_MG_OK

int

Normal execution.

KML_MG_ERR_INVALID_PARAM

int

Invalid parameter.

MG_ERR_UNSUPPORTED

int

Unsupported feature.

KML_MG_ERR_NO_MEMORY

int

Memory allocation failed.

KML_MG_ERR_EXCEEDS_LIMIT

int

Value out of the valid range.

KML_MG_ERR_INCOMPATIBLE

int

Incompatible version.

KML_MG_ERR_NO_REQUIRED_FIELD

int

Required field not set.

KML_MG_ERR_UNKNOWN_TYPE

int

Unknown type.

KML_MG_ERR_THIRD_PART

int

Internal third-party call error.

KML_MG_ERR_INCONSISTENT

int

Inconsistent information transferred.

KML_MG_ERR_UNEXPECTED_CALL_ORDER

int

Unexpected call order.

KML_MG_ERR_MATRIX_VALUE_IS_NULL

int

Null matrix value.

KML_MG_ERR_NO_RESOURCE

int

Resources not ready.

Structure Description

KmlMgSolverOptions

Field

Type

Description

fieldMask

uint64_t

Mask that determines to which fields the configuration is applied. If a bit is set to 1, its corresponding field uses a specified value. If a bit is set to 0, its corresponding field uses the default value. See the individual field description for configurable mask bits.

indexType

KmlMgIndexType

Coordinate type. The options are as follows:

  • KML_MG_INDEX_INT32 (Currently, only 32-bit int is supported.)
  • KML_MG_INDEX_INT64

Mask bit: KML_MG_SOLVER_OPTIONS_INDEX_TYPE

kspValueType

KmlMgValueType

Value type of the input matrix. (Currently, it must match that of the pcCalcType field. The supported precision is as follows.)

  • KML_MG_VALUE_FP16
  • KML_MG_VALUE_FP32
  • KML_MG_VALUE_FP64

Mask bit: KML_MG_SOLVER_OPTIONS_KSP_VALUE_TYPE

pcValueType

KmlMgValueType

Value type of the preconditioner (multigrid). The options are as follows: (Currently, only FP16, FP32, and FP64 are supported.)

  • KML_MG_VALUE_FP16
  • KML_MG_VALUE_FP32
  • KML_MG_VALUE_FP64

Mask bit: KML_MG_MATRIX_INFO_STORE

pcCalcType

KmlMgValueType

Calculation value type of the preconditioner (multigrid). The options are as follows: (Currently, only FP32 and FP64 are supported.)

  • KML_MG_VALUE_FP16
  • KML_MG_VALUE_FP32
  • KML_MG_VALUE_FP64

Mask bit: KML_MG_MATRIX_INFO_STORE

ksp

KmlMgSolverKsp

Krylov subspace method type. The options are as follows:

  • KML_MG_SOLVER_NONE
  • KML_MG_SOLVER_BICG
  • KML_MG_SOLVER_CG
  • KML_MG_SOLVER_CR
  • KML_MG_SOLVER_GCR
  • KML_MG_SOLVER_GMRES

Mask bit: KML_MG_MATRIX_INFO_STORE

The table below describes the supported precision combinations.

Combination

kspValueType

pcValueType

pcCalcType

1

KML_MG_VALUE_FP64

KML_MG_VALUE_FP64

KML_MG_VALUE_FP64

2

KML_MG_VALUE_FP32

KML_MG_VALUE_FP32

KML_MG_VALUE_FP32

3

KML_MG_VALUE_FP32

KML_MG_VALUE_FP16

KML_MG_VALUE_FP32

Dependencies

#include "mg.h"

For details about the sample code, see Examples.