<p>I am interested to know whether anyone has written an application that takes advantage of a <a href="http://en.wikipedia.org/wiki/GPGPU" rel="nofollow noreferrer">GPGPU</a> by using, for example, <a href="http://www.nvidia.com/object/cuda_get.html" rel="nofollow noreferrer">nVidia CUDA</a>.  If so, what issues did you find and what performance gains did you achieve compared with a standard CPU?</p>

[{'answer_id': 55410, 'author': 'rck', 'author_id': 5070, 'author_profile': 'https://Stackoverflow.com/users/5070', 'pm_score': 3, 'selected': False, 'text': "<p>I have been using GPGPU for motion detection (Originally using CG and now CUDA) and stabilization (using CUDA) with image processing.\nI've been getting about a 10-20X speedup in these situations.</p>\n\n<p>From what I've read, this is fairly typical for data-parallel algorithms.  </p>\n"}, {'answer_id': 55791, 'author': 'Tony BenBrahim', 'author_id': 80075, 'author_profile': 'https://Stackoverflow.com/users/80075', 'pm_score': 4, 'selected': False, 'text': '<p>I have written trivial applications, it really helps if you can parallize floating point calculations.</p>\n\n<p>I found the following course cotaught by a University of Illinois Urbana Champaign professor and an NVIDIA engineer very useful when I was getting started: <a href="http://courses.ece.illinois.edu/ece498/al/Archive/Spring2007/Syllabus.html" rel="nofollow noreferrer">http://courses.ece.illinois.edu/ece498/al/Archive/Spring2007/Syllabus.html</a> (includes recordings of all lectures).</p>\n'}, {'answer_id': 62208, 'author': 'Morten Christiansen', 'author_id': 4055, 'author_profile': 'https://Stackoverflow.com/users/4055', 'pm_score': 2, 'selected': False, 'text': '<p>While I haven\'t got any practical experiences with CUDA yet, I have been studying the subject and found a number of papers which document positive results using GPGPU APIs (they all include CUDA).</p>\n\n<p>This <a href="http://www.cse.ust.hk/catalac/papers/gpujoin_sigmod08.pdf" rel="nofollow noreferrer">paper</a> describes how database joins can be paralellized by creating a number of parallel primitives (map, scatter, gather etc.) which can be combined into an efficient algorithm.</p>\n\n<p>In this <a href="http://www.manavski.com/downloads/PID505889.pdf" rel="nofollow noreferrer">paper</a>, a parallel implementation of the AES encryption standard is created with comparable speed to discreet encryption hardware.</p>\n\n<p>Finally, this <a href="http://www.sciencedirect.com/science?_ob=ArticleURL&amp;_udi=B6WKJ-4SVV8GS-2&amp;_user=632453&amp;_rdoc=1&amp;_fmt=&amp;_orig=search&amp;_sort=d&amp;view=c&amp;_version=1&amp;_urlVersion=0&amp;_userid=632453&amp;md5=8041f5b9d8a14cd18e96b12881f8d1df" rel="nofollow noreferrer">paper</a> analyses how well CUDA applies to a number of applications such as structured and unstructured grids, combination logic, dynamic programming and data mining.</p>\n'}, {'answer_id': 229077, 'author': 'biozinc', 'author_id': 30698, 'author_profile': 'https://Stackoverflow.com/users/30698', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve implemented a Monte Carlo calculation in CUDA for some financial use. The optimised CUDA code is about 500x faster than a "could have tried harder, but not really" multi-threaded CPU implementation. (Comparing a GeForce 8800GT to a Q6600 here). It is well know that Monte Carlo problems are embarrassingly parallel though.</p>\n\n<p>Major issues encountered involves the loss of precision due to G8x and G9x chip\'s limitation to IEEE single precision floating point numbers. With the release of the GT200 chips this could be mitigated to some extent by using the double precision unit, at the cost of some performance. I haven\'t tried it out yet.</p>\n\n<p>Also, since CUDA is a C extension, integrating it into another application can be non-trivial.</p>\n'}, {'answer_id': 319096, 'author': 'Die in Sente', 'author_id': 40756, 'author_profile': 'https://Stackoverflow.com/users/40756', 'pm_score': 6, 'selected': True, 'text': '<p>I have been doing gpgpu development with <a href="http://ati.amd.com/technology/streamcomputing/sdkdwnld.html" rel="nofollow noreferrer">ATI\'s stream SDK</a> instead of Cuda.\nWhat kind of performance gain you will get depends on a <strong><em>lot</em></strong> of factors, but the most important is the numeric intensity.  (That is, the ratio of compute operations to memory references.)</p>\n\n<p>A BLAS level-1 or BLAS level-2 function like adding two vectors only does 1 math operation for each 3 memory references, so the NI is (1/3).  This is always run <em>slower</em> with CAL or Cuda than just doing in on the cpu.  The main reason is the time it takes to transfer the data from the cpu to the gpu and back.</p>\n\n<p>For a function like FFT, there are O(N log N) computations and O(N) memory references, so the NI is O(log N).  If N is very large, say 1,000,000 it will likely be faster to do it on the gpu; If N is small, say 1,000 it will almost certainly be slower.</p>\n\n<p>For a BLAS level-3 or LAPACK function like LU decomposition of a matrix, or finding its eigenvalues, there are O( N^3) computations and O(N^2) memory references, so the NI is O(N).  For very small arrays, say N is a few score, this will still be faster to do on the cpu, but as N increases, the algorithm very quickly goes from memory-bound to compute-bound and the performance increase on the gpu rises very quickly.</p>\n\n<p>Anything involving complex arithemetic has more computations than scalar arithmetic, which usually doubles the NI and increases gpu performance.</p>\n\n<p><a href="https://i.stack.imgur.com/kXBjR.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kXBjR.gif" width="500" height="298"></a><br>\n<sub>(source: <a href="http://home.earthlink.net/~mtie/CGEMM%20081121.gif" rel="nofollow noreferrer">earthlink.net</a>)</sub>  </p>\n\n<p>Here is the performance of CGEMM -- complex single precision matrix-matrix multiplication done on a Radeon 4870.</p>\n'}, {'answer_id': 852993, 'author': 'Tom Pohl', 'author_id': 20954, 'author_profile': 'https://Stackoverflow.com/users/20954', 'pm_score': 3, 'selected': False, 'text': '<p>I have used CUDA for several image processing algorithms. These applications, of course, are very well suited for CUDA (or any GPU processing paradigm).</p>\n\n<p>IMO, there are three typical stages when porting an algorithm to CUDA:</p>\n\n<ol>\n<li><strong>Initial Porting:</strong> Even with a very basic knowledge of CUDA, you can port simple algorithms within a few hours. If you are lucky, you gain a factor of 2 to 10 in performance.</li>\n<li><strong>Trivial Optimizations:</strong> This includes using textures for input data and padding of multi-dimensional arrays. If you are experienced, this can be done within a day and might give you another factor of 10 in performance. The resulting code is still readable.</li>\n<li><strong>Hardcore Optimizations:</strong> This includes copying data to shared memory to avoid global memory latency, turning the code inside out to reduce the number of used registers, etc. You can spend several weeks with this step, but the performance gain is not really worth it in most cases. After this step, your code will be so obfuscated that nobody understands it (including you).</li>\n</ol>\n\n<p>This is very similar to optimizing a code for CPUs. However, the response of a GPU to performance optimizations is even less predictable than for CPUs.</p>\n'}, {'answer_id': 853110, 'author': 'Edison Gustavo Muenz', 'author_id': 61915, 'author_profile': 'https://Stackoverflow.com/users/61915', 'pm_score': 0, 'selected': False, 'text': '<p>Yes. I have implemented the <a href="http://www.cs.huji.ac.il/~cheny/reading/diffusion/classic.pdf" rel="nofollow noreferrer">Nonlinear Anisotropic Diffusion Filter</a> using the CUDA api.</p>\n\n<p>It is fairly easy, since it\'s a filter that must be run in parallel given an input image. I haven\'t encountered many difficulties on this, since it just required a simple kernel. The speedup was at about 300x. This was my final project on CS. The project can be found <a href="http://projetos.inf.ufsc.br/arquivos_projetos/projeto_833/tcc_EdisonGustavoMuenz.pdf" rel="nofollow noreferrer">here</a> (it\'s written in Portuguese thou).</p>\n\n<p>I have tried writing the <a href="http://www.dam.brown.edu/people/mumford/Papers/DigitizedVisionPapers--forNonCommercialUse/89-Mumford-Shah.pdf" rel="nofollow noreferrer">Mumford&amp;Shah</a> segmentation algorithm too, but that has been a pain to write, since CUDA is still in the beginning and so lots of strange things happen. I have even seen a performance improvement by adding a <code>if (false){}</code> in the code O_O.</p>\n\n<p>The results for this segmentation algorithm weren\'t good. I had a performance loss of 20x compared to a CPU approach (however, since it\'s a CPU, a different approach that yelded the same results could be taken). It\'s still a work in progress, but unfortunaly I left the lab I was working on, so maybe someday I might finish it.</p>\n'}, {'answer_id': 895512, 'author': 'zenna', 'author_id': 93580, 'author_profile': 'https://Stackoverflow.com/users/93580', 'pm_score': 1, 'selected': False, 'text': '<p>I implemented a Genetic Algorithm on the GPU and got speed ups of around 7.. More gains are possible with a higher numeric intensity as someone else pointed out.  So yes, the gains are there, if the application is right</p>\n'}, {'answer_id': 1400387, 'author': 'GG.', 'author_id': 164933, 'author_profile': 'https://Stackoverflow.com/users/164933', 'pm_score': 1, 'selected': False, 'text': '<p>I have implemented Cholesky Factorization for solving large linear equation on GPU using ATI Stream SDK. My observations were </p>\n\n<p><img src="https://i.stack.imgur.com/vQZkq.jpg" alt="alt text"></p>\n\n<p>Got performance speedup upto 10 times.</p>\n\n<p>Working on same problem to optimize it more, by scaling it to multiple GPUs.</p>\n'}, {'answer_id': 14822167, 'author': "P O'Conbhui", 'author_id': 445799, 'author_profile': 'https://Stackoverflow.com/users/445799', 'pm_score': 1, 'selected': False, 'text': '<p>I wrote a complex valued matrix multiplication kernel that beat the cuBLAS implementation by about 30% for the application I was using it for, and a sort of vector outer product function that ran several orders of magnitude than a multiply-trace solution for the rest of the problem.</p>\n\n<p>It was a final year project. It took me a full year.</p>\n\n<p><a href="http://www.maths.tcd.ie/~oconbhup/Maths_Project.pdf" rel="nofollow">http://www.maths.tcd.ie/~oconbhup/Maths_Project.pdf</a></p>\n'}]
['https://Stackoverflow.com/questions/55403', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3305/']