Add option USE_LOCKING for single-threaded build with locking support

for calling from concurrent threads
This commit is contained in:
Martin Kroeker 2019-05-15 23:18:43 +02:00 committed by GitHub
parent ff1bfe7b16
commit d2cb610272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View File

@ -56,7 +56,13 @@ VERSION = 0.3.7.dev
# specify it. # specify it.
# For force setting for single threaded, specify USE_THREAD = 0 # For force setting for single threaded, specify USE_THREAD = 0
# For force setting for multi threaded, specify USE_THREAD = 1 # 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. # 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. # 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 COMMON_PROF = -pg
# Build Debug version # Build Debug version
# DEBUG = 1 DEBUG = 1
# Set maximum stack allocation. # Set maximum stack allocation.
# The default value is 2048. 0 disable stack allocation a may reduce GER and GEMV # The default value is 2048. 0 disable stack allocation a may reduce GER and GEMV

View File

@ -237,6 +237,10 @@ SMP = 1
endif endif
endif endif
ifeq ($(SMP), 1)
USE_LOCKING =
endif
ifndef NEED_PIC ifndef NEED_PIC
NEED_PIC = 1 NEED_PIC = 1
endif endif
@ -388,6 +392,12 @@ ifneq ($(MAX_STACK_ALLOC), 0)
CCOMMON_OPT += -DMAX_STACK_ALLOC=$(MAX_STACK_ALLOC) CCOMMON_OPT += -DMAX_STACK_ALLOC=$(MAX_STACK_ALLOC)
endif endif
ifdef USE_LOCKING
ifneq ($(USE_LOCKING), 0)
CCOMMON_OPT += -DUSE_LOCKING
endif
endif
# #
# Architecture dependent settings # Architecture dependent settings
# #
@ -744,6 +754,8 @@ CCOMMON_OPT += -DF_INTERFACE_GFORT
FCOMMON_OPT += -Wall FCOMMON_OPT += -Wall
# make single-threaded LAPACK calls thread-safe #1847 # make single-threaded LAPACK calls thread-safe #1847
FCOMMON_OPT += -frecursive 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 #Don't include -lgfortran, when NO_LAPACK=1 or lsbcc
ifneq ($(NO_LAPACK), 1) ifneq ($(NO_LAPACK), 1)
EXTRALIB += -lgfortran EXTRALIB += -lgfortran

View File

@ -131,7 +131,7 @@ extern "C" {
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <math.h> #include <math.h>
#ifdef SMP #if defined(SMP) || defined(USE_LOCKING)
#include <pthread.h> #include <pthread.h>
#endif #endif
#endif #endif
@ -200,7 +200,7 @@ extern "C" {
#error "You can't specify both LOCK operation!" #error "You can't specify both LOCK operation!"
#endif #endif
#ifdef SMP #if defined(SMP) || defined(USE_LOCKING)
#define USE_PTHREAD_LOCK #define USE_PTHREAD_LOCK
#undef USE_PTHREAD_SPINLOCK #undef USE_PTHREAD_SPINLOCK
#endif #endif