Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
718 Discussions

I don't know how to migrate C++ to oneAPI.

Nicholas_Darius
Beginner
3,196 Views

sorry to disturb you. I'm a oneAPI beginner. I'm learning how to migrate C++ to oneAPI, but I'm running into some problems. When I encounter nested loops or multiple loops, I don't know how to migrate to oneAPI. So, I'm here to ask for some help. Attached is my code, I have migrated part of it, I don't know what to do when there are only multiple loops and nested loops. The TXT file contains part of the code,I just want to know how to migrate the code in the file. Thanks!

0 Kudos
13 Replies
NoorjahanSk_Intel
Moderator
3,126 Views

Hi,

 

Thanks for posting in Intel Communities.

 

When you have multiple or nested loops, You can create kernels for each loop or you can use different for loops in a single kernel. Based on your use case you can use any of these methods.

 

Please refer to below link for more details:

https://www.intel.com/content/www/us/en/developer/articles/technical/oneapi-cpp-to-dpcpp-conversion.html

https://www.intel.com/content/www/us/en/docs/oneapi/optimization-guide-gpu/2023-2/executing-multiple-kernels-on-the-device-at-the.html

https://link.springer.com/book/10.1007/978-1-4842-5574-2

 

We have tried with a sample code creating two kernels in a single for loop. Please find the attached file for the sample code.

 

Please try to implement your code based on the above methods. If you face any issues, please provide us with a complete code along with compiler version and OS details.

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
NoorjahanSk_Intel
Moderator
3,086 Views

Hi,


We haven't heard back from you. Could you please provide an update on your issue?


Thanks & Regards,

Noorjahan.


0 Kudos
Nicholas_Darius
Beginner
3,051 Views

Sorry for only replying to you now! I just received the subscription information in my email yesterday. Maybe I didn't explain my question clearly. In my attachment, test is a program written in C++ code, DPC++ is written using oneAPI, and ADdata is the matlab file to be read. During my migration process, I mainly found the following problems. The data obtained after the migration of func_apod is different from that of C++; and it will stop running when running the main function; the last problem is that the main function does not know how to migrate to oneAPI, because Vector assignment is used during the loop. I hope you can help me solve the problem, thank you very much! In this process, Matlab and opencv need to be installed, because the lib package is needed to read Matlab files and display images.Due to file size limitations, I can only upload some CPP files to attachments, not the entire program! terribly sorry! Sorry to trouble you, thank you very much!

0 Kudos
NoorjahanSk_Intel
Moderator
2,918 Views

Hi,

 

Thanks for providing the details.

 

Could you please provide us with complete steps you have followed to link openCV with your sample code?

We tried it from our end but got lot of errors. Could you pleas help us to resolve these errors.

Please find the below screenshot for errors we got:

NoorjahanSk_Intel_0-1698720955382.pngNoorjahanSk_Intel_1-1698720969441.png

 

 

>>The data obtained after the migration of func_apod is different from that of C++

Could you please provide data obtained from C++ and migrated code?

Do you want to migrate func_apod code to oneAPI with correct output as of C++. Is this correct? Please correct us if it is wrong.

Also please let us know why hanning() function is commented in your migrated code but not in C++ in func_apod.cpp file. 

If you have multiple loops, we can write multiple kernels for each loop. Please refer to above links that we have provided for more details.

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
Nicholas_Darius
Beginner
2,909 Views

 The data obtained by Fun_apod is the main function that has been commented out. This is also found in the C++ file. The main functions of both are the same, but the data displayed is different. Also, the hanning function exists in c++ but not in oneAPI because during the migration process I found that if I use the hanning function, oneAPI will not run successfully, so I implemented the hanning function inside the func_apod function. Sorry to trouble you! Thanks!

0 Kudos
Nicholas_Darius
Beginner
2,902 Views

Also, I found a problem that if func_delaycalc is not migrated to oneAPI in the last main function, the program will run successfully; but if it is migrated to oneAPI, the program will stop. Is that why? Please see the screenshot below.

Nicholas_Darius_0-1698721001329.png

 

0 Kudos
Nicholas_Darius
Beginner
2,900 Views

Nicholas_Darius_3-1698721624113.png

Nicholas_Darius_4-1698721655139.png

Nicholas_Darius_5-1698721702772.png

Since the installation locations of matlab and Opencv are different, the include directories and library directories will be different. Since the installed versions of opencv are inconsistent, the names of the lib packages will be inconsistent. For details, see opencv/build/x64/vc16/lib.

 

 

 

 

0 Kudos
NoorjahanSk_Intel
Moderator
2,743 Views

Hi,

 

Thanks for providing the details.

 

>>the program will run successfully; but if it is migrated to oneAPI, the program will stop

Could you please provide the results you obtained when you run C++ code. Also please share the complete visual studio(C++ and DPC++) project with detailed steps you have followed.

 

We tried the code from our end, but we are getting errors from Matlab. we tried downloading it, but it requires a License. Could you please share the Matlab dependency files so that we can investigate the issue at our end.

NoorjahanSk_Intel_0-1699435572067.png

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
Nicholas_Darius
Beginner
2,714 Views

Since the matlab file needs to be read, the package in Matlab needs to be imported into Visual Studio. Since the location and version of Matlab installation are different, it is for reference only.

1.C/C++>General->Additional include directories add:
MATLAB\extern\include
MATLAB\extern\include\win64
2. Linker->General->Additional Library Directory Add:
MATLAB\extern\lib\win64\microsoft
MATLAB\extern\lib\win32\microsoft
3. Linker->Input->Additional Dependent Library Add:
libmat.lib
libmx.lib
libmex.lib
libeng.lib
4. Top menu->Generate->Configuration Manager->Platform: X64 (Since the installed matlab is 64-bit, to call its functions, the project needs to be converted to X64)
5. Linker->Advanced->Target Computer:
MachineX64(/MACHINE:X64)
6. Modify the computer environment variable->path and add:
*\MATLAB\extern\lib\win64\microsoft;
*\MATLAB\bin\win64;

0 Kudos
NoorjahanSk_Intel
Moderator
2,633 Views

Hi,


We are working on your issue. We will get back to you soon.


Thanks & Regards,

Noorjahan.


0 Kudos
Viet_H_Intel
Moderator
1,914 Views

Hi, 

We are having problem to duplicate your issue at our end. Could you please provide a self-contain reproducer? 

Thanks,

0 Kudos
Subarnarek_G_Intel
1,680 Views

Gentle reminder to respond.

0 Kudos
Subarnarek_G_Intel
1,642 Views

We will no longer respond to this thread.  If you require additional assistance from Intel, please start a new thread.  Any further interaction in this thread will be considered community only

0 Kudos
Reply