Live data from Hacker News

An Even Easier Introduction to CUDA

devblogs.nvidia.com

41–50 of 60 posts

Re: An Even Easier Introduction to CUDA

#41
post #29

Earlier quoted context omitted.

I think that the closed nature of CUDA will be its undoing. I think that a standard, like C++ amp or openMP-4.5 will be the the ultimate winner. I liked openCL but it seems to be dying.

Apple seems to have abandoned OpenCL in favor of Metal, which speaks to your case of it dying. I found Metal Compute Shaders to be very nice to work with, though. Was much easier for me to understand than OpenCL.

I also like metal, but it is not yet performant for high performance computing, which is more my wheelhouse. I'm also skeptical it will be popular if it does not get picked up by the GPGPU folks, but time will tell.

Re: An Even Easier Introduction to CUDA

#42
post #36
post #18

Earlier quoted context omitted.

OK so basic background here: CUDA processing usually looks like some dimensional array of data (1d, 2d, 3d, etc). Then you have a series of "warps" which tesselate their way through your data space processing a chunk of elements at a time. The warps can be organized into larger "blocks" to share data between parts of the warp. Many blocks make up a "grid", which is more or less synonymous with "the processing element…

If I format this up nicely as a blog post: I'd like to draw some spatial diagrams. I'm a compsci programmer, not a math prof. I need to draw 2D and 3D spaces, like a 3x3x3 cube, or an arbitrary sized space, with selectable highlighting for each unit-cube in the space. Can someone please help me with an appropriate tool here? I'm sure there's got to be some Python module out there or something. I don't even know what…

In my experience, I've found it easy to make figures with Wolfram Mathematica (the python analogue would be matplotlib) and with Tikz (http://www.texample.net/tikz/examples/all/)

If you want to check out what might be possible within the Mathematica system, you could try out https://www.wolframalpha.com/

Further, hand-drawing on a tablet using a stylus is highly underrated.

Re: An Even Easier Introduction to CUDA

#43
post #18

Earlier quoted context omitted.

OK so basic background here: CUDA processing usually looks like some dimensional array of data (1d, 2d, 3d, etc). Then you have a series of "warps" which tesselate their way through your data space processing a chunk of elements at a time. The warps can be organized into larger "blocks" to share data between parts of the warp. Many blocks make up a "grid", which is more or less synonymous with "the processing element…

Thanks for that support, I suppose I should just keep trying. Realistically perhaps I should do GPU code for vector problems rather than trying to do it in anger on "hard" problems with tons of branching. I think part of the problem is also that I don't know C++ (and more or less refuse to learn it, old dogs etc...). Usually I have some higher level code and wish to speed up parts of it. You should clean up that comm…

CMU has a few lectures on this open to the public: http://15418.courses.cs.cmu.edu/fall2016/lectures Check out Lecture 7: GPU Architecture and CUDA Programming it starts 16mins in after some review.

Udacity also has a parallel image processing algorithms w/CUDA course though I haven't done it https://www.udacity.com/course/intro-to-parallel-programming...

Re: An Even Easier Introduction to CUDA

#45

Does anyone familiar with the state of GPU programming think OpenCL will eventually 'win' over CUDA? Although CUDA has more adoption, I don't like the idea of using it and being locked into a specific vendor. Of course nVidia is only supporting outdated versions of OpenCL for now. Am I a fool for hoping OpenCL eventually becomes the standard?

Honestly for those of us in machine learning, I think something like XLA will likely win over both paradigms. (Disclaimer, I work on XLA.)

https://www.tensorflow.org/versions/master/experimental/xla/

XLA much more closely matches what you want for ML than CUDA/opencl. Which isn't a surprise; it was designed specifically for ML.

Kernel launches are expensive, so any fast CUDA system has to let you compose computations into a single kernel (e.g. multiply by 5 and then take tanh). It's possible to do this in CUDA, but it requires heoric C++ template metaprogramming. It's not uncommon to have files that take ten minutes to compile. Whereas in XLA kernel fusion is nbd, because it's a JIT.

