我要评分
获取效率
正确性
完整性
易理解

Samples

Before using the KML_RT runtime dynamic library, ensure that the dynamic library libkml_rt.so is correctly located in the root directory of your KML installation path (typically established after installing HPCKit or KML RPM package). The library cannot be loaded or executed if it is missing from this path.

For example, when sgemm function in KML_BLAS level 3 is called, you do not need to change its application compilation and header file references; however, you need to use the KML_RT library during compilation.

Dependencies

#include "kblas.h"

Examples

main.c:

    int m = 4, k = 3, n = 4, lda = 4, ldb = 3, ldc = 4; 
    float alpha = 1.0, beta = 2.0; 
     /* 
     * A: 
     *     0.340188,       0.411647,       -0.222225, 
     *     -0.105617,      -0.302449,      0.053970, 
     *     0.283099,       -0.164777,      -0.022603, 
     *     0.298440,       0.268230,       0.128871, 
     * B: 
     *     -0.135216,      0.416195,       -0.358397,      -0.257113, 
     *     0.013401,       0.135712,       0.106969,       -0.362768, 
     *     0.452230,       0.217297,       -0.483699,      0.304177, 
     * C: 
     *     -0.343321,      0.498924,       0.112640,       -0.006417, 
     *     -0.099056,      -0.281743,      -0.203968,      0.472775, 
     *     -0.370210,      0.012932,       0.137552,       -0.207483, 
     *     -0.391191,      0.339112,       0.024287,       0.271358, 
     */ 
    float a[12] = {0.340188, -0.105617, 0.283099, 
                    0.298440, 0.411647, -0.302449, 
                    -0.164777, 0.268230, -0.222225, 
                    0.053970, -0.022603, 0.128871}; 
    float b[12] = {-0.135216, 0.013401, 0.452230, 0.416195, 
                    0.135712, 0.217297, -0.358397, 0.106969, 
                    -0.483699, -0.257113, -0.362768, 0.304177}; 
    float c[16] = {-0.343321, -0.099056, -0.370210, -0.391191, 
                    0.498924, -0.281743, 0.012932, 0.339112, 
                    0.112640, -0.203968, 0.137552, 0.024287, 
                    -0.006417, 0.472775, -0.207483, 0.271358}; 
 
    cblas_sgemm(CblasColMajor,CblasNoTrans,CblasNoTrans, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc); 
    /* 
     * Output C: 
     *     -0.827621       1.147010        0.254881        -0.317229 
     *     -0.163476       -0.636762       -0.428542       1.098841 
     *     -0.791128       0.116416        0.166949        -0.434854 
     *     -0.760862       0.866839        -0.092028       0.407877 
     * 
     */

Compilation

gcc main.c -o main -I /usr/local/kml/include -L /usr/local/kml/lib -lkml_rt