Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Mikhail_K_
Beginner
359 Views

Declaring BLAS functions from mkl_rt.dll in VBA Excel

Hi,

The stdcall requirement normally needed for dlls to work in VBA only applies to 32bit dlls. In 64bit dlls there is only one calling convention, I think.

So, for example, With 64-bits OpenBLAS I am able to do declare a call to a fortran BLAS function (not cblas) and it works fine:

Public Declare PtrSafe Sub dgemm Lib "libopenblas.dll" (ByVal transa As String, _
                                                        ByVal transb As String, _
                                                        ByRef m As Long, _
                                                        ByRef n As Long, _
                                                        ByRef k As Long, _
                                                        ByRef alpha As Double, _
                                                        ByRef a As Double, _
                                                        ByRef lda As Long, _
                                                        ByRef b As Double, _
                                                        ByRef ldb As Long, _
                                                        ByRef beta As Double, _
                                                        ByRef c As Double, _
                                                        ByRef ldc As Long)

But whichever way I tried the same does not work with 64bit mkl_rt.dll. Excel just quietly quits.

Do I have to compile a BLAS-only 64bit dll to be used with VBA Excel? If yes, how exaclty (I urge you to explain in detail)?

 

MKL headers are slightly different from OpenBLAS, not sure if its somehow related to this:

MKL:

void __stdcall DGEMM(const char *transa, int transa_len, const char *transb, int transb_len, const MKL_INT *m, const MKL_INT *n, const MKL_INT *k,
                     const double *alpha, const double *a, const MKL_INT *lda, const double *b, const MKL_INT *ldb,
                     const double *beta, double *c, const MKL_INT *ldc);

 

OpenBLAS:

void BLASFUNC(dgemm)(char *, char *, blasint *, blasint *, blasint *, double *,
	   double *, blasint *, double *, blasint *, double *, double *, blasint *);

 

Any tips?

0 Kudos
4 Replies
Mikhail_K_
Beginner
359 Views

Hi, false alarm figured it out.

Dependecy Walker showed that mkl_rt.dll does not rely on other dlls, but I gathered all MKL dlls in one directory anyway. When looking at what other dlls load up when calling for example cblas_drotg, the following shows up:

libiomp5md.dll
mkl_avx2.dll
mkl_core.dll
mkl_intel_thread.dll
mkl_rt.dll
Ngo__Nhan
Novice
342 Views

Hi Mikhail,

I have the same problem, my excel is crashed when the call is made too.

I have posted the question: https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Cannot-Invert-Matrix-using-Lapack-DG...

Could you review and give the instruction?

Thank you a lot.

Gennady_F_Intel
Moderator
319 Views

one notes regarding the single dynamic library - this mode, by default provides support of LP64 and Intel threading mode. Please refer to the MKL's Developer Guide follow this link:https://software.intel.com/content/www/us/en/develop/documentation/mkl-linux-developer-guide/top/lin...

Ngo__Nhan
Novice
293 Views

Hi Gennady,

Could you help me to provide the documents which show how we declare the function in mkl_rt for window and excel 32bit? I used ByRel for all variables used for DGETRF/DGETR which work in Window and Excel 64bit but 32 bit.

Thank you for giving instructions.

Reply