How to run code on a GPU?
Asked Answered
M

2

7

LLVM has a back end for both AMD and NVIDIA GPUS. Is it currently possible to compile c++ (or a subset) to GPU code with clang and run it? Obviously things like the standard library would be unavailable, as well as operator new and delete. I'm not looking for OpenCL or CUDA, I'm thinking of a fully ahead-of-time compiled program, even a trivial one.

Millymilman answered 7/3, 2017 at 5:36 Comment(1)
Cuda is normally compiled ahead of time. What do you mean?Nosey
S
7

No, you need some language like OpenCL or CUDA, because a GPGPU is not an ordinary computer and has a different programming model (grossly speaking, SIMD like). GPGPU compute kernels have specific constraints.

You might want to consider using OpenACC pragmas in your C++ code (and use a recent GCC compiler).

Skilken answered 7/3, 2017 at 5:41 Comment(0)
D
-1

Download the Cuda toolkit. The download may take a while. Be patient. Do the express installation and extract to standard location. Once finished, click the start button and type in "visual studio." Not VS Code, but click the other one, the one that looks old. Mine is called Visual Studio 2022. Open it up, set it up, click "new project," and then click Cuda. Name it whatever you want, and then you now have your first project that will run on a GPU.

Alternatively, After installing Cuda toolkit, watch this video

Docket answered 1/5 at 3:29 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Pathogenic

© 2022 - 2024 — McMap. All rights reserved.