OpenBLAS: [VS2013] Access violation in ntdll.dll while using static compiled cblas_sgemv
Steps to reproduce this issue:
- Use CMake to generate VS2013 solution files using default settings.
- Open the OpenBLAS solution and change the configurations to compile as Win32 static library (change /MD to /MT), then compile.
- Compile and run the code below, linking against the static OpenBLAS library in step 2:
#include <Windows.h>
#include <opencv2/opencv.hpp>
#include <cblas.h>
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
LARGE_INTEGER freq, start, end;
QueryPerformanceFrequency(&freq);
RNG &rng = theRNG();
rng.state = getTickCount();
float alpha = 1.f, beta = 0;
int m = 25, p = 10000, n = 1;
Mat_<float> A(m, p, CV_32F), B(p, n, CV_32F);
Mat C1 = Mat(m, n, CV_32F, 0.0);
Mat C2 = Mat(m, n, CV_32F, 0.0);
rng.fill(A, RNG::NORMAL, 1, 100);
rng.fill(B, RNG::NORMAL, 2, 50);
float *src1, *src2, *src3, *src4;
src1 = (float *)A.data;
src2 = (float *)B.data;
src3 = (float *)C1.data;
src4 = (float *)C2.data;
QueryPerformanceCounter(&start);
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, p,
alpha, src1, p, src2, n, beta, src3, n);
QueryPerformanceCounter(&end);
cout << "cblas_sgemm: " << (end.QuadPart - start.QuadPart) / (float)freq.QuadPart * 1000.f << " ms " << endl;
cout << C1 << endl;
QueryPerformanceCounter(&start);
cblas_sgemv(CblasRowMajor, CblasNoTrans, m, p,
alpha, src1, p, src2, n, beta, src4, n);
QueryPerformanceCounter(&end);
float duration = (end.QuadPart - start.QuadPart) / (float)freq.QuadPart * 1000.f;
cout << "cblas_sgemv: " << (end.QuadPart - start.QuadPart) / (float)freq.QuadPart * 1000.f << " ms " << endl;
cout << C2 << endl;
return 0;
}
When using static linking, cblas_sgemm works fine while cblas_sgemv encounters access violation in ntdll.dll. However when using dynamic linking (don’t change anything CMake generated), both cblas_sgemm and cblas_sgemv works as expected. The same applies to cblas_dgemm/cblas_dgemv (as for now I only tested these). Note: Reduce p in the code above from 10000 to 100 seems to eliminate all access violations. Is this somehow related to issue #773?
I am compiling and testing OpenBLAS on this computer: Intel T8300 / Windows 10 64bit / 4GB RAM When used on several other systems below, the access violation still occurs: Intel Z3735f / Windows 8 32bit / 1GB RAM intel Xeon E3-1230 V2 / Windows 7 64bit / 16GB RAM
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (12 by maintainers)
If you link outer .EXE with MD you have MSVCRT*.DLL linked twice in program. It is certain to cause conflicts.