Skip to content

Commit 2855e60

Browse files
authored
Merge pull request #2841 from martin-frbg/cpp_gemvtest
Make thread safety tests available to CMAKE and support running only the GEMV version
2 parents 144a034 + 6abca76 commit 2855e60

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ option(NO_AFFINITY "Disable support for CPU affinity masks to avoid binding proc
2929
else()
3030
set(NO_AFFINITY 1)
3131
endif()
32+
option(CPP_THREAD_SAFETY_TEST "Run a massively parallel DGEMM test to confirm thread safety of the library (requires OpenMP and about 1.3GB of RAM)" OFF)
33+
option(CPP_THREAD_SAFETY_GEMV "Run a massively parallel DGEMV test to confirm thread safety of the library (requires OpenMP)" OFF)
3234

3335
# Add a prefix or suffix to all exported symbol names in the shared library.
3436
# Avoids conflicts with other BLAS libraries, especially when using
@@ -234,6 +236,9 @@ if (NOT MSVC AND NOT NOFORTRAN)
234236
add_subdirectory(ctest)
235237
endif()
236238
add_subdirectory(lapack-netlib/TESTING)
239+
if (CPP_THREAD_SAFETY_TEST OR CPP_THREAD_SAFETY_GEMV)
240+
add_subdirectory(cpp_thread_test)
241+
endif()
237242
endif()
238243

239244
set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ ifneq ($(NO_CBLAS), 1)
146146
ifeq ($(CPP_THREAD_SAFETY_TEST), 1)
147147
$(MAKE) -C cpp_thread_test all
148148
endif
149+
ifeq ($(CPP_THREAD_SAFETY_GEMV), 1)
150+
$(MAKE) -C cpp_thread_test dgemv_tester
151+
endif
149152
endif
150153
endif
151154

Makefile.rule

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ COMMON_PROF = -pg
272272
# work at all.
273273
#
274274
# CPP_THREAD_SAFETY_TEST = 1
275+
#
276+
# use this to run only the less memory-hungry GEMV test
277+
# CPP_THREAD_SAFETY_GEMV = 1
275278

276279

277280
# If you want to enable the experimental BFLOAT16 support

cpp_thread_test/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
include_directories(${PROJECT_SOURCE_DIR})
2+
include_directories(${PROJECT_BINARY_DIR})
3+
4+
enable_language(CXX)
5+
6+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -DADD${BU} -DCBLAS")
7+
8+
if (USE_OPENMP)
9+
if (CPP_THREAD_SAFETY_TEST)
10+
message(STATUS building thread safety test)
11+
add_executable(dgemm_thread_safety dgemm_thread_safety.cpp)
12+
target_link_libraries(dgemm_thread_safety ${OpenBLAS_LIBNAME})
13+
add_test( dgemm_thread_safety ${CMAKE_CURRENT_BINARY_DIR}/dgemm_thread_safety)
14+
endif()
15+
16+
17+
if (CPP_THREAD_SAFETY_TEST OR CPP_THREAD_SAFETY_GEMV)
18+
add_executable(dgemv_thread_safety dgemv_thread_safety.cpp)
19+
target_link_libraries(dgemv_thread_safety ${OpenBLAS_LIBNAME})
20+
add_test(dgemv_thread_safety ${CMAKE_CURRENT_BINARY_DIR}/dgemv_thread_safety)
21+
endif()
22+
23+
endif()

0 commit comments

Comments
 (0)