Rate This Document
Findability
Accuracy
Completeness
Readability

Vectorization Method of the Bisheng Compiler

When using the Bisheng compiler, add -lksvml -fveclib=MATHLIB -lkm -lm to the link option and add the -O3 or -O2 option to provide the vector interface. -O3/-O2 is used to enable vectorization optimization, which is the prerequisite for the vectorized math library to take effect.

Examples

test.c:

#include <km.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
        long loop = 1e7;
        int len = 8192;
        float *a = (float*)malloc(sizeof(float) * len);
        float *b = (float*)malloc(sizeof(float) * len);
        float *d = (float*)malloc(sizeof(float) * len);
        for (int i = 0; i < len; i++) {
                a[i] = rand() * 7.7680f - 6.3840f;
                b[i] = rand() * 8.7680f - 6.3840f;
                d[i] = 0;
        }
        for (int i = 0; i < loop; i++) {
                for (int j = 0; j < len; j++) {
                        d[j] = expf(a[j]);
                }
        }
        return 1;
}

Compilation command:

clang test.c -lksvml -fveclib=MATHLIB -lkm -lm -O3

Run the nm command to check the called interface.

nm -D a.out

If the _ZGVnN4v_ prefix interface is displayed, the calling is successful.