GPU Coder

Amdahl’s law in parallel processing

What is the Amdahl’s law? This law which is named after Gene Amdahl is quite fundamental in the field of parallel programming and is quite extensively used. The Amdahl’s law is used to predict how much speedup can be obtained by parallelizing a particular algorithm.

Amdahl’s law states that the overall speedup of applying the improvement will be:
\frac{1}{(1 - P) + \frac{P}{N}}
which represents the speedup achievable from an improvement to a computation that affects a proportion P of that computation when the improvement has a speedup of S.

To understand this equation better, let N be the number of cores over which the algorithm will be divided or distributed upon and let P be the proportion of the algorithm that is parallelized. Then (1-P) is the portion of the program that is sequentially executed.

Now lets try an intuitive derivation of the Amdahl’s law. To start off, we define speedup as the ratio of the time taken to execute a program using a serial algorithm to the time taken to execute a program using a parallel algorithm. Here, time can be in any unit. So, if we have an algorithm that is executed sequentially and we create a new algorithm for the same problem that is identical to our sequential algorithm (new algorithm is also sequential), then speedup is obviously 1. Because we did not do anything new.

Read More »



Dieter Rams : Ten Principles for Good Design

I hadn’t heard about Dieter Rams until today and I am now in love with his design. Well not software design — but actual stuff that is in daily use like radio, furniture, shelving, etc. Have a look at this link and you will begin to appreciate his design sense too.

http://www.vitsoe.com/en/gb/about/dieterrams/gooddesign

Here are the 10 design principles by Dieter Rams,

  1. Good design is innovative.
  2. Good design makes a product useful.
  3. Good design is aesthetic.
  4. Good design makes a product understandable.
  5. Good design is unobtrusive.
  6. Good design is honest.
  7. Good design is long-lasting.
  8. Good design is thorough, down to the last detail.
  9. Good design is environmentally-friendly.
  10. Good design is as little design as possible.

I think this list applies just as well to software design and programming. Especially point #6 on being honest and not promising the world from your product (think SEO in 10 days ;) ).

But the absolute killer is #8 “Good design is thorough, down to the last detail”.  This is so important in today’s world with all the zillion programming languages, job-hopping, team-programming, agile programming and every other conceivable stunt in front of your compiler.

Good, detailed programming with proper tables and data structures,  with oodles of sensible comments and documentation can save every one a trip to the cardiology ward .. don’t you agree?

“Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious.”— Fred Brooks in “The Mythical Man-Month”


clGetDeviceIDs function in OpenCL

In the earlier posts “Hello World” and clGetPlatformIDs( ) we looked at a simple OpenCL program and the use of the function clGetPlatformIDs( ) to query the number of platforms and their IDs in the hardware present that can be used by OpenCL. Now that we have the platform IDs, we can use another function clGetDeviceIDs to get a list of devices on a particular platform.
The function prototype for clGetDeviceIDs ( ) is

cl_int clGetDeviceIDs ( cl_platform_id platform, cl_device_type device_type,
cl_uint num_entries, cl_device_id *devices,  
cl_uint *num_devices )

Here are a list of the OpenCL device types that can be specified in the function call as given in the OpenCL spec.

Read More »



clGetPlatformIDs function in OpenCL

In the earlier post Hello World”, there was an extremely brief intro to OpenCL and how to install it on Win XP with SP3. now I am going to delve into the commands, structures, keywords specific to the OpenCL language that were covered in the Hello World program in the post mentioned at the start of this post.

You can actually look at OpenCL as a querying language where you use in the inbuilt primitives and you can extract some information from your hardware. Something similar to using grep to count the number of 1s or 0s in a txt file you just dumped your data into. Using this analogy, we would like to find out how many and what platforms are available that support OpenCV. Or OpenCL platforms as they are referred to. Read More »



Hello World in OpenCL

Hi there. In this post I am going to walk through the installation of OpenCL on a Windows XP operating system with Service Pack 3. I will also run through a very simple program in OpenCL … kinda like a “Hello World” program to get the ball rolling. It sometimes amazes me how much information about a programming language can be gleaned from its “hello world” program. Like telling whether a kid’ll become a hot shot lawyer from hearing his “dada-mama” talk? Anyways back to the topic at hand ….the machine that I am using is a Dell Optiplex 760 with an Intel Core2 Duo processor and a ATI Radeon graphics card.

The first step is to download and install the latest AMD APP SDK release from this link. However, if this link is not working anymore, then click here to search for the AMD APP SDK on google –>click here .

Once you download the file, extract it and install the SDK (it is a simple process and gets over in a couple of minutes). Once we are done with this installation .. we can start writing programs and testing the parallel processing capabilities in OpenCL.  Read More »



What is the OpenCL standard?

To really understand the question “What is OpenCL”, I looked at two definitions that stare at you when you open the Khronos website ..

  1. OpenCL is an open standard for parallel programming of heterogeneous systems.
  2. OpenCL™ is the first open, royalty-free standard for cross-platform, parallel programming of modern processors found in personal computers, servers and handheld/embedded devices. OpenCL (Open Computing Language) greatly improves speed and responsiveness for a wide spectrum of applications in numerous market categories from gaming and entertainment to scientific and medical software.

This may look like a lot of words and jargon but the two definitions complement each other and give a succinct understanding of what OpenCL means.

Read More »



What is GPU computing?

Since everything on this site is dedicated to GPU computing, its good to develop an idea of what GPUs are and how they function and what makes them so awesome ! We know that GPU stands for Graphics Processing Unit and the more generalized term used nowadays is GP-GPU or General Purpose- Graphics Processing Unit. It makes a lot of sense to use the term GP-GPU because GPUs aren’t really restricted to working on GPUs. That is what they were meant for and used for in most computers because image manipulation is quite an intensive process (think of playing your HD movies on your laptop or shooting an enemy sniper in Call of Duty) .. yea all the processes to ensure that you have a seamless visual experience needs some serious number crunching and FAST !

Will Smith : So can I throw my CPU and put a GPU in its place??
Alfred Lanning : Sorry detective. My responses are limited. You must ask the right question.
Will Smith : Hmm… so if a GPU does number crunching and can run algorithms  * like a CPU * does, then what differentiates it from a CPU?
Alfred Lanning : That detective…. is the right question.

Read More »