Cuda compilation issue in Visual Studio - visual-studio

I have to port a crowd simulation application onto GPU using CUDA. For that I have this work done by Simon Boots who has ported C++ opensteer library onto CUDA successfully. But I am unable to run the CUDA version on my PC. I am attaching the link for the CUDA code but when i run it on visual studio it does not show any cuda files in solution explorer. Instead it runs the CPU version. Thanks.
Code link:
https://github.com/simonboots/OpenSteerCUDA
In short, my question is, help me compile this CUDA code. I need to use it for my learning. I am still a beginner. thanks.

Try looking for a tutorial or ReadMe that describes how to do what you are trying to do. There is probably a Preprocessor flag (#define) or script that you need to enable to tell the compiler to build the GPU version.

Related

XC8 Compiler setup on CLion for PIC Development

I am new to the embedded systems development space.
My problem is I can't find a way to setup my CLion for development with the XC8 compiler on the PIC16f1779. I have limited knowledge on compilers and CMake also its my first time using C/C++.
The IntelliJ IDE is amazing and I would love to use CLion instead of MPLab X IDE for development.
The school I am at use MPLAB for teaching but its just terrible.
I am using Mac M1 and I am trying to migrate development from MPlab to CLion.
Any help would be appreciated
I have already tried to configure another compiler as XC8 but don't know what exactly to change in the toolchain config in CLion.
As you being a newbie, I strongly recommend that you stick with MPLAB X IDE. Creating PIC projects in other IDEs really require a good knowledge of make build system. Also you will need to integrate the debugger bridge (it is MDB in your case) in order to debug your programs within the IDE.
In my case I tried to develop an existing project both in KDevelop IDE and Eclipse CDT IDE using the make files generated by MPLAB X IDE. Eventually I managed to get the both IDEs compiling the code. But I couldn't go further and integrate symbol recognition and debug bridge.
As a matter of fact the Microchip provides the IDEs as open source for those who want to integrate them into their desired environment. However as I said before, it requires a good knowledge to be able to manage and integrate all those apps in one environment.
If you are interested to learn more about the open source SDK of Microchip go ahead and have a look at ---> openSource4Pic.
But as per my experience on developing application for PIC micros, you will get the best experience in MPLAB X since it is well integrated and featured nearly all needed tools.

Compile OpenCV 3.4 and Cuda 9.2 with MS VS15 2017

I need to do fast image processing so I decide to go for OpenCV with CUDA support. Now I'm trying to build OpenCV as dll to use it in my project, but I am not even able to generate the VS project since CMake keeps giving me this error:
CMakeError. I am on Windows 10, CMake 3.11 with VS 15 2017 x64 generator, OpenCV 3.4 (the last release).
I have installed CUDA 9.2, 9.1 and 8.0 and set CUDA_HOME environment variable as the CUDA toolkit directory. Nothing seems to work.
Then I try to set the CUDA_SDK_ROOT_DIR through the CMake GUI, but the CUDA toolkit directory seems to be not the right one and I'm not able to find the CUDA sample directory anywhere.
I have googled a lot, but I found nothing that had been able to help me. Did someone face this very same issue? How can I solve it?
PS: I have successfully created the dll with TBB and IPP (without CUDA) and it is still not fast enough, so I really need to use Cuda.
I have solved using Cuda 9.1 and VS 15.45. To install CUDA in a correct way you need to use custom installation and delete the VS integration, since it seems to have some problems. Once installation is complete, CMake should detect it.
This is a guide that could help.

gcc can't find cuda_runtime.h even though path is provided with -I flag (cygwin) [duplicate]

I'm trying to build a simple application with CUDA and I've been trying for hours on end and I just can't make it work on windows. nvcc absolutely refuses to compile without Visual Studio's compiler which doesn't support things I need. I tried building using nvcc with clang but It just asks me to use Visual Studio's compiler. I've also tried using clang directly since it now supports CUDA but I receive this error:
clang++.exe: error: Unsupported CUDA gpu architecture: compute_52
This makes no sense to me because I have the CUDA toolkit version 7.5 and my graphics card is a GTX 970 (two of them). I have googled this extensively and everywhere I come across the error the person always has is their CUDA toolkit is < 7.5. I'm on the brink of tears right now trying to get something as simple as VLA to work on this CUDA application and I just can't achieve it...
The CUDA windows toolchain requires the Visual Studio C++ compiler. You cannot use anything else on that platform. If the VS compiler doesn't support the language features you need within CUDA host code, you have no choice but to change platforms, or your expectations.
You can still potentially compile non-CUDA host code using another compiler and then link that code using NVCC and the VS toolchain.
Try to use clang-cl, --cubin=clang-cl.exe
It may be worth to work on a Linux VM or WSL2 within windows. As per the CUDA docs.
To compile new CUDA applications, a CUDA Toolkit for Linux x86 is
needed. CUDA Toolkit support for WSL is still in preview stage as
developer tools such as profilers are not available yet. However, CUDA
application development is fully supported in the WSL2 environment, as
a result, users should be able to compile new CUDA Linux applications
with the latest CUDA Toolkit for x86 Linux.
https://docs.nvidia.com/cuda/wsl-user-guide/index.html#:~:text=However%2C%20CUDA%20application%20development%20is,becomes%20available%20within%20WSL%202.

Compile Qt 5.2 application with the compiler MSVC2008

I have developed an application using Qt 5.2 which has be to be compiled in Visual studio 2008. But i found on the following link that the oldest MSVC compiler that can be used with Qt5 is MSVC2010.
Link
Is it possible to compile Qt 5.2 application with MSVC 2008 ?
Thank you for any pointers.
You will need one of three solutions:
1) Drop MS2008 and use a modern compiler
2) Use an older Qt that supports VS2008 (some Qt4 version)
3) Compile Qt5 with old compiler and hope the best
I would try to do 1) even if it means some effort. You should always try to stay up to date (and the longer you wait the more difficult it gets). If this isn't possible I would probably try 2) since it gives you an oudated but at least stable Qt. 3) is the worst solution at my opionion since anything could happen... without good chances to cleanly solve appearing compatibility issues.
As the http://download.qt-project.org/official_releases/qt/5.2/5.2.1/ (but also your link) shows there is no official package for Qt 5.2 with MSVC2008. However, this does not mean you should not try to compile it.
Just download the source from http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/ and try to compile it. I see in the mkspec directory an entry for win32-msvc2008 so in theory it should work, however I cannot guarantee that it will compile flawlessly.
But I am very curious how did you manage to
developed an application using Qt 5.2 which has be to be compiled in Visual studio 2008
Maybe you should upgrade your compiler to get the full benefits that come with it.

