diff --git a/gtestsuite/testinghelpers/src/common/refCBLAS.cpp b/gtestsuite/testinghelpers/src/common/refCBLAS.cpp index a0ed63ead..51df14ae7 100644 --- a/gtestsuite/testinghelpers/src/common/refCBLAS.cpp +++ b/gtestsuite/testinghelpers/src/common/refCBLAS.cpp @@ -1,4 +1,7 @@ #include +#ifdef REF_IS_MKL +#include +#endif #include "common/refCBLAS.h" namespace testinghelpers { @@ -7,6 +10,8 @@ refCBLAS::refCBLAS() { if (!refCBLASModule) { #ifdef REF_IS_MKL + // Dummy call to force linker, link OpenMP library if MKL is used. + omp_get_num_threads(); MKLCoreModule = dlopen(MKL_CORE, RTLD_GLOBAL | RTLD_LAZY); MKLGNUThreadModule = dlopen(MKL_GNU_THREAD, RTLD_GLOBAL | RTLD_LAZY); #endif diff --git a/gtestsuite/testsuite/CMakeLists.txt b/gtestsuite/testsuite/CMakeLists.txt index 07023072b..8e6bbf35f 100644 --- a/gtestsuite/testsuite/CMakeLists.txt +++ b/gtestsuite/testsuite/CMakeLists.txt @@ -37,7 +37,8 @@ foreach(dir ${DIRS}) set_target_properties(${target_name}.${dir}.${subdir} PROPERTIES OUTPUT_NAME ${target_name}.${dir}.${subdir}) target_include_directories(${target_name}.${dir}.${subdir} PUBLIC ${BLIS_INCLUDE} ${CMAKE_SOURCE_DIR}/testinghelpers/inc ${CMAKE_SOURCE_DIR}/testsuite/) target_link_libraries(${target_name}.${dir}.${subdir} gtest gtest_main testinghelpers ${Blis_LIBRARY} ${COMMON_LIBS}) - if(ENABLE_THREADING STREQUAL "openmp") + # if we test serial BLIS, but MKL is used as a reference we still need to set up OpenMP. + if( (ENABLE_THREADING STREQUAL "openmp") OR (REF_CBLAS STREQUAL "MKL")) if(LINUX) if(OpenMP_LIBRARY STREQUAL "GNU") target_link_libraries(${target_name}.${dir}.${subdir} -fopenmp)