Rate This Document
Findability
Accuracy
Completeness
Readability

KmlAmgMatrixCreate

Create a matrix handle.

Shallow copy is used during matrix creation. Ensure that the matrix created by KmlAmgMatrixCreate does not release the memory specified by the store parameter before the solution is complete.

Interface Definition

C interface:

KmlAmgStatus KmlAmgMatrixCreate(KmlAmgMatrixH* matrix, KmlAmgMatrixStore* store, const KmlAmgMatrixOptions* options);

Parameters

Parameter

Type

Description

Input/Output

matrix

KmlAmgMatrixH*

Matrix handle. matrix cannot be a null pointer.

Input/Output

store

KmlAmgMatrixStore*

Matrix format and data information structure.

Input

options

KmlAmgMatrixOptions*

Matrix configuration.

Input

Return Value

Return Value

Type

Description

KMLAMG_SUCCESS

int

Successful execution.

KMLAMG_ERR_INVALID_PARAM

int

Invalid parameter.

KMLAMG_ERR_UNSUPPORTED

int

Unsupported feature.

KMLAMG_ERR_NULL_POINTER

int

Null pointer

KMLAMG_ERR_NO_REQUIRED_FIELD

int

Required field not set.

KMLAMG_ERR_NO_MEMORY

int

Memory allocation failed.

KMLAMG_ERR_UNKNOWN_TYPE

int

Unknown type.

KMLAMG_ERR_UNEXPECTED_CALL_ORDER

int

Unexpected call order.

KMLAMG_ERR_NO_RESOURCE

int

Resources not ready.

KMLAMG_ERR_INCONSISTENT

int

Inconsistent information transferred in different phases.

KMLAMG_ERR_UNKNOWN_ERROR

int

Unknown error.

Structure Description

The table below describes the KmlAmgMatrixStore structure.

Table 1 KmlAmgMatrixStore structure

Field

Type

Description

globalNRows

int64_t

Number of global matrix rows.

globalNCols

int64_t

Number of global matrix columns.

localNRows

int64_t

Number of local matrix rows.

localNCols

int64_t

Number of local matrix columns.

type

KmlAmgMatrixStoreType

Matrix type. The options are as follows:

  • KMLAMG_MATRIX_STORE_CSR: matrix in CSR format
  • KMLAMG_MATRIX_STORE_CSC: matrix in CSC format (not supported currently)
  • KMLAMG_MATRIX_STORE_COO: matrix in COO format (not supported currently)
  • KMLAMG_MATRIX_STORE_DENSE_ROW_MAJOR: row-major matrix (Currently, the number of columns can only be 1, that is, vector.)
  • KMLAMG_MATRIX_STORE_DENSE_COL_MAJOR: column-major matrix (not supported currently)

partitionType

KmlAmgMatrixPartitionType

Matrix partition type. The options are as follows:

KMLAMG_MATRIX_PARTITION_ROW: row-based partition

KMLAMG_MATRIX_PARTITION_COL: column-based partition (not supported currently)

KMLAMG_MATRIX_PARTITION_NZ: non-zero element-based partition (not supported currently)

isAvgPart

int8_t

Whether the matrix is evenly partitioned. The value 0 indicates uneven partitioning, and a non-zero value indicates even partitioning.

localBegin

int64_t

Start row/column index of the matrix in the current process.

dense

KmlAmgMatrixStoreDense

This field is valid when type is set to KMLAMG_MATRIX_STORE_DENSE_ROW_MAJOR or KMLAMG_MATRIX_STORE_DENSE_COL_MAJOR. It stores the value of the matrix.

csr

KmlAmgMatrixStoreCSR

This field is valid when type is set to KMLAMG_MATRIX_STORE_CSR. It stores the triplet information of the CSR matrix.

csc

KmlAmgMatrixStoreCSC

This field is valid when type is set to KMLAMG_MATRIX_STORE_CSC. It stores the triplet information of the CSC matrix.

coo

KmlAmgMatrixStoreCOO

This field is valid when type is set to KMLAMG_MATRIX_STORE_COO. It stores the triplet information of the COO matrix.

The table below describes the KmlAmgMatrixOptions structure.

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.

valueType

KmlAmgValueType

Matrix value type. The options are as follows:

  • KMLAMG_VALUE_FP32: float
  • KMLAMG_VALUE_FP64: double

Mask bit: KMLAMG_MATRIX_OPTIONS_VALUE_TYPE

indexType

KmlAmgIndexType

Matrix index type. The options are as follows:

  • KMLAMG_INDEX_INT32: int32_t
  • KMLAMG_INDEX_INT64: int64_t (not supported currently)

Mask bit: KMLAMG_MATRIX_OPTIONS_INDEX_TYPE

comm

MPI_Comm

Communicator.

Mask bit: KMLAMG_MATRIX_OPTIONS_COMM

numThreads

int32_t

Number of threads.

Mask bit: KMLAMG_MATRIX_OPTIONS_NUM_THREADS

Using unsupported parameters will cause the program to exit abnormally.

Dependencies

#include "amg4c.h"