迁移步骤
C语言迁移步骤
MKL提供了C接口,KML_SOLVER同样提供了C接口,但接口名及接收参数不一致,需要进行对应功能的切换。
- 初始化。
迁移前:
const MKL_INT n = 8; MKL_INT ia[9]; MKL_INT ja[18]; double a[18]; MKL_INT rci_request; double rhs[8] = {0.0}; double solution[8] = {0.0}; double expected_sol[8]; MKL_INT ipar[128]; double dpar[128], tmp[4 * 8] = {0.0}; sparse_matrix_t csrA; struct matrix_descr descrA; sparse_operation_t transA; ...... mkl_sparse_d_create_csr ( &csrA, SPARSE_INDEX_BASE_ONE, n, n, ia, ia+1, ja, a ); mkl_sparse_d_mv( transA, 1.0, csrA, descrA, expected_sol, 0.0, rhs); dcg_init (&n, solution, rhs, &rci_request, ipar, dpar, tmp);
迁移后:int n = 8; int ia[9]; int ja[17]; double a[17]; void* handle; int error = KmlIssCgInitDI(&handle, &n, a, ja, ia);
- 求解。
迁移后:
double b[8]; /* Solution vector */ double x[8]; int nrhs = 1;/* Number of right-hand sides */ int ldx=n, ldb=n;/*!Leading dimension of B and X */ int error = KmlIssCgSolveDI(&handle, &nrhs, x, &ldx, b, &ldb);
- 获取迭代参数。
迁移后:
int *data; // user data. int nd = 1; int error = KmlIssCgGetDII(&handle, ITERATION_COUNT, data, nd);
- 清除。
迁移后:
KmlIssCgCleanDI(&handle);
- 头文件。
#include "mkl_rci.h"
#include "mkl_spblas.h"
#include "mkl_service.h"
迁移后:
#include "kml_iss.h"
- 编译链接库。