ref #62. Added the user friendly message with USE_OPENMP=1. The users should use OMP_NUM_THREADS.

When OpenBLAS is compiled with USE_OPENMP=1, it ignores OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags.Therefore, you should use OMP_NUM_THREADS.

Without setting OMP_NUM_THREADS, a process will use maximal number of threads on a computing node. Thus, if there are 2 processes on the computing node, the thread will contend against other threads on CPU cores. As a result, the application will hang.
This commit is contained in:
Xianyi Zhang 2011-10-09 15:14:48 +08:00
parent 8de2ba67dd
commit 57658a8c14
4 changed files with 70 additions and 13 deletions

View File

@ -57,6 +57,13 @@ else
@echo " (Multi threaded; Max num-threads is $(NUM_THREADS))"
endif
ifeq ($(USE_OPENMP), 1)
@echo
@echo " Use OpenMP in the multithreading. Becasue of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, "
@echo " you should use OMP_NUM_THREADS environment variable to control the number of threads."
@echo
endif
ifeq ($(OSNAME), Darwin)
@echo "WARNING: If you plan to use the dynamic library $(LIBDYNNAME), you must run:"
@echo

2
README
View File

@ -48,7 +48,7 @@ export OMP_NUM_THREADS=4
The priorities are OPENBLAS_NUM_THREADS > GOTO_NUM_THREADS > OMP_NUM_THREADS.
If you compile this lib with USE_OPENMP=1, you should only set OMP_NUM_THREADS environment variable.
If you compile this lib with USE_OPENMP=1, you should set OMP_NUM_THREADS environment variable. OpenBLAS ignores OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS with USE_OPENMP=1.
4.2 Set the number of threads with calling functions. for example,
void goto_set_num_threads(int num_threads);

View File

@ -36,22 +36,43 @@ ztestl3o = c_zblas3.o c_z3chke.o auxiliary.o c_xerbla.o constant.o
all :: all1 all2 all3
all1: xscblat1 xdcblat1 xccblat1 xzcblat1
ifeq ($(USE_OPENMP), 1)
OMP_NUM_THREADS=2 ./xscblat1
OMP_NUM_THREADS=2 ./xdcblat1
OMP_NUM_THREADS=2 ./xccblat1
OMP_NUM_THREADS=2 ./xzcblat1
else
OPENBLAS_NUM_THREADS=2 ./xscblat1
OPENBLAS_NUM_THREADS=2 ./xdcblat1
OPENBLAS_NUM_THREADS=2 ./xccblat1
OPENBLAS_NUM_THREADS=2 ./xzcblat1
endif
all2: xscblat2 xdcblat2 xccblat2 xzcblat2
ifeq ($(USE_OPENMP), 1)
OMP_NUM_THREADS=2 ./xscblat2 < sin2
OMP_NUM_THREADS=2 ./xdcblat2 < din2
OMP_NUM_THREADS=2 ./xccblat2 < cin2
OMP_NUM_THREADS=2 ./xzcblat2 < zin2
else
OPENBLAS_NUM_THREADS=2 ./xscblat2 < sin2
OPENBLAS_NUM_THREADS=2 ./xdcblat2 < din2
OPENBLAS_NUM_THREADS=2 ./xccblat2 < cin2
OPENBLAS_NUM_THREADS=2 ./xzcblat2 < zin2
endif
all3: xscblat3 xdcblat3 xccblat3 xzcblat3
ifeq ($(USE_OPENMP), 1)
OMP_NUM_THREADS=2 ./xscblat3 < sin3
OMP_NUM_THREADS=2 ./xdcblat3 < din3
OMP_NUM_THREADS=2 ./xccblat3 < cin3
OMP_NUM_THREADS=2 ./xzcblat3 < zin3
else
OPENBLAS_NUM_THREADS=2 ./xscblat3 < sin3
OPENBLAS_NUM_THREADS=2 ./xdcblat3 < din3
OPENBLAS_NUM_THREADS=2 ./xccblat3 < cin3
OPENBLAS_NUM_THREADS=2 ./xzcblat3 < zin3
endif
clean ::
rm -f x*

View File

