Rate This Document
Findability
Accuracy
Completeness
Readability

KmlMgSolverSetPreconditioner

Set the preconditioner.

Interface Definition

C interface:

KmlMgStatus KmlMgSolverSetPreconditioner(KmlMgSolverH solver, const KmlMgPreconditionerOptions* options);

Parameters

Parameter

Type

Description

Input/Output

solver

KmlMgSolverH

Solver handle created by KmlMgSolverCreate

Input/Output

options

const KmlMgPreconditionerOptions*

Preconditioner configuration information, that is, multigrid configuration information

Input

Return Value

Return Value

Type

Description

KML_MG_OK

int

The execution is successful.

KML_MG_ERR_INVALID_PARAM

int

The parameter is invalid.

KML_MG_ERR_UNSUPPORTED

int

Unsupported feature.

KML_MG_ERR_NO_MEMORY

int

Memory allocation failed.

KML_MG_ERR_EXCEEDS_LIMIT

int

The parameter is 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

The matrix value is null.

KML_MG_ERR_NO_RESOURCE

int

Resources not ready.

Structure Descriptions

KmlMgPreconditionerOptions

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_PRECONDITIONER_OPTIONS_INDEX_TYPE

kspValueType

KmlMgValueType

Value type of the input matrix. (Currently, it must match that of the kspValueType field in KmlMgSolverOptions. The supported precision combinations are as follows.)

  • KML_MG_VALUE_FP16
  • KML_MG_VALUE_FP32
  • KML_MG_VALUE_FP64

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_KSP_VALUE_TYPE

valueType

KmlMgValueType

Value type of the preconditioner (multigrid). The options are as follows: (Currently, it must match that of the pcValueType field in KmlMgSolverOptions.)

  • KML_MG_VALUE_FP16
  • KML_MG_VALUE_FP32
  • KML_MG_VALUE_FP64

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_VALUE_TYPE

calcType

KmlMgValueType

Calculation value type of the preconditioner (multigrid). The options are as follows: (Currently, it must match that of the pcCalcType field in KmlMgSolverOptions.)

  • KML_MG_VALUE_FP16
  • KML_MG_VALUE_FP32
  • KML_MG_VALUE_FP64

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_CALC_TYPE

numLevels

int64_t

Number of multigrid levels

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_NUM_LEVEL

shiftLevelId

int64_t

ID of a level at which mixed precision shifts to single precision.

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_SHIFT_LEVEL

cycle

KmlMgCycleType

The options are as follows:

  • KML_MG_CYCLE_V
  • KML_MG_CYCLE_W (not supported currently)

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_CYCLE_TYPE

gridSweep

void*

Sweep array for multigrid. The type is specified by indexType and the length is 2.

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_SWEEP

xpss

void*

XPSS array (X-Process Shrink Strides), indicating the stride of process shrinkage in the X direction. The type is specified by indexType, and the length equals the numLevels value.

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_XPSS

smoother

KmlMgSmootherType*

Array of smoother types for each grid level. The length equals the numLevels value. The options are as follows:

  • KML_MG_SMOOTHER_POINT_JACOBI
  • KML_MG_SMOOTHER_POINT_GS
  • KML_MG_SMOOTHER_LINE_JACOBI
  • KML_MG_SMOOTHER_LINE_GS
  • KML_MG_SMOOTHER_PLANE_ILU
  • KML_MG_SMOOTHER_SHUFFLE_PLANE_ILU
  • KML_MG_SMOOTHER_BLOCK_ILU
  • KML_MG_SMOOTHER_ADI
  • KML_MG_SMOOTHER_BLOCK_LU (not supported currently)
  • KML_MG_SMOOTHER_LU (not supported currently)
  • KML_MG_SMOOTHER_CUSTOM (not supported currently)

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_SMOOTHER

weight

void*

Smoother weight. The type is specified by calcType, and the length equals the numLevels value.

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_WEIGHT

coarsen

KmlMgCoarsenType*

Grid coarsening method. The length equals the numLevels value. The options are as follows:

  • KML_MG_COARSEN_FULL_XYZ
  • KML_MG_COARSEN_SEMI_XY
  • KML_MG_COARSEN_SEMI_XZ (not supported currently)
  • KML_MG_COARSEN_SEMI_YZ (not supported currently)
  • KML_MG_COARSEN_SEMI_Z (not supported currently)
  • KML_MG_COARSEN_FULL_XZ (not supported currently)

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_COARSEN

rest

KmlMgRestInteType*

Restriction operator. The length equals the numLevels value. The options are as follows:

  • KML_MG_REST_INTE_VTX_1D1 (not supported currently)
  • KML_MG_REST_INTE_VTX_1D3 (not supported currently)
  • KML_MG_REST_INTE_VTX_2D1 (not supported currently)
  • KML_MG_REST_INTE_VTX_2D5 (not supported currently)
  • KML_MG_REST_INTE_VTX_2D9 (not supported currently)
  • KML_MG_REST_INTE_CELL_2D4
  • KML_MG_REST_INTE_CELL_2D16
  • KML_MG_REST_INTE_CELL_3D8
  • KML_MG_REST_INTE_CELL_3D64

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_RESTRICT

interp

KmlMgRestInteType*

Interpolation operator. The length equals the numLevels value. The options are as follows:

  • KML_MG_REST_INTE_VTX_1D1 (not supported currently)
  • KML_MG_REST_INTE_VTX_1D3 (not supported currently)
  • KML_MG_REST_INTE_VTX_2D1 (not supported currently)
  • KML_MG_REST_INTE_VTX_2D5 (not supported currently)
  • KML_MG_REST_INTE_VTX_2D9 (not supported currently)
  • KML_MG_REST_INTE_CELL_2D4
  • KML_MG_REST_INTE_CELL_2D16
  • KML_MG_REST_INTE_CELL_3D8
  • KML_MG_REST_INTE_CELL_3D64

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_PROLONG

alpha

void*

Galerkin operator scaling coefficient. The type is specified by calcType, and the length equals the numLevels value.

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_ALPHA

control

bool*

Controls whether the stencil of the coarsened grid is consistent with that of the previous level. If the value is true, the stencil is consistent with that of the previous level. If the value is false, the stencil may expand. The length equals the numLevels value.

Mask bit: KML_MG_PRECONDITIONER_OPTIONS_CONTROL

Using unsupported parameters will cause the program to exit abnormally.

Dependencies

#include "mg.h"

For details about the sample code, see Examples.