fix dsohandle bug

feature/design_of_v2_layer_converter
liaogang 8 years ago
parent 5b8fe87faf
commit afc84114ae

@ -32,7 +32,7 @@ void* lapack_dso_handle = nullptr;
#define DYNAMIC_LOAD_LAPACK_WRAP(__name) \ #define DYNAMIC_LOAD_LAPACK_WRAP(__name) \
struct DynLoad__##__name { \ struct DynLoad__##__name { \
template <typename... Args> \ template <typename... Args> \
int operator()(Args... args)->decltype(__name(args...)) { \ auto operator()(Args... args)->decltype(__name(args...)) { \
using lapack_func = decltype(__name(args...)) (*)(Args...); \ using lapack_func = decltype(__name(args...)) (*)(Args...); \
std::call_once(lapack_dso_flag, GetLapackDsoHandle, &lapack_dso_handle); \ std::call_once(lapack_dso_flag, GetLapackDsoHandle, &lapack_dso_handle); \
void* p_##__name = dlsym(lapack_dso_handle, #__name); \ void* p_##__name = dlsym(lapack_dso_handle, #__name); \
@ -47,15 +47,18 @@ void* lapack_dso_handle = nullptr;
__macro(clapack_sgetrf) \ __macro(clapack_sgetrf) \
__macro(clapack_dgetrf) \ __macro(clapack_dgetrf) \
__macro(clapack_sgetri) \ __macro(clapack_sgetri) \
__macro(clapack_dgetri) __macro(clapack_dgetri)
#else #else
#define LAPACK_ROUTINE_EACH(__macro) \ #define LAPACK_ROUTINE_EACH(__macro) \
__macro(LAPACKE_sgetrf) \ __macro(LAPACKE_sgetrf) \
__macro(LAPACKE_dgetrf) \ __macro(LAPACKE_dgetrf) \
__macro(LAPACKE_sgetri) \ __macro(LAPACKE_sgetri) \
__macro(LAPACKE_dgetri) __macro(LAPACKE_dgetri)
#endif #endif
#endif #endif
LAPACK_ROUTINE_EACH(DYNAMIC_LOAD_LAPACK_WRAP)
// clang-format on // clang-format on
} // namespace dynload } // namespace dynload

@ -12,12 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#ifndef HL_DYNAMIC_LOAD_H_ #ifndef DYNAMIC_LOAD_H_
#define HL_DYNAMIC_LOAD_H_ #define DYNAMIC_LOAD_H_
#include <dlfcn.h> #include <dlfcn.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include <mutex>
/** /**
* @brief load the DSO of CUBLAS * @brief load the DSO of CUBLAS
@ -59,4 +60,4 @@ void GetWarpCTCDsoHandle(void** dso_handle);
*/ */
void GetLapackDsoHandle(void** dso_handle); void GetLapackDsoHandle(void** dso_handle);
#endif // HL_DYNAMIC_LOAD_H_ #endif // DYNAMIC_LOAD_H_

Loading…
Cancel
Save