@@ -29,13 +29,20 @@ void* lapack_dso_handle = nullptr;
2929 *
3030 * note: default dynamic linked libs
3131 */
32+
33+ // The argument for stringizing operator is not macro-expanded first.
34+ // We have to use two levels of macro to do the expansion.
35+ // See https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
36+ #define STR (x ) #x
3237#define DYNAMIC_LOAD_LAPACK_WRAP (__name ) \
3338 struct DynLoad__ ##__name { \
3439 template <typename ... Args> \
3540 auto operator ()(Args... args) -> decltype(__name(args...)) { \
3641 using lapack_func = decltype (__name (args...)) (*)(Args...); \
3742 std::call_once (lapack_dso_flag, GetLapackDsoHandle, &lapack_dso_handle); \
38- void * p_##__name = dlsym (lapack_dso_handle, #__name); \
43+ void * p_##__name = dlsym (lapack_dso_handle, STR (__name)); \
44+ CHECK (p_##__name) << " Cannot find symbol " << STR (__name) \
45+ << " in liblapack.so" ; \
3946 return reinterpret_cast <lapack_func>(p_##__name)(args...); \
4047 } \
4148 } __name; // struct DynLoad__##__name
@@ -51,7 +58,7 @@ void* lapack_dso_handle = nullptr;
5158 #define PADDLE_DGETRF LAPACKE_dgetrf
5259 #define PADDLE_SGETRI LAPACKE_sgetri
5360 #define PADDLE_DGETRI LAPACKE_dgetri
54- #endif
61+ #endif
5562
5663#define LAPACK_ROUTINE_EACH (__macro ) \
5764 __macro (PADDLE_SGETRF) \
0 commit comments