- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can anyone help with the following issue?
Newer versions 9.* and 10.* do not allow MKL to be linked statically from within a DLL except ifthis DLL is built with the custom DLL builder.
To demonstrate the problem, usingVS2005 create a Class Library project (DLL project) that contains a single class with a single method. Link statically the Class Library project to mkl_c.lib and libguide.lib. Then create a console project and try to callthe DoDGEMM method.
The following code runs fine with version 8.1.1 but fails to run with versions 9.* and 10.*
This is the code for the DLL project
// stdafx.h
#pragma
once#include
"mkl.h"#define
ALIGNBYTES 16extern
"C"{
void* _aligned_malloc(size_t size, size_t alignment);void _aligned_free(void *memblock);}
// TEST2005_DLL.h
#pragma
once#include
"stdafx.h"using
namespace System;namespace
TEST2005_DLL {public ref class Class1{
public:void DoDGEMM(){
// The following code works fine with version 8.1.1 // but it does not work with versions 9.* and 10.* // Testing matrix multiplicatio c = a * b// where a is a m x k matrix// where b is a k x n matrix// where c is a m x n matrix// define m, k, nint m = 50;int k = 60;int n = 70;System::Random ^rand =
gcnewSystem::Random(1); // define matrix "a" with random values
double *a = (double*) _aligned_malloc( m * k * sizeof(double), ALIGNBYTES); for(int i=0; i< (m*k); i++) a = rand->NextDouble();// define matrix "b" with random valuesdouble *b = (double*) _aligned_malloc( k * n * sizeof(double), ALIGNBYTES);for(int i=0; i < (k*n); i++) b = rand->NextDouble();// define space for matrix "c"double *c = (double*) _aligned_malloc( m * n * sizeof(double), ALIGNBYTES);char transa = 'N';char transb = 'N';double alpha = 1.0;double beta = 0.0;int lda = m;int ldb = k;int ldc = m;DGEMM(&transa, &transb, &m, &n, &k, α, a, &lda, b, &ldb, β, c, &ldc);
_aligned_free(a);
_aligned_free(b);
_aligned_free(c);
}
};
}
This is the code for the console application project using theDLL project
// TEST2005_EXE.cpp : main project file.
#include
"stdafx.h"using
namespace System;using
namespace TEST2005_DLL;int
main(array<:STRING> ^args){
Class1^ cl =
gcnew Class1();cl->DoDGEMM();
Console::WriteLine(
"Succeded");Console::Read();
return 0;}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you are right - it`s impossible to use statical MKL in your own DLL. It happen because in MKL we have thread safe mechanism and this mechanism is different for statical and dynamical libraries at windows. If you are trying to use statical libraries in your dynamical libraries you`ll receive a crash because MKL TLS section will not be initialized.
If you plan to create your own DLL you should use dynamical MKL libraries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, but it did work with older versions of MKL. Newer versions should not reduce functionality.
At least there should be an option or a switch which allow this to be done. For example MKL TLS section would require a "manual" initialization before MKL is used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If that is because of the new memory manager can it be resolved by redefining memory functions as described in the user guide?
E.g. redefining i_malloc, i_free etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use the Pardiso solver in Intel MKL in a matlab mex dll using IVF 10.1 on Windows. The program crashes when Pardiso is called. I have statically linked libs: libguide40.lib mkl_c.lib mkl_solver.lib. Can I do this with dynamic linking? Which libs do I then need and howdo I link to them?
/ Mats Landervik

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page