How do I use other c++ compilers with CUDA on Windows? - c++

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.

Related

Loading clang-compiled OpenCL kernels into OpenCL programs

Using clang, I am able to compile OpenCL-C++ kernels (using clang -c). I am trying to load these compiled kernels into my OpenCL application, but am at a loss how to achieve that. I am using Ubuntu 22.04, with an Intel CPU and an Nvidia GPU. The GPU unfortunately does not support SPIR-V injection via clCreateProgramWithIL - if it did, I would happily take that route. I also cannot use clCreateProgamWithSource, because that unfortunately does not support C++ features inside the kernels.
Is there any way I can compile OpenCL-C++ kernels using clang and then load them into my OpenCL application? Or is there a way I can still use clCreateProgramWithSource with C++ features inside the kernels, maybe? Either way would work well! (There has been a similar question here but focusing on macOS, which has its own OpenCL implementation and compiler, as far as I know.)

Open CL programming with G++ in Windows

I am trying to write Open CL programs in C++ using G++ compiler in Windows 10 but I am not able to find any SDK for my work.
Nvidia CUDA requires Visual Studio compilers to work and AMD AMP SDK seems to be discontinued saying that the libraries are included in the driver itself.
My PC has both AMD and Nvidia GPUs so any of the implementation should be fine with OpenCL. Can anyone suggest how can I carry on and also kindly clarify on how to use the libraries present in OpenCL driver in my C++ program as mentioned by AMD if possible?
Edit :
I found out that OpenCL libraries are already present in Windows as,
C:\Windows\System32\OpenCL.dll
We only need headers to compile our program using g++. It can be done as shown below.
Install OpenCL headers from below,
https://packages.msys2.org/package/mingw-w64-x86_64-opencl-headers
Once headers are present in include directory of MinGW64, I wrote my program normally and compiled the program using the below g++ command.
g++ main.cpp C:\Windows\System32\OpenCL.dll -o main.exe
And that's it. It worked !!!
http://arkanis.de/weblog/2014-11-25-minimal-opencl-development-on-windows was of great help to understand the OpenCL library implementation in Windows.
You don't need to install anything besides Visual Studio Community with the C++ compiler, and GPU drivers (these already contain the OpenCL runtimes).
For OpenCL development, you only need the OpenCL header files and the lib file. To setup Visual Studio, see here. This works for any OpenCL device, including Nvidia/AMD/Intel GPUs and even Intel CPUs if the CPU runtime is installed.
Alternatively, you can use my lightweight OpenCL-Wrapper. This comes with all Visual Studio settings already in the project file. OpenCL learning and developing with the wrapper is so much simpler than with the cumbersome OpenCL bindings directly.

OpenMP 3.0 for Visual Studio

Currently I am developing a cross-plattform framework where I want to use actuall features of openmp.
I would like to make use of the "new features" of openmp 3.0 (or later).
(Such like unsigned parallel for loops or tasks etc.,
I haven't developed on a windows plattform for quite a while and
as I have seen for now even Visual Studio 2015 does only support openmp 2.0 (At least when using msvc, see e.g. All OpenMP Tasks running on the same thread or https://blogs.msdn.microsoft.com/vcblog/2014/11/12/visual-studio-2015-preview-is-now-available/) So my questions are:
Is there any sane reason to not support openmp3.0 in Visual Studio?
Is there any way to get it work under Visual Studio?
I am aware, that I could use the Intel C++ compiler, but unfortunately i do not have access to one. So is there a free alternative to the Intel compiler with openmp3.0 support?
Thanks in advance
Well, you might try GCC ports for Windows, native (mingw64) and on top of cygwin.
Try to install msys2 and you'll get ming64 as well as cygwin compilers with OpenMP support
You can try cygwin.
cygwin is gcc compiler by GNU for windows.

Compiling C++ for OSX from Windows

I have a small console based, standards compliant, C++ program that I developed in Visual Studio on Windows. Since it is in standard C++, is all I need to do is compile it for OSX? or am I being overly optimistic?
I am looking for the easiest and most straightforward way to do this. Is it possible to do from Visual Studio 2012 Professional? If necessary I have access to a Mac. However, since my dev platform is Windows, it would be nice if I could do it from here.
I'm not experienced with mac development at all. When you compile an application for OSX, what do you get instead of a .exe?
If you don't mind installing MinGW or Cygwin to your Windows machine, you can build a Windows to OS X cross-toolchain as per the instructions here: https://github.com/Tatsh/xchain
I would get an OSX system (a VM is fine), install XCode and then compile your code using that. Should be trivial if your C++ code is written in a cross platform way.

cross compiling with Eclipse on linux and eclipse on windows?

I am pretty much new to embedded device programming world so pardon my ignorance if any.
I am cross compiling a C++ program on arm architecture with eclipse on ubuntu.
Then i have to burn the code and see the output with the device that has a linux kernel in it.
Then i came across a tutorial about cross compiling C++ program on arm architecture with eclipse on Windows. So my question is, Can i run this program (from windows) on my embedded device which has a linux kernel in it????
Thanks
A
If you are using a cross compiler, then the answer is yes. It should produce a linux libraries and executive file. You might need to adjust the files parameters (like set permissions and execute flag).
Yes.
eclipse is a great tool, especially when coupled with gcc. You can definitely use a ready-built compiler to extend eclipse as long as that compiler is available for Windows.
Here is a link to some documentation on how to change the toolchain in an eclipse project -
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.cdt.doc.user/reference/cdt_u_prop_build_toolchain.htm