Rate This Document
Findability
Accuracy
Completeness
Readability

Migrating the Library That Uses the C Language

The following three parts need to be migrated:

  • Functions

    Replaceability shows the mapping between replaceable interfaces and MKL interfaces.

  • Function input parameters

    For some interfaces, the input parameter of the constant variable in MKL is a pointer, and the input parameter in KML interface is a value. For details, see Kunpeng Math Library Developer Guide.

  • Variable declaration

    The "MKL" prefix of some MKL variables need to be changed to "KML".

Example: csrmv interface

Before the migration:

#include "mkl_spblas.h"

char transa = 'N';
MKL_INT m = 4;
MKL_INT k = 4;
float alpha = 0.5;
float beta = 1.2;
char *matdescra = "G00F"; // General matrix, one-based indexing
float val[9] = {2, -3, 7, 1, -6, 8, -4, 5, 9};
MKL_INT indx[9] = {1, 2, 4, 3, 4, 1, 3, 4, 1};
MKL_INT pntrb[4] = {1, 4, 6, 9};
MKL_INT pntre[4] = {4, 6, 9, 10};
float x[4] = {1, 3, -2, 5};
float y[4] = {-1, 1, 5, 3};
mkl_scsrmv(&transa, &m, &k, &alpha, matdescra, val, indx, pntrb, pntre, x, &beta, y);
return 0;
/*
*  Output Y:
*
*     12.80  -14.80  26.50   8.10
*
* */

After the migration:

#include "kspblas.h"

kml_sparse_operation_t opt = KML_SPARSE_OPERATION_NON_TRANSPOSE;
KML_INT m = 4;
KML_INT k = 4;
float alpha = 0.5;
float beta = 1.2;
char *matdescra = "G00F"; // General matrix, one-based indexing
float val[9] = {2, -3, 7, 1, -6, 8, -4, 5, 9};
KML_INT indx[9] = {1, 2, 4, 3, 4, 1, 3, 4, 1};
KML_INT pntrb[4] = {1, 4, 6, 9};
KML_INT pntre[4] = {4, 6, 9, 10};
float x[4] = {1, 3, -2, 5};
float y[4] = {-1, 1, 5, 3};
kml_sparse_status_t status = kml_sparse_scsrmv(opt, m, k, alpha, ma tdescra, val, indx, pntrb, pntre, x, beta, y);
return status;
/*
*  Output Y:
*
*     12.80  -14.80  26.50   8.10
*
* */