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

MKL_Set_Num_Threads(n) and MKL_Verbose(1) make DASUM() and DGEMM() fail

RomanN
Novice
2,135 Views

Dear community,

 

I met the situation that currently couldn't be explained.

Situation 1: If I call MKL_Verbose(1), then DASUM() and DGEMM() fail with External exception C06D007E.

Situation 2:  if I call MKL_Set_Num_Threads(n) where n>1, DGEMM() fails with same exception but DASUM() works as expected. Before setting the number of threads, MKL_Set_Dynamic(0) is called.

Actually, I work with my code from https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Failed-to-use-MKL-linked-dynamically-from-Delphi-x64/m-p/1552112

Everything is fine in case of MKL_Set_Dynamic(0) and MKL_Set_Num_Threads(1).

I also tried to use MKL_malloc() to allocate the memory, but it changed nothing. Playing with MKL_Enable_Instructions() and MKL_Set_Threading_Layer() didn't help as well.

Internet is full of the DGEMM() + MKL_Set_Num_Threads() examples, so they should work together.

Could you please help in this?

Labels (1)
0 Kudos
11 Replies
JilaniS_Intel
Employee
2,078 Views

Hi,



Thanks for posting in Intel Communities.


We are looking into your issue internally. We will get back to you soon with an update.



Regards,

Jilani


0 Kudos
JilaniS_Intel
Employee
2,018 Views

Hi,

 

 

Based on the provided link, it appears that the code you shared is written in Pascal. Could you please confirm if this is indeed the case?

 

 

Regards,

Jilani

 

0 Kudos
RomanN
Novice
2,007 Views

Hi Jilani,

I confirm that the code is written in Delphi 11 and targeted Win64 platform.

Best regards,

Roman

0 Kudos
JilaniS_Intel
Employee
1,995 Views

Hi,



Thank you for your reply.


Could you kindly refer to the link provided below?. The provided link contains information regarding hardware and software requirements for the Intel® oneAPI Math Kernel Library.


https://www.intel.com/content/www/us/en/developer/articles/system-requirements/oneapi-math-kernel-library-system-requirements.html



Regards,

Jilani


0 Kudos
RomanN
Novice
1,950 Views

Dear Jilani,

Thank you very much for the information provided. I checked the requirements and discovered that the Intel® oneAPI Threading Building Blocks is not installed in the system.  I installed it to c:\Program Files (x86)\Intel\oneAPI\tbb\2021.11 and added "c:\Program Files (x86)\Intel\oneAPI\tbb\2021.11\bin" to the PATH for the testing purposes.

Unfortunately, it didn't change the situation. I even put all MKL and TBB dlls from their bins together with my exe and loaded mkl_rt.2.dll dynamically from this folder - no results.

If TBB is required by MKL to implement multithreading, could you please suggest me how to make the MKL use the installed TBB correctly if I load MKL dynamically?

Best regards,

Roman

0 Kudos
Mark_L_Intel
Moderator
1,815 Views

As you can see in the system requirements link above, oneMKL provides C++, Fortran (and also DPC++/SYCL) interfaces. It looks like you were able to use oneMKL with Delphi Pascal but I'm not sure if we can support Delphi Pascal issues with oneMKL.


0 Kudos
RomanN
Novice
1,775 Views

Thank you for reply. Could you please give a link to any C/C++ example of the dynamic oneMKL + TBB loading?

0 Kudos
Mark_L_Intel
Moderator
1,722 Views

I would recommend to start from installing oneAPI Base Toolkit on Windows. It sounds that you are already using Visual Studio.  You can choose to integrate oneAPI Base Toolkit into Visual Studio. After that, you should have an option to start command prompt "Intel oneAPI command prompt for Intel 64 for Visual Studio". Clicking on that prompt, should open the command window with Intel oneAPI tools initialized.  That way, you don't need to install Intel tools piece-wise and wondering why they won't work together. By the way, you could choose at the time of installation the only tools you need, e.g., C/C++ compiler, oneMKL, oneTBB. 

When you use the Intel oneAPI tools command prompt, oneMKL and oneTBB will be available without extra effort.  If you later decide to experiment with your own way to access MKL APIs, you could check what environmental variables are set in the oneAPI command prompt and try to emulate them.  

oneTBB is not required for oneMKL to use multi-threading. By default oneMKL should use OpenMP for multi-threading. It is called "intel_thread" in the output below.  To check what threading model you are using, please "set MKL_VERBOSE=1".  Then, when you are running the code, you should see something similar to the following:

 

MKL_VERBOSE oneMKL 2023.0 Update 2 Product build 20230613 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX-2) with support of Intel(R) Deep Learning Boost (Intel(R) DL Boost), Win 3.78GHz cdecl intel_thread
MKL_VERBOSE DGEMM(N,N,1000,2000,200,000000386B93FAF0,00000235BA889080,1000,00000235BA565080,200,000000386B93FB18,00000235BAA23080,1000) 10.50ms CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:10

 

 as you can see, there is "intel_thread" in the output now. If you'd like to use oneTBB threading for oneMKL, you can enter "set MKL_THREADING_LAYER=tbb" into the command window. Then you should see something like this:

 

MKL_VERBOSE oneMKL 2023.0 Update 2 Product build 20230613 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX-2) with support of Intel(R) Deep Learning Boost (Intel(R) DL Boost), Win 3.78GHz lp64 tbb_thread
MKL_VERBOSE DGEMM(N,N,2,2,2,0000006A2038F7C8,0000006A2038F7D0,2,0000006A2038F810,2,0000006A2038F7C0,0000006A2038F7F0,2) 5.22ms CNR:OFF Dyn:1 FastMM:1

 

with "tbb_thread" in the output. You could switch back to OpenMP by "MKL_THREADING_LAYER=INTEL".  As always, please check the value of the threading variable, e.g., "echo %MKL_THREADING_LAYER%".

After that, I'd recommend to build and run matrix multiply example multiplying-matrices-using-dgemm. And then, try measuring-effect-of-threading-on-dgemm example.  Please use icpx for C++ or icx for C to compile your code or examples.

Also, you could add the following into your C++ code to check on the number of threads you are running.

 

std::cout << "mkl_get_max_threads = " << mkl_get_max_threads () << std::endl;

 

0 Kudos
Mark_L_Intel
Moderator
1,599 Views

Hello @RomanN, have the last post helped you?

0 Kudos
Mark_L_Intel
Moderator
1,551 Views

Hello @RomanN

 

    Is this issue still of interest to you?

0 Kudos
Mark_L_Intel
Moderator
1,523 Views

Hello @RomanN, we have not heard back from you. The issue will no longer be monitored by Intel. Thank you for posting at oneMKL Community Forum.

0 Kudos
Reply