@ -4,29 +4,46 @@ include ../Makefile.system
all :: level1 level2 level3
level1 : sblat1 dblat1 cblat1 zblat1
OPENBLAS_NUM_THREADS=1 ./sblat1
OPENBLAS_NUM_THREADS=1 ./dblat1
OPENBLAS_NUM_THREADS=1 ./cblat1
OPENBLAS_NUM_THREADS=1 ./zblat1
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat1
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./dblat1
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./cblat1
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./zblat1
ifdef SMP
ifeq ($(USE_OPENMP), 1)
OMP_NUM_THREADS=2 ./sblat1
OMP_NUM_THREADS=2 ./dblat1
OMP_NUM_THREADS=2 ./cblat1
OMP_NUM_THREADS=2 ./zblat1
else
OPENBLAS_NUM_THREADS=2 ./sblat1
OPENBLAS_NUM_THREADS=2 ./dblat1
OPENBLAS_NUM_THREADS=2 ./cblat1
OPENBLAS_NUM_THREADS=2 ./zblat1
endif
endif
level2 : sblat2 dblat2 cblat2 zblat2
rm -f ?BLAT2.SUMM
OPENBLAS_NUM_THREADS=1 ./sblat2 < ./sblat2.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat2 < ./sblat2.dat
@$(GREP) -q FATAL SBLAT2.SUMM && cat SBLAT2.SUMM || exit 0
OPENBLAS_NUM_THREADS=1 ./dblat2 < ./dblat2.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./dblat2 < ./dblat2.dat
@$(GREP) -q FATAL DBLAT2.SUMM && cat DBLAT2.SUMM || exit 0
OPENBLAS_NUM_THREADS=1 ./cblat2 < ./cblat2.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./cblat2 < ./cblat2.dat
@$(GREP) -q FATAL CBLAT2.SUMM && cat CBLAT2.SUMM || exit 0
OPENBLAS_NUM_THREADS=1 ./zblat2 < ./zblat2.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./zblat2 < ./zblat2.dat
@$(GREP) -q FATAL ZBLAT2.SUMM && cat ZBLAT2.SUMM || exit 0
ifdef SMP
rm -f ?BLAT2.SUMM
ifeq ($(USE_OPENMP), 1)
OMP_NUM_THREADS=2 ./sblat2 < ./sblat2.dat
@$(GREP) -q FATAL SBLAT2.SUMM && cat SBLAT2.SUMM || exit 0
OMP_NUM_THREADS=2 ./dblat2 < ./dblat2.dat
@$(GREP) -q FATAL DBLAT2.SUMM && cat DBLAT2.SUMM || exit 0
OMP_NUM_THREADS=2 ./cblat2 < ./cblat2.dat
@$(GREP) -q FATAL CBLAT2.SUMM && cat CBLAT2.SUMM || exit 0
OMP_NUM_THREADS=2 ./zblat2 < ./zblat2.dat
@$(GREP) -q FATAL ZBLAT2.SUMM && cat ZBLAT2.SUMM || exit 0
else
OPENBLAS_NUM_THREADS=2 ./sblat2 < ./sblat2.dat
@$(GREP) -q FATAL SBLAT2.SUMM && cat SBLAT2.SUMM || exit 0
OPENBLAS_NUM_THREADS=2 ./dblat2 < ./dblat2.dat
@ -36,19 +53,30 @@ ifdef SMP
OPENBLAS_NUM_THREADS=2 ./zblat2 < ./zblat2.dat
@$(GREP) -q FATAL ZBLAT2.SUMM && cat ZBLAT2.SUMM || exit 0
endif
endif
level3 : sblat3 dblat3 cblat3 zblat3
rm -f ?BLAT3.SUMM
OPENBLAS_NUM_THREADS=1 ./sblat3 < ./sblat3.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat3 < ./sblat3.dat
@$(GREP) -q FATAL SBLAT3.SUMM && cat SBLAT3.SUMM || exit 0
OPENBLAS_NUM_THREADS=1 ./dblat3 < ./dblat3.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./dblat3 < ./dblat3.dat
@$(GREP) -q FATAL DBLAT3.SUMM && cat DBLAT3.SUMM || exit 0
OPENBLAS_NUM_THREADS=1 ./cblat3 < ./cblat3.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./cblat3 < ./cblat3.dat
@$(GREP) -q FATAL CBLAT3.SUMM && cat CBLAT3.SUMM || exit 0
OPENBLAS_NUM_THREADS=1 ./zblat3 < ./zblat3.dat
OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./zblat3 < ./zblat3.dat
@$(GREP) -q FATAL ZBLAT3.SUMM && cat ZBLAT3.SUMM || exit 0
ifdef SMP
rm -f ?BLAT3.SUMM
ifeq ($(USE_OPENMP), 1)
OMP_NUM_THREADS=2 ./sblat3 < ./sblat3.dat
@$(GREP) -q FATAL SBLAT3.SUMM && cat SBLAT3.SUMM || exit 0
OMP_NUM_THREADS=2 ./dblat3 < ./dblat3.dat
@$(GREP) -q FATAL DBLAT3.SUMM && cat DBLAT3.SUMM || exit 0
OMP_NUM_THREADS=2 ./cblat3 < ./cblat3.dat
@$(GREP) -q FATAL CBLAT3.SUMM && cat CBLAT3.SUMM || exit 0
OMP_NUM_THREADS=2 ./zblat3 < ./zblat3.dat
@$(GREP) -q FATAL ZBLAT3.SUMM && cat ZBLAT3.SUMM || exit 0
else
OPENBLAS_NUM_THREADS=2 ./sblat3 < ./sblat3.dat
@$(GREP) -q FATAL SBLAT3.SUMM && cat SBLAT3.SUMM || exit 0
OPENBLAS_NUM_THREADS=2 ./dblat3 < ./dblat3.dat
@ -58,6 +86,7 @@ ifdef SMP
OPENBLAS_NUM_THREADS=2 ./zblat3 < ./zblat3.dat
@$(GREP) -q FATAL ZBLAT3.SUMM && cat ZBLAT3.SUMM || exit 0
endif
endif
FLDFLAGS = $(FFLAGS:-fPIC=)
CEXTRALIB =