HPC OpenCL Exercise: Hands-On Lab


As mentioned last week, there are three programming platforms for using graphics cards for general purpose computing:

  1. CUDA is Nvidia's proprietary but free platform that works (only) with Nvidia devices. It is the oldest and most well-established framework, and it is the best documented.
  2. OpenCL is a non-proprietary standard that can use any OpenCL compatible cores (CPU or GPU) in a system. It is supported by AMD/Radeon, Nvidia, Apple, Intel, ...
  3. OpenACC is a (currently proprietary) standard that provides a higher level interface to the GPU, similar to what OpenMP does for multithreading. It is supported by the Portland Group International (PGI) and Cray, among others.
This week, we will explore how to use OpenCL. Since OpenCL is platform independent, you can use it on your Ulab workstation, which is equipped with an AMD/Radeon 7850, which has 1024 "stream processors" we can throw at a problem.

Getting Started

If you have not already done so, read over this Dr. Dobbs Journal article on OpenCL.

Hands On

After reading the article, download the two source files add_numbers.c and add_numbers.cl and figure out how to get them working on your workstation.

Once you have them working, modify them as follows:

  1. Using argc and argv, add logic so that the number of array elements can be specified from the command-line.
  2. Using OpenMP's omp_get_wtime() call, measure and compare the run-times of these programs. Create a line-chart comparing the two programs' times for 50,000; 500,000; 5,000,000; and 50,000,000 array elements.
  3. In the OpenCL program, measure the time required for each of the OpenCL steps of the computation. Create a "stacked" bar graph showing these times for 50,000; 500,000; 5,000,000; and 50,000,000 array elements.

When you are finished, you may continue to this week's project.

CS > 374 > Exercise > 10 > Hands-On Lab

This page maintained by Joel Adams.