Add option USE_LOCKING for single-threaded build with locking support
authorMartin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Wed, 15 May 2019 21:18:43 +0000 (23:18 +0200)
committerGitHub <noreply@github.com>
Wed, 15 May 2019 21:18:43 +0000 (23:18 +0200)
for calling from concurrent threads

Makefile.rule
Makefile.system
common.h

index 1781509..faf8c80 100644 (file)
@@ -56,7 +56,13 @@ VERSION = 0.3.7.dev
 # specify it.
 # For force setting for single threaded, specify USE_THREAD = 0
 # For force setting for multi  threaded, specify USE_THREAD = 1
-# USE_THREAD = 0
+USE_THREAD = 0
+
+# If you want to build a single-threaded OpenBLAS, but expect to call this
+# from several concurrent threads in some other program, comment this in for
+# thread safety. (This is done automatically for USE_THREAD=1 , and should not
+# be necessary when USE_OPENMP=1)
+# USE_LOCKING = 1
 
 # If you're going to use this library with OpenMP, please comment it in.
 # This flag is always set for POWER8. Don't set USE_OPENMP = 0 if you're targeting POWER8.
@@ -220,7 +226,7 @@ NO_AFFINITY = 1
 COMMON_PROF = -pg
 
 # Build Debug version
-DEBUG = 1
+DEBUG = 1
 
 # Set maximum stack allocation.
 # The default value is 2048. 0 disable stack allocation a may reduce GER and GEMV
index a95d619..29aef7e 100644 (file)
@@ -237,6 +237,10 @@ SMP = 1
 endif
 endif
 
+ifeq ($(SMP), 1)
+USE_LOCKING = 
+endif
+
 ifndef NEED_PIC
 NEED_PIC = 1
 endif
@@ -388,6 +392,12 @@ ifneq ($(MAX_STACK_ALLOC), 0)
 CCOMMON_OPT    += -DMAX_STACK_ALLOC=$(MAX_STACK_ALLOC)
 endif
 
+ifdef USE_LOCKING
+ifneq ($(USE_LOCKING), 0)
+CCOMMON_OPT    += -DUSE_LOCKING
+endif
+endif
+
 #
 #  Architecture dependent settings
 #
@@ -744,6 +754,8 @@ CCOMMON_OPT += -DF_INTERFACE_GFORT
 FCOMMON_OPT += -Wall
 # make single-threaded LAPACK calls thread-safe #1847
 FCOMMON_OPT += -frecursive
+# work around ABI changes in gfortran 9 that break calls from C code
+FCOMMON_OPT += -fno-optimize-sibling-calls
 #Don't include -lgfortran, when NO_LAPACK=1 or lsbcc
 ifneq ($(NO_LAPACK), 1)
 EXTRALIB += -lgfortran
index 0ac74bb..a9fe8d9 100644 (file)
--- a/common.h
+++ b/common.h
@@ -131,7 +131,7 @@ extern "C" {
 #include <time.h>
 #include <unistd.h>
 #include <math.h>
-#ifdef SMP
+#if defined(SMP) || defined(USE_LOCKING)
 #include <pthread.h>
 #endif
 #endif
@@ -200,7 +200,7 @@ extern "C" {
 #error "You can't specify both LOCK operation!"
 #endif
 
-#ifdef SMP
+#if defined(SMP) || defined(USE_LOCKING)
 #define USE_PTHREAD_LOCK
 #undef USE_PTHREAD_SPINLOCK
 #endif