0

I can't get Intel MKL to work as it should from C. I have the following test program:

#include "stdafx.h"
#include"mkl.h"
int main()
{
    int one = 1;
    int ten = 10;
    double copy[10];
    double threes[10];

    for (int i = 0; i < 10; ++i) threes[i] = 3;

    dcopy(&ten, threes, &one, copy, &one);
    double l1norm;
    l1norm = dasum(&ten, threes, &one);
    return 0;
}

which is building and linking fine but not doing what I intended. Specifically at the return line the array "copy" continues to be full of what was there when it was declared and l1norm equal to 0. I am linking to the libraries : mkl_blas95_ilp64.lib, mkl_core_dll.lib, mkl_intel_ilp64_dll.lib and mkl_intel_thread_dll.lib.

I'm also getting similar problems when running third-party code that calls MKL so I assume the problem is how I have the build configured (in Visual Studio 2015).

The equivalent Fortran program runs fine.

leppie
  • 115,091
  • 17
  • 196
  • 297
MatthewJohnHeath
  • 393
  • 2
  • 12
  • Have you tried to use cblas API rather than Fortan API in your C code? – kangshiyin May 11 '16 at 19:08
  • @Eric I have now. If I replace the line` dcopy...` with `cblas_dcopy(10,threes,copy1)`then that line throws `Access violation reading location 0xFFFFFFFFFFFFFFFF` after managing to copy the first 3. Also the code I need to call (SuperLU) uses the Fortran declarations with "extern" `cblas_dasum` actually seems to work fine – MatthewJohnHeath May 12 '16 at 08:03

1 Answers1

1

Please check the libraries you link when porting from Fortran to C/C++. MKL requires different libraries and compiling flags with different compilers and settings. At least mkl_blas95_ilp64.lib is not required with C compiler.

Also ILP64 is not common compared to the default model LP64.

MKL Link Line Advisor is a tool provided by Intel to solve this issue. You could use it to check if your libraries and compiling flags are correct.

https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

kangshiyin
  • 9,681
  • 1
  • 17
  • 29