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

whether DPC++ compiler works with intel MKL

runchan
Beginner
543 Views

I try to use intel MKL with DPC++  compiler, and reports "Unhandled exception at 0x00007FF61B91397A in test_parallel.exe: 0xC0000005: Access violation reading location 0x000002239F286444."

 

Below is my code to test MKL function:

int main()
{
    //cl::sycl::stream cout(1024, 256);
    int a = 1, b = 1;
    int n = 5;
    float* A = (float*)mkl_malloc(n * 1 * sizeof(float), 64);
    float* B = (float*)mkl_malloc(n * 1 * sizeof(float), 64);
    printf("The 1st vector is ");
    for (int i = 0; i < n; i++) {
        A[i] = i;
        printf("%2.0f", A[i]);
    }
    printf("\n");
    printf("The 2st vector is ");
    for (int i = 0; i < n; i++) {
        B[i] = i + 1;
        printf("%2.0f", B[i]);
    }
    printf("\n");
    //compute:a*A+b*B
    cblas_saxpby(n, a, A, 1, b, B, 1);
    printf("The a*A+b*B is ");
    for(int i = 0; i < n; i++) //this is where the above error is reported
    {
        printf("%2.0f", B[i]);
    }
    printf("\n");
    mkl_free(A);
    mkl_free(B);
    //getchar();
    return 0;
}

The above code works when i use Intel C++ compiler, and i am sure intel DPC++ compiler is correctly installed because i have tested a vector-add program before.

I wonder if DPC++ compiler works with Intel MKL.

Thanks~

 

0 Kudos
1 Solution
VarshaS_Intel
Moderator
499 Views

Hi, 

 

Thanks for posting in Intel Communities.

 

>>I wonder if DPC++ compiler works with Intel MKL.

Yes, Intel MKL will work with Intel Classic compiler(icc,icpc), Intel LLVM compilers( ICX, ICPX, DPC++) as well as Fortran. Please find this link for the MKL System Requirements as well.

 

We tried the sample code provided by you and we are able to get the expected results without any error in the Microsoft Visual Studio 2019 and 2022 using the latest Intel oneAPI MKL and DPC++ compiler. Please find the below screenshot for the results:

VarshaS_Intel_3-1685097837087.png

Please find the below screenshot for the project properties settings to use Intel MKL with the DPCPP compiler in Visual Studio:

VarshaS_Intel_2-1685097788205.png

 

Also, we tried running the code on the Intel oneAPI command prompt and we are able to get the expected results:

For compiling the code: dpcpp -qmkl <filename>.cpp
use of 'dpcpp' is deprecated and will be removed in a future release. Use 'icpx -fsycl'
So, you can use for compiling: icpx -fsycl -qmkl <filename>.cpp

For running the code: a.exe

VarshaS_Intel_1-1685097638846.png

Also, you can use the Intel Link Line Advisor for the exact commands for compiling and linking the code with several compilers and third-party libraries and it provides different interfaces to the functionality. Please find the below link for more details:

https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html#gs.yo2o7r

 

Could you please try these and let us know if you are facing any issues?

 

Thanks & Regards,

Varsha

 

View solution in original post

0 Kudos
3 Replies
VarshaS_Intel
Moderator
500 Views

Hi, 

 

Thanks for posting in Intel Communities.

 

>>I wonder if DPC++ compiler works with Intel MKL.

Yes, Intel MKL will work with Intel Classic compiler(icc,icpc), Intel LLVM compilers( ICX, ICPX, DPC++) as well as Fortran. Please find this link for the MKL System Requirements as well.

 

We tried the sample code provided by you and we are able to get the expected results without any error in the Microsoft Visual Studio 2019 and 2022 using the latest Intel oneAPI MKL and DPC++ compiler. Please find the below screenshot for the results:

VarshaS_Intel_3-1685097837087.png

Please find the below screenshot for the project properties settings to use Intel MKL with the DPCPP compiler in Visual Studio:

VarshaS_Intel_2-1685097788205.png

 

Also, we tried running the code on the Intel oneAPI command prompt and we are able to get the expected results:

For compiling the code: dpcpp -qmkl <filename>.cpp
use of 'dpcpp' is deprecated and will be removed in a future release. Use 'icpx -fsycl'
So, you can use for compiling: icpx -fsycl -qmkl <filename>.cpp

For running the code: a.exe

VarshaS_Intel_1-1685097638846.png

Also, you can use the Intel Link Line Advisor for the exact commands for compiling and linking the code with several compilers and third-party libraries and it provides different interfaces to the functionality. Please find the below link for more details:

https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html#gs.yo2o7r

 

Could you please try these and let us know if you are facing any issues?

 

Thanks & Regards,

Varsha

 

0 Kudos
runchan
Beginner
489 Views

Thank you for your prompt and helpful response!

You are right about the project properties settings in this screenshot:

runchan_0-1685108874658.png

I used the DPC++ API instead of "ILP64" interface. This may be the cause of my error.

Thank you once again for taking the time to address my question.

0 Kudos
VarshaS_Intel
Moderator
477 Views

Hi,


>>Thank you for your prompt and helpful response!

It’s great to know that the issue has been resolved, in case you run into any other issues please feel free to create a new thread.


Have a Good Day!


Thanks & Regards,

Varsha


0 Kudos
Reply