OpenMathLib / OpenBLAS

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
http://www.openblas.net
BSD 3-Clause "New" or "Revised" License
6.38k stars 1.5k forks source link

libopenblas.dll create forrtl: severe (157): Program Exception - access violation #2383

Closed realbabilu closed 3 years ago

realbabilu commented 4 years ago

The pre-built works great openblas036-win64.zip https://github.com/xianyi/OpenBLAS/files/3438111/openblas036-win64.zip from https://github.com/xianyi/OpenBLAS/issues/805 The pre-built of martin-frbg is not need mingw-w64 library like libgcc_s_seh-1.dll to run. That library runs well inverting non symmetry matrix 2000x2000 with 1000 times at remarkable 0.3 seconds same as MKL did, and 20 seconds total time along with others method at i7-9750H notebook. The source app is here: https://www.mediafire.com/file/oi966842pbdemt9/test_fpu3.f90/file The prebuilt Openblas on sourceforge, works too. it need mingw-w64-x86_64 lib + libgfortran-3.dll older from anaconda mingw64. DLLs is uploaded here: https://www.mediafire.com/file/f6x0gjoi0g5uquc/DLL_for_run_openblas_mingw-w64-x86_64.zip/file

QUESTION: i have difficulties when linking my own build Openblas.
I tried to build my own the openblas 0.3.8 lib for VS2019/Intel Fortran at windows 10. First try: using MingW-w64 (installed at d/linux/mingw-w64) Tried with mingw-w64_x86_64 http://mingw-w64.org/doku.php/download/mingw-builds Several adjustment for compiling blas copy mingw32-make.exe make.exe (maybe unnecessary) copy ar.exe x86_64-w64-mingw32-ar. copy ranlib.exe to x86_64-w64-mingw32-ranlib. bash (to enter the linux environment) extract openblas-develop at openblas folder make HOSTCC=gcc CC=/mnt/d/linux/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe FC=/mnt/d/linux/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gfortran.exe BINARY=64 and i got files : libopenblas.a libopenblas.dll.a libopenblas.dll libopenblas_haswellp-r0.3.8.dev.a also config.h lapacke_mangling.h , and the other h files before: cblas.h blas.h. Tried to compile test_fpu3.f90 with : ifort /I"D:\win\test_fpu\Openblas2" test_fpu3.f90 libopenblas.dll.a /O3 /link /stack:64000000 Got error forrtl: severe (157): Program Exception - access violation at libopenblas.dll it need the mingw-w64 dll files: libquadmath-0.dll libwinpthread-1.dll libgcc_s_seh-1.dll to run. Create also for VS2019 Gui: lib.exe /def:libopenblas.def /machine:x64 /out:libopenblas.lib. Still got error 157 on compiled app when executed

Second try: using MingW-w64 at Ubuntu WSL Windows 10 sudo apt install mingw-w64 sudo apt install gfortran-mingw-w64-x86-64
at openblas-develop folder: make HOSTCC=gcc CC=/usr/bin/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc FC=/usr/bin/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gfortran BINARY=64 and i got files : libopenblas.a libopenblas.dll.a libopenblas.dll libopenblas_haswellp-r0.3.8.dev.a also config.h lapacke_mangling.h , and the other h files before: cblas.h blas.h. Tried to compile test_fpu3.f90 with : ifort /I"D:\win\test_fpu\Openblas2" test_fpu3.f90 libopenblas.dll.a /O3 /link /stack:64000000 Got error forrtl: severe (157): Program Exception - access violation at libopenblas.dll it need the mingw-w64 dll files: libquadmath-0.dll libwinpthread-1.dll libgcc_s_seh-1.dll to run. i pressume it dll needed is posix right, not win32?

brada4 commented 4 years ago

Please install JIT debugger like x64dbg so that you see which OpenBLAS call is to blame.

libblas.so.3 => ilaenv_,dgetrf_,dgetri_

Last two functions have really heavy call chain behind... more detail is needed.

Does it work other way if you remove 3 tests before one that calls LAPACK?

realbabilu commented 4 years ago

This is on windows. So i am using VS2019 and x64dbg windows. The prebuilt from sourceforge was fine.

This is my built from source with mingw-w64 that create error. The 3 process before calling Lapack DGETRF was fine. Error 157 when call DGETRF : Inaccessible Address

x64dbg.log exception1

brada4 commented 4 years ago

It looks more like calling convention mismatch The arguments are pointers and if they offset by a word you get that access violation in regard to unknown memory @martin-frbg may know better.

realbabilu commented 4 years ago

any more detail built library howto than the Openblas for VS wiki (native or mingw-w64_x86-64) is more helping for more less experience like me. @martin-frbg
For temporary pre-built is fine.

In native: Step 5: is look like bash mode, calling vcvars64.bat ? step 7: cmake --build . --config Release what the expected files on RELEASE. and what next to do for X64. The steps cut out. to others confusing step.

martin-frbg commented 4 years ago

I haven't found time to experiment with Windows builds yet, or to try and drop a newer gcc into my MXE enviroment, so this could be a bug in recent versions of mingw (the default gcc version used in MXE on Linux is 5.5 or so), or some incompatibility with VS2019.

martin-frbg commented 4 years ago

Added some clarification of the "native" cmake build process in the wiki now, but have not actually tested compatibility of the build with ifort.