CUDA Integration with Windows Forms / WPF

I currently have a console application that is suitable for me, but not for others. I need to create a GUI. I am developing for Windows 7 using the settings in Visual Studio 2010 and CUDA 3.2.

Is it possible to simply create a graphical interface in Windows Forms / WPF, and then simply specify the external function "C", which will be enabled for the function that calls the CUDA kernel? I tried to do it now, and I had a lot of compilation errors, including some CLR stuff. After a quick search on the Internet, I get the impression that it is not as simple as it seemed.

- edit

General question: how to include CUDA code in a C ++ Windows Forms / WPF application?

+4
source share
2 answers

If you are using Visual Studio 2010, you can start downloading Cuda Toolkit v4.2, and then download CudaFy.net. Searching everyone on google will lead you to the right pages. Then you will make sure nvcc is running. You must compile the C # code into a low level code (cuda). You can then download sample applications to test how they work. You can run here

+2
source

My partner and I had the same problem. We decided to write a GUI in C # Windows Forms because of its simplicity. However, we could not find a way to use CUDA in one project (even for Managed C ++). Maybe there is a way to do this, but here is our solution: we created another project that was written in C ++ and a dll file was created. Then we used P / Invoke (Platform Invoke) in C # so that we could call the exported functions from the dll. There should be a kernel and some device functions in the dll, but you must create another function that calls the kernel and which will be exported. You can google P / Invoke and learn how to import native C ++ functions from a dll into a C # application.

+1
source

Source: https://habr.com/ru/post/1382445/


All Articles