3

Currently I have a console application, which is fine for me, but not for others. I need to create a GUI. I am developing for Windows 7 using Visual Studio 2010 and CUDA 3.2 build customizations.

Can I simply create a GUI in Windows Forms / WPF and then just state an extern "C" function, that will be resolved to a function calling a CUDA kernel? I tried to do so just now and I had a lot of compilation errors, including some CLR stuff. After a quick googling I have the impression, that it isn't as simple as it seemed.

-- edit

The generalized question is: how to include CUDA code in C++ Windows Forms / WPF application?

3
  • What did you try? What are the errors you're getting? Commented Nov 22, 2011 at 12:04
  • Well, after forcing Framework 3.5 I dont have those errors an more.. but I am veery suprised by the syntax of the "C++" .. public ref class Form1 : public System::Windows::Forms::Form is no C++ to me.. How do I include a *.cu file there ? or use extern .. ? Commented Nov 22, 2011 at 16:44
  • Well, it's not standard C++. From what I know (but I've never worked with it) it's Microsoft's managed extension for C++ or C++/CLI. Perhaps someone else with more experience can help you out. Commented Nov 22, 2011 at 16:50

2 Answers 2

1

My partner and I had the same problem. We decided to write GUI in C# Windows Forms because of simplicity. However, we couldn't find any way of using CUDA in the same project (not even for Managed C++). There might be some way of doing it, but here is our solution: we created another project which was written in native c++ and produced dll file. Then, we used P/Invoke (Platform Invoke) in C# so, that we could call exported functions from dll. In the dll, there should be kernel and some device functions, but you should create another function which calls kernel and which will be exported. You can google P/Invoke and find out how to import native c++ functions from dll to c# application.

Sign up to request clarification or add additional context in comments.

3 Comments

If I wont find a solution, I'll simply build a C++ console app and will comunicate via standard input/output, lol.
Yes, but if you need to exchange information you will have to write too much information in files and it may be slow. If that doesn't matter, go on :)
Actually, if you write another application, then interaction between 2 apps will be hard. when you have one application and one dll, you just use dll's functions as it was your own, so the interaction is much easier.
1

If you're using Visual Studio 2010, you can get started by downloading Cuda Toolkit v4.2 and then downloading CudaFy.net. A search for each on google will get you to the correct pages. Then you make sure nvcc is running. It is necessary to compile C# code into low level (cuda) code. You can then download sample apps to test how they work. You can start here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.