From 04e091fdca6bf9c5fff72c1a267a2d2ef8e8571e Mon Sep 17 00:00:00 2001 From: Eleni Vlachopoulou Date: Tue, 28 Mar 2023 00:26:22 +0530 Subject: [PATCH] BLIS GTestSuite: Link OpenMP if we test serial BLIS, but MKL is used as a reference. Change-Id: Iacafa5ecf74622fa5e1180a81305cf7a23d79055 --- gtestsuite/testinghelpers/src/common/refCBLAS.cpp | 5 +++++ gtestsuite/testsuite/CMakeLists.txt | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) 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)