|
opm-simulators
|
Unified interface for AMGX operations with both CPU and GPU data structures. More...
#include <AmgxInterface.hpp>
Static Public Member Functions | |
| static void | initialize () |
| Initialize the AMGX library. | |
| static void | finalize () |
| Finalize the AMGX library. | |
| static AMGX_config_handle | createConfig (const std::string &config_string) |
| Create an AMGX config handle from a configuration string. | |
| static AMGX_resources_handle | createResources (AMGX_config_handle config) |
| Create AMGX resources from a config. | |
| static AMGX_solver_handle | createSolver (AMGX_resources_handle resources, AMGX_Mode mode, AMGX_config_handle config) |
| Create an AMGX solver. | |
| static AMGX_matrix_handle | createMatrix (AMGX_resources_handle resources, AMGX_Mode mode) |
| Create an AMGX matrix. | |
| static AMGX_vector_handle | createVector (AMGX_resources_handle resources, AMGX_Mode mode) |
| Create an AMGX vector. | |
| static void | destroyConfig (AMGX_config_handle config) |
| Destroy an AMGX config handle. | |
| static void | destroyResources (AMGX_resources_handle resources) |
| Destroy an AMGX resources handle. | |
| static void | destroySolver (AMGX_solver_handle solver) |
| Destroy an AMGX solver handle. | |
| template<typename MatrixType> | |
| static void | destroyMatrix (AMGX_matrix_handle amgx_matrix, const MatrixType &matrix) |
| Destroy an AMGX matrix handle. | |
| static void | destroyVector (AMGX_vector_handle vector) |
| Destroy an AMGX vector handle. | |
| template<typename T> | |
| static void | updateAmgxFromGpuVector (const GpuVector< T > &gpu_vec, AMGX_vector_handle amgx_vec) |
| Update an AMGX vector from a GpuVector (device-to-device transfer). | |
| template<typename T> | |
| static void | updateGpuVectorFromAmgx (AMGX_vector_handle amgx_vec, GpuVector< T > &gpu_vec) |
| Update a GpuVector from an AMGX vector (device-to-device transfer). | |
| template<typename VectorType> | |
| static void | transferVectorToAmgx (const VectorType &vec, AMGX_vector_handle amgx_vec) |
| Transfer vector to AMGX from any vector type (CPU or GPU). | |
| template<typename VectorType> | |
| static void | transferVectorFromAmgx (AMGX_vector_handle amgx_vec, VectorType &vec) |
| Transfer vector from AMGX to any vector type (CPU or GPU). | |
| template<typename T> | |
| static void | updateAmgxMatrixFromGpuSparseMatrix (const GpuSparseMatrixWrapper< T > &gpuSparseMatrix, AMGX_matrix_handle amgxMatrix) |
| Update an AMGX matrix from a GpuSparseMatrixWrapper (device-to-device transfer). | |
| template<typename T> | |
| static void | updateAmgxMatrixCoefficientsFromGpuSparseMatrix (const GpuSparseMatrixWrapper< T > &gpuSparseMatrix, AMGX_matrix_handle amgxMatrix) |
| Update only the coefficient values of an AMGX matrix from a GpuSparseMatrix. | |
| template<typename T> | |
| static void | updateGpuSparseMatrixFromAmgxMatrix (AMGX_matrix_handle amgxMatrix, GpuSparseMatrixWrapper< T > &gpuSparseMatrix) |
| Update a GpuSparseMatrixWrapper from an AMGX matrix (device-to-device transfer). | |
| template<typename MatrixType> | |
| static void | initializeMatrix (const MatrixType &matrix, AMGX_matrix_handle amgx_matrix) |
| Initialize an AMGX matrix from any matrix type (CPU or GPU). | |
| static void | initializeVector (int N, int block_size, AMGX_vector_handle amgx_vector) |
| Initialize an AMGX vector with zeros. | |
| template<typename MatrixType> | |
| static void | updateMatrixValues (const MatrixType &matrix, AMGX_matrix_handle amgx_matrix) |
| Update matrix values in AMGX. | |
| template<typename MatrixFieldType, typename VectorFieldType> | |
| static AMGX_Mode | determineAmgxMode () |
| Determine the appropriate AMGX mode based on matrix and vector field types. | |
Unified interface for AMGX operations with both CPU and GPU data structures.
This class provides utilities for working with AMGX resources and transferring data between CPU/GPU data structures and AMGX handles. It handles type detection and automatically chooses the most efficient transfer method:
|
inlinestatic |
Create an AMGX config handle from a configuration string.
| config_string | Configuration string for AMGX |
| AmgxError | if config creation fails |
|
inlinestatic |
Create an AMGX matrix.
| resources | AMGX resources handle |
| mode | AMGX mode (precision configuration) |
| AmgxError | if matrix creation fails |
|
inlinestatic |
Create AMGX resources from a config.
| config | The AMGX config handle |
| AmgxError | if resource creation fails |
|
inlinestatic |
Create an AMGX solver.
| resources | AMGX resources handle |
| mode | AMGX mode (precision configuration) |
| config | AMGX config handle |
| AmgxError | if solver creation fails |
|
inlinestatic |
Create an AMGX vector.
| resources | AMGX resources handle |
| mode | AMGX mode (precision configuration) |
| AmgxError | if vector creation fails |
|
inlinestatic |
Destroy an AMGX config handle.
| config | The config handle to destroy |
| AmgxError | if config destruction fails |
|
inlinestatic |
Destroy an AMGX matrix handle.
| amgx_matrix | The matrix handle to destroy |
| matrix | The type of the matrix |
| AmgxError | if matrix destruction fails |
|
inlinestatic |
Destroy an AMGX resources handle.
| resources | The resources handle to destroy |
| AmgxError | if resource destruction fails |
|
inlinestatic |
Destroy an AMGX solver handle.
| solver | The solver handle to destroy |
| AmgxError | if solver destruction fails |
|
inlinestatic |
Destroy an AMGX vector handle.
| vector | The vector handle to destroy |
| AmgxError | if vector destruction fails |
|
inlinestatic |
Determine the appropriate AMGX mode based on matrix and vector field types.
| MatrixFieldType | The field type of the matrix |
| VectorFieldType | The field type of the vector |
| std::runtime_error | if the type combination is not supported |
|
inlinestatic |
Finalize the AMGX library.
This should be called once at the end of the program to release AMGX resources.
| AmgxError | if finalization fails |
|
inlinestatic |
Initialize the AMGX library.
This should be called once at the start of the program before using any AMGX functionality.
| AmgxError | if initialization fails |
|
inlinestatic |
Initialize an AMGX matrix from any matrix type (CPU or GPU).
Selects the transfer method based on the matrix type.
| matrix | Source matrix (typically BCRSMatrix (CPU) or GpuSparseMatrixWrapper (GPU)) |
| amgx_matrix | Destination AMGX matrix |
| AmgxError | if initialization fails |
|
inlinestatic |
Initialize an AMGX vector with zeros.
Creates a zero-initialized vector of the appropriate size.
| N | Size of the vector |
| block_size | Block size (typically 1 for scalar vectors) |
| amgx_vector | The AMGX vector to initialize |
| AmgxError | if initialization fails |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Update an AMGX vector from a GpuVector (device-to-device transfer).
Updates the AMGX vector with the contents of the GpuVector using direct device memory access. The AMGX vector must already be created with appropriate resources and mode.
| gpu_vec | The source GpuVector |
| amgx_vec | The AMGX vector to update |
| AmgxError | if the transfer fails or sizes mismatch |
|
inlinestatic |
Update only the coefficient values of an AMGX matrix from a GpuSparseMatrix.
Updates just the coefficient values of an AMGX matrix without changing its sparsity pattern. This is more efficient when the matrix structure remains the same.
| gpuSparseMatrix | The source GpuSparseMatrixWrapper with updated values |
| amgxMatrix | The AMGX matrix to update |
| AmgxError | if the update fails |
|
inlinestatic |
Update an AMGX matrix from a GpuSparseMatrixWrapper (device-to-device transfer).
Uploads the entire matrix structure and values from GpuSparseMatrixWrapper to AMGX.
| gpuSparseMatrix | The source GpuSparseMatrix |
| amgxMatrix | The AMGX matrix to update |
| AmgxError | if the transfer fails |
|
inlinestatic |
Update a GpuSparseMatrixWrapper from an AMGX matrix (device-to-device transfer).
Downloads the matrix data from AMGX and updates the GpuSparseMatrixWrapper with the values. The sparsity pattern is assumed to be identical, so only values are updated.
| amgxMatrix | The source AMGX matrix |
| gpuSparseMatrix | The GpuSparseMatrixWrapper to update |
| AmgxError | if the transfer fails |
|
inlinestatic |
|
inlinestatic |
Update matrix values in AMGX.
Selects the update method based on the matrix type. Updates the coefficients of an AMGX matrix, without changing its sparsity pattern.
| matrix | Source matrix with updated values |
| amgx_matrix | AMGX matrix to update |
| AmgxError | if the update fails |