How to debug into CUDA kernel code using visual studio 2008?

Hey,
I am using Visual Studio 2008, with CUDA 3.2. I am trying to debug into a function with this signature:
MatrixMultiplication_Kernel<<<dimGrid, dimBlock>>>(Md, Nd, Pd, Width);
I can step into the function, however when I get into the function it doesn't let me step over any of the code and tells me that no source is available. Anybody knows how to debug into this properly?
Thank you!
You can now debug on a single machine with only one GPU using NSight.
Thought I'd update this, since the previous answers are no longer correct (you no longer need 2 GPUs) and it sent me off in the wrong direction for a while.
Update: Parallel Nsight is now free and supports debugging with only one GPU in your system.
To debug device code within Visual Studio you will need Parallel Nsight. The standard version is free and offers the debugging you require as well as device code profiling.
If you want to debug on a single machine then you will need two GPUs (since the GPU running the code will be stopped when it hits a breakpoint, and hence your display would block as well). They don't need to be high-end GPUs though, anything from G92 onwards will do (including most Fermi GPUs as listed here).
Are you using Nsight? Vanilla Visual Studio cannot step into device code, but with Nsight, this is possible. Unfortunately, limitations of the Windows device driver model mean there are some serious restrictions. It used to be that two machines were required to do the debugging. The target machine would run the CUDA code on it's GPU, and had to be using the TCC driver. The host machine would run Visual Studio and control the target. It seems that it is now possible to debug CUDA code on the same machine as long as you have two GPU's, one for compute and one for display. There are a number of other problems mentioned in the user guide.
This may not be an acceptable answer, but: If you can compile your code on Linux, you can use cuda-gdb to debug kernels. cuda-gdb is part of the Linux CUDA toolkit.
You can't debug CUDA kernel code using visual studio. Visual studio can only debug programs that run on the CPU.
In fact, I don't think that you can debug CUDA kernel code in Windows at all any more. CUDA used to have a host emulation mode, but that was removed in 3.0. The only debugging tools available are cuda-gdb and ocelot, and, as far as I know, neither of them supports Windows.

Resources