Skip to content

Commit d2cb610

Browse files
authored
Add option USE_LOCKING for single-threaded build with locking support
for calling from concurrent threads
1 parent ff1bfe7 commit d2cb610

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Makefile.rule

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ VERSION = 0.3.7.dev
5656
# specify it.
5757
# For force setting for single threaded, specify USE_THREAD = 0
5858
# For force setting for multi threaded, specify USE_THREAD = 1
59-
# USE_THREAD = 0
59+
USE_THREAD = 0
60+
61+
# If you want to build a single-threaded OpenBLAS, but expect to call this
62+
# from several concurrent threads in some other program, comment this in for
63+
# thread safety. (This is done automatically for USE_THREAD=1 , and should not
64+
# be necessary when USE_OPENMP=1)
65+
# USE_LOCKING = 1
6066

6167
# If you're going to use this library with OpenMP, please comment it in.
6268
# 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
220226
COMMON_PROF = -pg
221227

222228
# Build Debug version
223-
# DEBUG = 1
229+
DEBUG = 1
224230

225231
# Set maximum stack allocation.
226232
# The default value is 2048. 0 disable stack allocation a may reduce GER and GEMV

Makefile.system

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ SMP = 1
237237
endif
238238
endif
239239

240+
ifeq ($(SMP), 1)
241+
USE_LOCKING =
242+
endif
243+
240244
ifndef NEED_PIC
241245
NEED_PIC = 1
242246
endif
@@ -388,6 +392,12 @@ ifneq ($(MAX_STACK_ALLOC), 0)
388392
CCOMMON_OPT += -DMAX_STACK_ALLOC=$(MAX_STACK_ALLOC)
389393
endif
390394

395+
ifdef USE_LOCKING
396+
ifneq ($(USE_LOCKING), 0)
397+
CCOMMON_OPT += -DUSE_LOCKING
398+
endif
399+
endif
400+
391401
#
392402
# Architecture dependent settings
393403
#
@@ -744,6 +754,8 @@ CCOMMON_OPT += -DF_INTERFACE_GFORT
744754
FCOMMON_OPT += -Wall
745755
# make single-threaded LAPACK calls thread-safe #1847
746756
FCOMMON_OPT += -frecursive
757+
# work around ABI changes in gfortran 9 that break calls from C code
758+
FCOMMON_OPT += -fno-optimize-sibling-calls
747759
#Don't include -lgfortran, when NO_LAPACK=1 or lsbcc
748760
ifneq ($(NO_LAPACK), 1)
749761
EXTRALIB += -lgfortran

common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ extern "C" {
131131
#include <time.h>
132132
#include <unistd.h>
133133
#include <math.h>
134-
#ifdef SMP
134+
#if defined(SMP) || defined(USE_LOCKING)
135135
#include <pthread.h>
136136
#endif
137137
#endif
@@ -200,7 +200,7 @@ extern "C" {
200200
#error "You can't specify both LOCK operation!"
201201
#endif
202202

203-
#ifdef SMP
203+
#if defined(SMP) || defined(USE_LOCKING)
204204
#define USE_PTHREAD_LOCK
205205
#undef USE_PTHREAD_SPINLOCK
206206
#endif

0 commit comments

Comments
 (0)