Link to this document's Jupyter Notebook

In order to successfully complete this assignment you need to participate both individually and in groups during class. If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class on Monday March 1. If you are attending asynchronously, turn in your assignment using D2L no later than _11:59pm on Monday March 1.


In-Class Assignment: CUDA

progression of older GPU cards

Image from: https://www.amax.com/blog/?p=907

Agenda for today's class (70 minutes)

  1. (20 minutes) Pre class Review
  2. (20 minutes) BCCD CUDA Example
  3. (30 minutes) Vector Add Example

1. Pre class Review

0228--CUDA_Intro_pre-class-assignment

We learned the following in the video:

  1. You must use a dev node with a CUDA card (Ex. dev-intel14-k20 or dev-intel16-k80).
  2. You need to install the CUDA software (How do we do that on the HPC?).
  3. Once you do that, build thee software and run it.
#define CUDA_CALL(x) {cudaError_t cuda_error__ = (x); if (cuda_error__) printf("CUDA error: " #x " returned \"%s\"\n", cudaGetErrorString(cuda_error__));}

Steps in a common CUDA program:


2. BCCD CUDA Example

DO THIS: In the class Git repository, go back to the BCCD directory and compile and run the CUDA example. Read though the output and discuss it with your neighbors and the class.


3. Vector Add Example

The following is a vector add example.

DO THIS: Copy and paste the above code to the HPCC and get it to compile and run.

DO THIS: Analyse the code and see if you can figure out what it is doing. Where are the key steps?

DO THIS: Think about why this code does not do a fair timing comparison between the CPU and the GPU. Make modifications to make it a more fair comparison.

DO THIS: As in the pre-class video, the exit codes for the CUDA program are not being checked. Add the CUDA_CALL command to your program.


Congratulations, we're done!

If you attend class in-person then have one of the instructors check your notebook and sign you out before leaving class. If you are attending asynchronously, turn in your assignment using D2L.

Course Resources:

Written by Dr. Dirk Colbry, Michigan State University Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.