How to setup oneMKL lib properly for Visual Studio 2022

229 Views Asked by At

The title says it already: I downloaded the so called oneMKL library from Intel at

oneMKL Download page

with the intent of using it with a (professional) version of Visual Studio 2022 on a Windows 10 machine.

During the GUI presented installation process I chose only default options and it ended with an entry in

C:\Program Files (x86)\Intel\oneAPI

Now it was not quite clear to me, what to do next, nevertheless I knew that something special had to be done, as one of my colleagues was unsuccessful at directly trying to compile an example program with Visual Studio 2022 at this point.

I tried to find out the necessary steps by going through Intel's online docs, by googling and binging and also tried using Bings AI.

All I found out was, that it is necessary to execute

C:\Program Files (x86)\Intel\oneAPI\setvars.bat

which I did and received messages that I interpreted as success and as declaring that now Visual Studio 2022 (at least the command-line version) was prepared to work with oneMKL.

In the next step I made a Console C++ project in Visual Studio 2022 with the following code:

#include <iostream>
#include <vector>
#include "mkl.h"

int main() {
    const int n = 8;
    std::vector<double> x(n);
    std::vector<double> y(n);
    DFTI_DESCRIPTOR_HANDLE desc;
    MKL_LONG status;

    // Initialize input data
    for (int i = 0; i < n; ++i) {
        x[i] = i + 1;
    }

    // Create descriptor
    status = DftiCreateDescriptor(&desc, DFTI_DOUBLE, DFTI_COMPLEX, 1, n);

    // Set configuration options
    status = DftiSetValue(desc, DFTI_PLACEMENT, DFTI_NOT_INPLACE);

    // Commit descriptor
    status = DftiCommitDescriptor(desc);

    // Compute forward FFT
    status = DftiComputeForward(desc, x.data(), y.data());

    // Print output
    std::cout << "FFT output: ";
    for (int i = 0; i < n; ++i) {
        std::cout << y[i] << " ";
    }
    std::cout << std::endl;

    // Free descriptor
    status = DftiFreeDescriptor(&desc);

    return 0;
}

(The code was made up by Bings AI).

But I could not compile it, because, already at start, mkl.h was not found. This was despite the fact, that I have made on "Project properties" the advertised settings on a newly created properties sub-page:

Intel page in Project Properties

Digging deeper it seems that some necessary environment variables that Visual Studio tries to bring into play are not filled properly, for example

$(oneMKLIncludeDir)

Of course you could say, "why not fill these on your own and see what happens", but for the moment I would prefer some explicit step by step instructions what can be done in the way oneMKL was intended to be used. Surely there was no thought of letting the user explicitly create environment variables by hand.

So: Has anyone succeeded with oneMKL download and install on Windows 10 and with Visual Studio 2022 (GUI version not command line) and what are the necessary steps?

Many thanks in advance for every answer!

1

There are 1 best solutions below

1
Buddhadeva Das On

I installed complete oneApi Base Toolkit. Symbol initializations are not done with oneMKL.

In project VC++ Directories put

C:\Program Files (x86)\Intel\oneAPI\mkl\2024.0\include
C:\Program Files (x86)\Intel\oneAPI\mkl\2024.0\lib\

FFT input: 1 2 3 4 5 6 7 8

FFT output: 16 20 12.6569 -12.8995 -8 0 6.31371 2.75736