Hi all,
I am using ArmPL 22 and want to use some functions in libamath, like exp, log, cos etc. By dumping libamath.so I can find intrinsics like armpl_svexp_f32_x, but it does not compile and I can not find any documents or examples. Could someone help me to compile SVE codes with ArmPL?
Thanks
Hello,
Could you please share the command line and error message, so we can help you better?
First of all, armpl_ prefixed names can be handy but we do not expect people to know about them.
We recommend to use the standard symbol names declared in math.h.
The standard ABI for vector routines is defined here:
https://github.com/ARM-software/abi-aa/blob/320a56971fdcba282b7001cf4b84abb4fd993131/vfabia64/vfabia64.rst
or in pdf form
https://github.com/ARM-software/abi-aa/releases/download/2021Q3/vfabia64.pdf.
It basically tells you that standard names for SVE are
or alternatively for non-predicated versions
So instead of armpl_svexp_f64_x(svfloat64_t, svbool_t) you want to use _ZGVsMxv_exp(svfloat64_t, svbool_t).
You can find some information to get started with ArmPL and libamath here https://developer.arm.com/documentation/102574/0100/Optimized-math-routines---libamath.
You will also find information on how to compile for SVE with armclang here https://developer.arm.com/documentation/101458/2200/Compile-and-Link.
Hi Blanchard,Thank you for the reply! I am trying to compile a simple program as follow:#include <math.h>#include <arm_sve.h>#include <armpl.h>int main() { svfloat32_t x = svdup_f32(4.0); svbool_t p_all = svptrue_b32(); svfloat32_t y = _ZGVsMxv_exp(x, p_all); return 0;}
The command line I use is:gcc -O3 -march=armv8-a+sve -o test test.c -lamath -lm And the error I get is:test.c: In function ‘main’:test.c:9:21: warning: implicit declaration of function ‘_ZGVsMxv_exp’ [-Wimplicit-function-declaration] 9 | svfloat32_t y = _ZGVsMxv_exp(x, p_all); | ^~~~~~~~~~~~test.c:9:21: error: incompatible types when initializing type ‘svfloat32_t’ using type ‘int’
Ok, you are almost there. You simply need to use the single precision version, which is _ZGVsMxv_expf.
I am still getting the same error with both gcc 10 and 11, and the library I am using is 22.0 (free version)
test.c: In function ‘main’:test.c:9:21: warning: implicit declaration of function ‘_ZGVsMxv_expf’ [-Wimplicit-function-declaration] 9 | svfloat32_t y = _ZGVsMxv_expf(x, p_all); | ^~~~~~~~~~~~~test.c:9:21: error: incompatible types when initializing type ‘svfloat32_t’ using type ‘int’
Or if I change the type of y from
svfloat32_t y = _ZGVsMxv_expf(x, p_all);
to
int y = _ZGVsMxv_expf(x, p_all);
The error becomes
test.c:9:13: error: SVE type ‘svfloat32_t’ cannot be passed to an unprototyped function 9 | int y = _ZGVsMxv_expf(x, p_all); | ^~~~~~~~~~~~~~~~~~~~~~~
I can compile the example from
https://developer.arm.com/documentation/102620/0100/Compile-and-test-the-examples
So I think I have set the environment correctly.
Right, math.h don't seem to expose the SVE symbols. You will have to declare the one you want to use manually in the header of your file, like that:
svfloat32_t _ZGVsMxv_expf(svfloat32_t, svbool_t);
svfloat32_t _ZGVsNxv_expf(svfloat32_t);
Thank you so much, it finally works!