Also, because XLA is generating GPU code after it's seen your model, it can specialize computations specifically to your model. In regular TensorFlow (and I presume other ML frameworks, although I'm not at all familiar with them), you have to compile all of your kernels upfront. This means that the framework probably doesn't have the ideal set of kernels for your model, because the framework's set of kernels needs to be generic. For example, the framework probably isn't going to have a "multiply by 5 and then take tanh" kernel -- if you're lucky, it might have a "multiply by X and then take tanh", but notice that this may be slower because X is now not a constant.

In contrast, not only can XLA specialize for your weird X==5 case, but it can also specialize all of the dimensions of your arrays. This is a really big advantage in many cases.

As just one example, it's common for kernels to do something like

  int index = some computation based on threadIdx and blockIdx;
  if (index 
But in XLA we know the size of the kernel, so we know the possible values for threadIdx and blockIdx, and we know the exact value of array_len. We can therefore often optimize out the if entirely.

Re: An Even Easier Introduction to CUDA

#46
post #45

Does anyone familiar with the state of GPU programming think OpenCL will eventually 'win' over CUDA? Although CUDA has more adoption, I don't like the idea of using it and being locked into a specific vendor. Of course nVidia is only supporting outdated versions of OpenCL for now. Am I a fool for hoping OpenCL eventually becomes the standard?

Honestly for those of us in machine learning, I think something like XLA will likely win over both paradigms. (Disclaimer, I work on XLA.) https://www.tensorflow.org/versions/master/experimental/xla/ XLA much more closely matches what you want for ML than CUDA/opencl. Which isn't a surprise; it was designed specifically for ML. Kernel launches are expensive, so any fast CUDA system has to let you compose computations…

Why no AMD GPU support?

Re: An Even Easier Introduction to CUDA

#47

Does anyone familiar with the state of GPU programming think OpenCL will eventually 'win' over CUDA? Although CUDA has more adoption, I don't like the idea of using it and being locked into a specific vendor. Of course nVidia is only supporting outdated versions of OpenCL for now. Am I a fool for hoping OpenCL eventually becomes the standard?

I've been evaluating Cuda and OpenCL while trying to produce some target independent code.

My impression is that while Cuda might not win, OpenCL will almost certainly lose. OpenCL seems to be a monster compromise interface which takes into account all the architectures of the members of a large consortium. It's the sort-of designed-by-committee api that a developer has to fight against to accomplish anything. Naturally its many years behind Cuda in features, etc.

An open-source library with equivalent qualities to Cuda is needed- ie, a library intended to aid developers, allow abstract c++ to be easily become parallel code, provide reasonable tools and documentation etc.

One promising example is amd's Hip

"HIP allows developers to convert CUDA code to portable C++. The same source code can be compiled to run on NVIDIA or AMD GPUs."

https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP

Re: An Even Easier Introduction to CUDA

#48
post #20

Is there a preprocessor in the chain? Because add >>(N, x, y); isn't regular C++. Sorry if I missed something.

The triple angle bracket syntax is used to specify execution details when the device code's sent to the GPU -- the details are outlined under "Picking up the threads" in the OP.

Re: An Even Easier Introduction to CUDA

#49

It's really a shame that openCL doesn't have the market share that CUDA does (or kudos are awaiting NVidia's marketing and foresight to invest so heavily in the tooling around its hardware...) because the raw compute performance of AMD hardware is superior to that of AMD and often cheaper.

"...superior to that of Nvidia.." /edit

Re: An Even Easier Introduction to CUDA

#50
post #36

Earlier quoted context omitted.

If I format this up nicely as a blog post: I'd like to draw some spatial diagrams. I'm a compsci programmer, not a math prof. I need to draw 2D and 3D spaces, like a 3x3x3 cube, or an arbitrary sized space, with selectable highlighting for each unit-cube in the space. Can someone please help me with an appropriate tool here? I'm sure there's got to be some Python module out there or something. I don't even know what…

Have you tried Blender? It's a 3D modeling tool with a python interface. Might work nicely for what you want to do.

it's not as simple as I'd prefer for 2d but that's exactly what I want for 3D. Thank you.
Post reply on HN