Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7121 Discussions

Attempting to use MKL_RT.2.DLL in Delphi Pascal

CodingInDelphiIn2023
986 Views

We want to start using the MKL within our application and for that I have created a barebones console app. I'm receiving an mix of Access Exceptions and External Exception (can't find dependencies?). My first step debugging this was turning on verbose mode but this is also causing an issue. I'm attempting two main approaches:

Compiling the code below into an executable and running it which fails. I've also attempted to use a cmd prompt first and running "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 ilp64 after which within the same cmd prompt I run my application. I'm running into multiple issues but would like to focus on the mkl_verbose call not working. When I pass a PInteger (integer pointer) I don't get an exception but it also doesn't start outputting to console. When I pass it as Integer I get an access exception. Could anyone help please? I'd be happy to provide more context or info incase necessary.

unit MKL;

interface

uses sysutils;

type
  _MKL_DSS_HANDLE_t = array [0 .. 63] of Pointer;

var
  PARDISO: procedure (pt: Pointer; const maxfct, mnum, mtype, phase: PInteger; const n: PInteger; a: Pointer; ia, ja, perm: PInteger; const nrhs: PInteger; iparm: PInteger; const msglvl: PInteger; b, x: Pointer; error: PInteger); cdecl;
  PARDISO_64: procedure (pt: Pointer; const maxfct, mnum, mtype, phase: PInt64; const n: PInt64; a: Pointer; ia, ja: PInt64; perm: PInt64; const nrhs: PInt64; iparm: PInt64; const msglvl: PInt64; b, x: Pointer; error: PInt64); cdecl;
  PARDISOINIT: procedure (pt: Pointer; const mtype: PInteger; iparm: PInteger); cdecl;
  mkl_verbose: function (mode: Integer): Integer; cdecl;

implementation

uses
  Windows;

var
  MKLHandle: THandle;

procedure LoadMKL;
begin
  MKLHandle := LoadLibrary('C:\Program Files (x86)\Intel\oneAPI\mkl\2023.2.0\redist\intel64\mkl_rt.2.dll');
  if MKLHandle = 0 then
    raise Exception.Create('Could not load MKL library');

  @PARDISO := GetProcAddress(MKLHandle, 'pardiso');
  if not Assigned(PARDISO) then
    raise Exception.Create('Could not find PARDISO function');

  @PARDISO_64 := GetProcAddress(MKLHandle, 'pardiso_64');
  if not Assigned(PARDISO_64) then
    raise Exception.Create('Could not find PARDISO_64 function');

  @PARDISOINIT := GetProcAddress(MKLHandle, 'pardisoinit');
  if not Assigned(PARDISOINIT) then
    raise Exception.Create('Could not find PARDISOINIT function');

  @mkl_verbose := GetProcAddress(MKLHandle, 'mkl_verbose');
  if not Assigned(mkl_verbose) then
    raise Exception.Create('Could not find mkl_verbose function');
end;

initialization
begin
  LoadMKL;
  mkl_verbose(1);
end;

finalization
  if MKLHandle <> 0 then
    FreeLibrary(MKLHandle);

end.

 

0 Kudos
2 Replies
CodingInDelphiIn2023
921 Views

Alright I got MKL Pardiso working in Delphi Pascal so this question can be closed. If there's interest I could explain the process. The main issue is in the Environment Variables and correctly crafting the right signature / using the correct types.

0 Kudos
VarshaS_Intel
Moderator
915 Views

Hi,

 

Thanks for posting in Intel Communities.

 

>>Alright I got MKL Pardiso working in Delphi Pascal so this question can be closed.

Glad to know that your issue is resolved. In case you run into any other issues, please feel free to create a new thread.

 

>>If there's interest I could explain the process

Sure! You can share your findings here, as it helps other users with similar issues.

 

Thanks & Regards,

Varsha

 

0 Kudos
Reply