You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
I am getting segfaults when running an openmp-parallelised code that calls a blas matrix-multiplication from the parallel region. The machine is an 8-core "Intel(R) Xeon(R) CPU E5345", with 16 GB RAM, running Ubuntu 12.04 LTS. I have essentially the same problem with the 0.1 version shipped with 12.04 and the backported 0.2.6 version. I used gfortran 4.6.3 to compile and link. The stack size is set to unlimited, and OMP_STACKSIZE=1G. The problem on this machine occurs if OMP_NUM_THREADS=5 or greater.
Here is the example program:
program test_blas_error
implicit none
integer, parameter :: dp = kind(1.0d0)
real(dp), dimension(:,:), allocatable :: a, b, c
integer :: i, n, n_max, l_max
n = 20
n_max = 1000
l_max = 100
!$omp parallel do schedule(dynamic) default(none) shared(n, n_max, l_max) private(i, a, b, c)
do i = 1, n
allocate(a(n_max,l_max), b(n_max,l_max), c(n_max,n_max))
call random_number(a)
call random_number(b)
call dgemm('N','T',n_max, n_max, l_max, 1.0_dp, &
a, size(a,1), b, size(b,1), 0.0_dp, c, size(c, 1))
print*, sum(c)
deallocate(a,b,c)
enddo
!$omp end parallel do
endprogram test_blas_error
$ gfortran -fopenmp test_blas_error.f95 -lblas
$ ./a.out
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
24944796.711494826
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
Segmentation fault
$ gfortran -g -fbacktrace -fopenmp test_blas_error.f95 -lblas
ab686@womble:~/test$ ./a.out
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
24944796.711494826
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
#0 0x2B10EF77A547
#1 0x2B10EF77AB4E
#2 0x2B10EFEDC49F
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x2B10EF77A547
#1 0x2B10EF77AB4E
#2 0x2B10EFEDC49F
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x2B10EF77A547
#1 0x2B10EF77AB4E
#2 0x2B10EFEDC49F
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
#0 0x2B10EF77A547
#1 0x2B10EF77AB4E
#2 0x2B10EFEDC49F
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
24974178.514966901
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
Segmentation fault
I'd like to add that in Makefile.conf NUM_CORES=8 (auto-detected) and USE_OPENMP=0 ( blas shouldn't use openmp here I think.)
I'd be grateful for any comments, advice.
Albert
Hi Xianyi,
Many thanks for your quick reply. I have tried 2) but got the same:
$ export OPENBLAS_NUM_THREADS=1
$ ./a.out
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
24944796.711494826
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
BLAS : Program is Terminated. Because you tried to allocate too many memory regions.
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x2AF00EFDB547
#1 0x2AF00EFDBB4E
#2 0x2AF00F73D49F
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x2AF00EFDB547
#1 0x2AF00EFDBB4E
#2 0x2AF00F73D49F
#0 0x2AF00EFDB547
#1 0x2AF00EFDBB4E
#2 0x2AF00F73D49F
24942308.924021363
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
#0 0x2AF00EFDB547
#1 0x2AF00EFDBB4E
#2 0x2AF00F73D49F
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
25022022.333436657
#3 0x57C4EF in dgemm_otcopy_CORE2 at gemm_tcopy_4.S:247
Segmentation fault
I am currently compiling with USE_OPENMP=1 and I'll let you know the result when it's finished.
Albert
OK, compiling with USE_OPENMP=1 was a success, I didn't get any more segfaults. I am wondering in this case is the blas routine running in on a single core or parallel (called from a parallel region). Is this controlled by OPENBLAS_NUM_THREADS? What is the default?
Thanks for your help.
Albert
Hi @albapa ,
By default, the number of threads is controlled by OPENBLAS_NUM_THREADS. When it built with USE_OPENMP=1, it is controlled by OMP_NUM_THREADS.
The default value of OPENBLAS_NUM_THREADS is the number of cpu cores.
Xianyi
Hi Xianyi,
Thanks for your reply.
One more thing and sorry if this should be obvious - assume openblas is built with USE_OPENMP=1, and I call a blas routine from a parallel region - so the blas routine is called OMP_NUM_THREADS times concurrently - does each blas instance run on a single (the calling) thread, or is it threaded further? Thank you very much in advance.
Albert
If you call BLAS routine from a parallel region, BLAS routine will not run multi-threaded further.
If you call BLAS routine from a sequential region, BLAS routine is multi-threaded.