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. Students must come to class the next day prepared to discuss the material covered in this assignment.


PCA 22: CUDA Memory Tiling#

Goals for today’s pre-class assignment#

  1. Tiling

  2. Transpose Example

  3. Assignment wrap up


1. Tiling#

A GPU does not do automatic memory caching like a CPU. Instead you need to do all of work for memory management yourself. The following video gives a brief overview of the concept of tiling.

from IPython.display import YouTubeVideo
YouTubeVideo("tGu5DyIlofY",width=640,height=360)

QUESTION: Which of the following two code snippets (foo or bar) would benefit from tiling?

__global__ void foo(flout d_out[], float d_A[], float d_B[], float d_C[], float d_D[], float d_E[], int N)
{
    int tid = threadIdx.x;
    int i = tid + blockIdx.x*blockDim.x;
    if (i < N)
        d_out[i] = (d_A[i] + d_[i] + d_C[i] + d_D[i] + d_E[i]) / 5.0;
}
__global__ void bar(flout d_out[], float d_in[], int N)
{
    int tid = threadIdx.x;
    int i = tid + blockIdx.x*blockDim.x;
    if (i < N)
        d_out[i] = (d_in[i-2] + d_in[i-1] + d_in[i] + d_in[i+1] + d_in[i+2]) / 5.0;
}

QUESTION: Explain your answer to the above question.

Put your answer to the above question here.


2. Matrix Transpose#

The following video describes how you might improve the performace of matrix transpose using tiling.

from IPython.display import YouTubeVideo
YouTubeVideo("pP-1nJEp4Qc",width=640,height=360)

QUESTION: Explain why a matrix transpose is difficult to tile for large matrices. Can you come up with any clever ways to get tiling to work?

Put your answer to the above question here.


3. 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 Survey Form

Assignment-Specific QUESTION: No assignment specific question.

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

from IPython.display import HTML
HTML(
"""
<iframe 
	src="https://cmse.msu.edu/cmse401-pc-survey" 
	width="100%" 
	height="500px" 
	frameborder="0" 
	marginheight="0" 
	marginwidth="0">
	Loading...
</iframe>
"""
)

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.

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.