Originally posted by: ChristineLi
Q1: When will I come across references to __xl_* math functions?
When compiling with IBM XL compilers, you might have come across references to __xl_* math functions, for example, in error messages such as:
undefined reference to `__xl_cos'
ld: 0711-317 ERROR: Undefined symbol: .__xl_log
or when doing performance profiling, such as:
4.23% my_app my_app [.] __xl_pow
2.84% my_app my_app [.] __xl_sin
1.35% my_app my_app [.] __xl_exp
0.61% my_app my_app [.] __xl_tan
Q2: Why do I see the references to __xl_* math functions?
When you enable an optimization level of -O3 or higher, IBM XL compilers may replace calls to libm math functions with calls to a high performance math library called libxlopt.a. If you use an XL compiler to link, it'll automatically statically link in libxlopt.a. The __xl_* functions are provided by that library.
Q3: How to fix "undefined references to __xl_*"?
If you get errors at link time stating that the functions cannot be found (undefined reference or undefined symbol), make sure you are using the XL compiler to link. If you prefer to link with another compiler, add -L<path to directory containing libxlopt.a> -lxlopt to your link line. The path to libxlopt.a depends on which platform you're running the compiler on, for example /opt/ibm/xlC/16.1.0/lib for XL C/C++ for Linux, V16.1.
Q4: How to disable the __xl_* function calls?
The __xl_* functions may make slight accuracy tradeoffs in the interest of increased performance. If you don't want the __xl_* function calls, for example to preserve exact agreement with libm results, compile with -qstrict=library or -qhot=nofastmath.
Q5: What is the XLOPT library (libxlopt.a)?
The XLOPT library (libxlopt.a) contains functions that the XL compilers may generate calls to, including the following mathematical functions:
- Four Basic Linear Algebra Subprograms (BLAS) functions (More information available at IBM Knowledge Center):
- sgemv (single-precision) and dgemv (double-precision), which compute the matrix-vector product and sum for a general matrix or its transpose
- sgemm (single-precision) and dgemm (double-precision), which perform combined matrix multiplication and addition for general matrices or their transposes
- Mathematical Acceleration Subsystem (MASS) functions for automatic vectorization or scalarization
Q6: When to ship the XLOPT library and where to find the redistributable XLOPT library?
The XLOPT library is statically linked into your application, so you do not need to ship the libxlopt.a archive with your application. However, if you ship object files or archives with the intention of linking the application on your users' systems, you need to also ship the libxl*-devel package. The package contains the XLOPT library as well as other static libraries that object files compiled with the IBM XL compilers depend on. The package is stored under the images/rpms directory in the installed compiler package.