Sign in to follow this  

Questions about GPGPU

This topic is 1035 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know compute shaders use HLSL, Nvidia has CUDA etc and so on. My question is can C++ be made to run on GPU? If yes, will it be faster than HLSL and CUDA ?

Edited by Inder

Share this post


Link to post
Share on other sites

L. Spiro is the man, one word and you got the answer.

You have to bind the compiled shader and the graphic card knows what he has to do, no other way.

Edited by Alundra

Share this post


Link to post
Share on other sites
In a similar vein to C++ AMP, there's SYCL, a khronos standard to embed opencl code directly into c++ code.

It's also worth noting that opencl 2.1 adopted a subset of c++14 as a compute kernel language (basically all of c++ except what you'd expect not to be possible on a GPU)

Share this post


Link to post
Share on other sites
Cuda and opencl 2.1 (no driver supports it atm) allow you to write c++ kernel.
But you can't write function in pure c++ (or even c) code that will execute on the gpu transparently, except maybe with c++ amp.

Share this post


Link to post
Share on other sites

I have one more question - Which will be more quicker? C++ amp or direct compute 

 
And direct compute can do all those things that C++ amp can do?

Share this post


Link to post
Share on other sites


I have one more question - Which will be more quicker? C++ amp or direct compute 

 

C++ AMP compiles to a DirectCompute shader on the GPU side, and to (potentially) multi-threaded, SIMD-parallel code on the CPU side (for when a GPU is not available). It is likely that an hand-tuned DirectCompute shader written by someone with considerable skill will outperform an equivalent C++ AMP compute kernel, in the same way that assembly code written by someone with considerable experience doing that will likely match or beat your C++ compiler.

 

What you gain for coding in C++ vs Assembly, or C++ AMP vs DirectCompute, is that you get to work at a higher and more productive level. What you can do in a day or week in C++ or C++ AMP would usually take that expert several days or weeks to accomplish in Assembly or DirectCompute. And there are relatively fewer of these experts than there are people who can/could write C++ or C++ AMP. That makes their time a very valuable commodity, which is why they're only called on for performance-critical sections of code. With something like C++ AMP, you can take a reasonably competent programmer who's not even half the GPGPU programmer your staff GPGPU expert is, and they can create a solution in less time that likely achieves ~80% the performance of what it takes your expert days or weeks to accomplish. That's the draw of something like AMP.

 

The other appeal of AMP, specifically, is that AMP is not just C++, its actually *inside* your program, mixed in with (and potentially sharing code dependencies with) your normal C++ application code. I believe this is not the case with Cuda (Which, IIRC is a separate sort of linking step), and is definitely not the case with DirectCompute/OpenCL unless I'm mistaken.

Share this post


Link to post
Share on other sites
Sign in to follow this