-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Description
An undefined reference linking error was detected during testing. This error arises because the symbol prefix/suffix for the function openblas_set_threads_callback_function in the dynamic library is missing after SYMBOLPREFIX or SYMBOLSUFFIX is defined (this feature was introduced by PR #4577). When SYMBOLPREFIX or SYMBOLSUFFIX is configured in the Makefile, the function signature of SYMBOLPREFIX_openblas_set_threads_callback_function_SYMBOLSUFFIX in the header file cblas.h is modified (with the configured prefix/suffix added), but the function name in the dynamic link library remains unmodified, resulting in an undefined reference.
Steps to Reproduce
- Set
SYMBOLPREFIXorSYMBOLSUFFIXin the Makefile (e.g.,SYMBOLSUFFIX=_smp). - Compile the OpenBLAS dynamic library.
- Compile and link the following test code against the compiled library:
#include <omp.h> #include "cblas.h" void myfunction_(int sync, openblas_dojob_callback_smp dojob, int numjobs, size_t jobdata_elsize, void *jobdata, int dojob_data) { #pragma omp parallel for for(int i = 0; i < numjobs; i++) { void *element_addr = (void *) (((char *)jobdata) + ((unsigned) i) * jobdata_elsize); dojob(i, element_addr, dojob_data); } return; } int main() { openblas_set_num_threads_smp(4); omp_set_num_threads(4); openblas_set_threads_callback_function_smp(myfunction_); return 0; }
- Trigger the linking error: undefined reference to `openblas_set_threads_callback_function_smp'
Root Cause
openblas_set_threads_callback_function is not included in the exports/gensymbol and exports/gensymbol.py files. As a result, the symbol generation script does not apply the SYMBOLPREFIX/SYMBOLSUFFIX configured in the Makefile to the openblas_set_threads_callback_function when processing the dynamic library.
Related PR
The original PR that introduced the openblas_set_threads_callback_function feature: #4577