-
-
Save xianyi/4771129 to your computer and use it in GitHub Desktop.
#include <stdio.h> | |
#include "cblas.h" | |
#include "lapacke.h" | |
int main(int argc, char* argv[]) | |
{ | |
int* ipiv; | |
int info; | |
int i, j; | |
int n; | |
double * m, *x, *y; | |
int LDB,LDA, N, NRHS; | |
char transp = 'N'; | |
if(argc<2){ | |
printf("Error\n"); | |
return 1; | |
} | |
n=atoi(argv[1]); | |
printf("n=%d\n",n); | |
m=(double*)malloc(sizeof(double)*n*n); | |
x=(double*)malloc(sizeof(double)*n); | |
y=(double*)malloc(sizeof(double)*n); | |
ipiv=(int*)malloc(sizeof(int)*n); | |
for (i=0; i<n; ++i) { | |
x[i]=1.0; | |
for (j=0; j<n; ++j) { | |
m[i*n+j]=(rand()%100+1)/10.0; | |
// printf("m[%d,%d]=%lf\n",i,j, m[i*n+j]); | |
} | |
} | |
/* test cblas.h */ | |
cblas_dgemv(CblasColMajor, CblasNoTrans, n, n, 1.0, m, n, | |
x, 1, 0.0, y, 1); | |
// for (i=0; i<n; ++i) printf("x[%d]=%lf\n",i, x[i]); | |
//for (i=0; i<n; ++i) printf("y[%d]=%lf\n",i, y[i]); | |
LDB=n; | |
LDA=n; | |
N=n; | |
NRHS=1; | |
info=0; | |
LAPACK_dgetrf(&N, &N, m, &LDA,ipiv, &info); | |
if (info != 0) fprintf(stderr, "dgetrf failure with error %d\n", info); | |
LAPACK_dgetrs(&transp, &N, &NRHS, m, &LDA, ipiv, y, &LDB, &info); | |
if (info != 0) fprintf(stderr, "failure with error %d\n", info); | |
// for (i=0; i<n; ++i) printf("%lf\n", y[i]); | |
return 0; | |
} |
The results are the same with the development version of openblas: I get a crash for n > 65.
If I include cblas.h and the corresponding function (and remove lapacke.h), it does not crash, even with N=10000
if i export OPENBLAS_NUM_THREADS=1
, test.exe works, even with N=3000
I do not have pthreads, so I did not link against it
Hi @vtjnash ,
Download OpenBLAS develop branch.
make
make PREFIX=/your/path/OpenBLAS install
gcc -o test test_dgetrf.c -I /your/path/OpenBLAS/include /your/path/OpenBLAS/lib/libopenblas.a -lpthread -lgfortran
Xianyi
OK. Before I had tried copying the headers directly, which failed as shown. make install worked to fix the headers.
I invoked make with the following command (on a linux box):
make CC="i686-w64-mingw32-gcc" FC="i686-w64-mingw32-gfortran" RANLIB="i686-w64-mingw32-ranlib" CFLAGS="-g" FFLAGS="-g -O2 " USE_THREAD=1 TARGET= DYNAMIC_ARCH=1 OSNAME=WINNT CROSS=1 BINARY=32
then i compiled the test code (on the host machine):
gcc -g -Wall -I. -L. test_dgetrf.c -o test.exe -m32 -lopenblas
I still get the segfault for N > 65
(gdb) r 100
Starting program: c:\users\jameson\desktop\julia-64966d6e8c\test.exe 100
[New Thread 31900.0x80f8]
[New Thread 31900.0x83c0]
[New Thread 31900.0x8678]
n=100
[New Thread 31900.0x85e0]
Program received signal SIGSEGV, Segmentation fault.
0x6d7e9243 in zupmtr_ () from c:\users\jameson\desktop\julia-64966d6e8c\libopenblas.dll
(gdb) bt
#0 0x6d7e9243 in zupmtr_ () from c:\users\jameson\desktop\julia-64966d6e8c\libopenblas.dll
#1 0x6cc2c9f6 in zupmtr_ () from c:\users\jameson\desktop\julia-64966d6e8c\libopenblas.dll
#2 0x6cc2c9f6 in zupmtr_ () from c:\users\jameson\desktop\julia-64966d6e8c\libopenblas.dll
#3 0x6cc2c9f6 in zupmtr_ () from c:\users\jameson\desktop\julia-64966d6e8c\libopenblas.dll
#4 0x6cc2c9f6 in zupmtr_ () from c:\users\jameson\desktop\julia-64966d6e8c\libopenblas.dll
#5 0x6c4d6996 in libopenblas!DLANSB () from c:\users\jameson\desktop\julia-64966d6e8c\libopenblas.dll
#6 0x0028fde0 in ?? ()
#7 0x004013fa in __tmainCRTStartup ()
#8 0x749033aa in KERNEL32!BaseCleanupAppcompatCacheSupport () from C:\Windows\syswow64\kernel32.dll
#9 0x0028ffd4 in ?? ()
#10 0x77149ef2 in ntdll!RtlpNtSetValueKey () from C:\Windows\system32\ntdll.dll
#11 0x7efde000 in ?? ()
#12 0x77149ec5 in ntdll!RtlpNtSetValueKey () from C:\Windows\system32\ntdll.dll
#13 0x004014e0 in WinMainCRTStartup ()
#14 0x7efde000 in ?? ()
#15 0x00000000 in ?? ()
(gdb) info reg
eax 0x3440 13376
ecx 0x92b80 600960
edx 0x8 8
ebx 0x8 8
esp 0xf6b74 0xf6b74
ebp 0xf6bb8 0xf6bb8
esi 0x28fde0 2686432
edi 0xffffc000 -16384
eip 0x6d7e9243 0x6d7e9243 <zupmtr_+13701139>
eflags 0x10202 [ IF RF ]
cs 0x23 35
ss 0x2b 43
ds 0x2b 43
es 0x2b 43
fs 0x53 83
gs 0x2b 43
(gdb)
If I comment out the cblas header and call, it compiles:
edit I am using openblas-v0.2.5, not develop (yet)