- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
When the program reaches the point where it uses cblas_sgemm when called, it appears to exit with a code 20 , otherwise does not show an error message when it comes. Any idea what is causing this?
コピーされたリンク
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Could you please share a minimal reproducer along with OS, Compiler and MKL version information with us?
Regards
Rajesh.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Currently using windows 10, Intel C++ 2021 compiler, and MKL 2021.1.1
Here is a sample of the code
float scale(float sx, float sy, float sz)
{
float x1[4*4], x2[4*4], x3[4*4];
float alpha = 1.0;
float beta = 0.0;
int b = 0;
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 4; i++) {
if (i == j) {
if (i == 0) {
x2[b] = sx;
x1[b] = 1;
}
else if (i == 1) {
x2[b] = sy;
x1[b] = 1;
}
else if (i == 2) {
x2[b] = sz;
x1[b] = 1;
}
else if (i == 3) {
x2[b] = 1;
x1[b] = 1;
}
}
else {
x2[b] = 0;
x1[b] = 0;
}
b++;
}
}
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 4, 4, 4, alpha, x1, 4, x2, 4, beta, x3, 4);
return x3;
}
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
I tried running the program using cmd, it worked for me. Can you please try compiling it on cmd and let me know if you are facing any issues?
Regards
Rajesh.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Sorry one thing i forgot to mention, i am using visual studio 2019 to run and compile (switched project to use intel compiler as well). I am not well versed in knowing how to compile using cmd for it since I do not usually use this as i am pretty new to using c++ and intel compilers/libraries.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Your function is declared as returning a scalar float, but you are attempting to return a pointer to an array of float. Secondly, x3 is a local variable, which goes out of scope when the function returns.
Here is a suggestion to get things working. Instead of calling cblas_sgemm, write code to calculate x3 (simply setting all 16 elements to 0.0 will do). After you get the function to work, replace that code with the call to cblas_gemm.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
In my current code which i have tried to continue to figure out, i do have all 16 values within x3 set to 0.0f, however it is still doing the same thing of exiting at the cblas_sgemm call at the end as it does not print anything after that when i put a print call after it but does right before the call.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
You did not respond to the remarks in the first paragraph of my post. Your code is wrong.
The return type of the argument does not match the type in the function declaration. In fact, the GCC compiler says the same thing when run on your code:
broken.c:37:8: error: incompatible types when returning type 'float *' but 'float' was expected
37 | return x3;
| ^~
My other comment, regarding returning a local pointer to a caller, is also important.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Well yes, i have fixed that as well but forgot to mention it. But my main focus right now is why it is stopping at the cblas_sgemm call right now as everything else works but that call.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Please follow the procedure below and let us know if you face any issues:
1) Open ""oneAPI command prompt for Visual Studio" to automatically source oneAPI environment or execute the setvars.bat file in oneAPI installation path(In General Command Prompt) to manually source the oneAPI environment.
2) Compile /Run the program using the command:
icl /Qmkl example.cpp && example.exe
Here is your working sample code:
#include<stdio.h>
#include<mkl.h>
float* scale(float sx, float sy, float sz)
{
float x1[4 * 4], x2[4 * 4], x3[4 * 4];
float alpha = 1.0;
float beta = 0.0;
int b = 0;
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 4; i++) {
if (i == j) {
if (i == 0) {
x2[b] = sx;
x1[b] = 1;
}
else if (i == 1) {
x2[b] = sy;
x1[b] = 1;
}
else if (i == 2) {
x2[b] = sz;
x1[b] = 1;
}
else if (i == 3) {
x2[b] = 1;
x1[b] = 1;
}
}
else {
x2[b] = 0;
x1[b] = 0;
}
b++;
}
}
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 4, 4, 4, alpha, x1, 4, x2, 4, beta, x3, 4);
return x3;
}
int main()
{
float* p;
p = scale(1.2, 2.2, 3.1);
for (int i = 0; i < 16; i++) {
printf("%f", p[i]);
printf("\t");
}
return 0;
}
Thanks
Rajesh.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi Rajesh,
Thank you, i have been able to get my sample code working now, however when i tried to implement this code to something similar to a current project i have been working on and it appears that any MKL calls i make just quits the cmd prompt that is open when i print out values such as mkl_malloc and the cblas_sgemm functions. Without those calls, everything runs through, however when the mkl calls are there, it just completely closes at those function calls. Is this due to something i need to add for environments? It is a separate project folder as a dll project to the main application (however my sample code is built the same way and works).
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Please update the current oneAPI version to 2021.2, make sure that you either set oneMKL in sequential or parallel mode. If you use ILP64, make sure to set it to Yes and configure the debug version x64, x86 accordingly in the visual studio and let us know if you face any issues.
Please check the attached picture which shows the above configuration in visual studio.
Regards
Rajesh.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
It appears that I can finally see what exception is being thrown by Visual Studio when using debugger and this is being thrown:
Exception thrown at 0x7556A8B2 (KernelBase.dll) in MakeSTL2.exe: 0xC06D007E: Module not found (parameters: 0x00F7EFBC).
Unhandled exception at 0x7556A8B2 (KernelBase.dll) in MakeSTL2.exe: 0xC06D007E: Module not found (parameters: 0x00F7EFBC).
I do have the MKL setting set to parallel currently in the settings so it should be using the MKL library.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Do you see the same behavior with other MKL applications or is it specific to this application?
Please ensure you upgrade your oneAPI base toolkit to latest version(2021.2). Let us know if you face any issues.
Regards
Rajesh.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Currently i am only using this application for my project. I have upgraded the base toolkit to the latest version and it still gives me the module not found during runtime.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
It is also currently giving me a symbol file not loaded for mkl_intel_thread.1.dll during runtime and i do have the dll files located in where the output files are located (eg .exe file)
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
1) Can you once please refer to the earlier reply, running code on cmd and check whether the same issue is present.
2) Follow these steps to include the missing DLL path:
- Open the project property pages (Alt + Enter)
- Change the Configuration to Debug (On the top left corner)
- On the left window, under the Configuration properties tab, click on Debugging.
- Under the Action tab, click on the Environment field and add the following:
PATH=C:\Program Files (x86)\Intel\oneAPI\mkl\latest\redist\intel64;%PATH%
Save the changes and run your executable. Let us know if you face any issues.
Regards
Rajesh.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Please let us know if there is any update.
Regards
Rajesh.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Yes, i was able to get it working now. Thank you for all the help and suggestions.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Thanks for the confirmation!
As this issue has been resolved, we will no longer respond to this thread. If you require any additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.
Have a Good day.
Regards
Rajesh