Vectorization Method of the BiSheng Compiler
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;
}
Compile 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.
Parent topic: Compiler Automatic Vectorization