Link to this document's Jupyter Notebook

In order to successfully complete this assignment you must do the required reading, watch the provided videos and complete all instructions. The embedded survey form must be entirely filled out and submitted on or before 11:59pm on Sunday March 7. Students must come to class the next day prepared to discuss the material covered in this assignment.


Pre-Class Assignment: The CUDA Memory Model

Goals for today's pre-class assignment

  1. Quick Overview of the CUDA Memory Model
  2. Coalescing global memory accesses
  3. Using shared memory
  4. CUDA Memory Example by doing Reduction
  5. Assignment wrap-up

1. Quick Overview of the CUDA Memory Model

The following video shows you how to schedule basic CUDA jobs on the HPCC.


2. Coalescing global memory accesses

QUESTION: Why does a large stride lower performance?

Put your answer to the above question here.

The following is a great reference on how to access global memory effectively:


3. Using shared memory

The following is a great reference on using Shared memory on cuda:

The basic syntac can be found here:

Static Shared memory:

__global__ void staticReverse(int *d, int n)
{
  __shared__ int s[64];
  int t = threadIdx.x;
  int tr = n-t-1;
  s[t] = d[t];
  __syncthreads();
  d[t] = s[tr];
}

Dynamic Shared Memory:

dynamicReverse<<<1, n, n*sizeof(int)>>>(d_d, n);

4. CUDA Memory Example by doing Reduction

DO THIS: I found the following code on Github which does a reduction similar to the one shown in the above video. Download the code and get it working on the HPCC.

You will need to do the following

DO THIS: Change the kernel function pointer on line 233 to point to the five different kernel options. Try each one and record the timing differences as compared to the cpu. Fill out the following table.


5. Assignment wrap-up

Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credits for the assignment!

Direct Link to Google Form

If you have trouble with the embedded form, please make sure you log on with your MSU google account at googleapps.msu.edu and then click on the direct link above.

Assignment-Specific QUESTION: Were you able to get the CUDA reduction example working on the HPCC? If not, where did you get stuck?

Put your answer to the above question here

QUESTION: Summarize what you did in this assignment.

Put your answer to the above question here

QUESTION: What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook?

Put your answer to the above question here

QUESTION: How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)?

Put your answer to the above question here

QUESTION: What was the most challenging part of this assignment for you?

Put your answer to the above question here

QUESTION: What was the least challenging part of this assignment for you?

Put your answer to the above question here

QUESTION: What kind of additional questions or support, if any, do you feel you need to have a better understanding of the content in this assignment?

Put your answer to the above question here

QUESTION: Do you have any further questions or comments about this material, or anything else that's going on in class?

Put your answer to the above question here

QUESTION: Approximately how long did this pre-class assignment take?

Put your answer to the above question here


Congratulations, we're done!

To get credit for this assignment you must fill out and submit the above survey from on or before the assignment due date.

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.