Coursera

[GPU programming] CUDA Constant and Shared Memory Quiz

star.candy 2022. 7. 27. 21:34
질문 1

C​onstant memory size on a GPU is in direct relation to the number of streaming multiprocessors (SMs).

F​alse

T​his is the correct answer. Based on the GPU device, there is a fixed maximum amount of constant memory that can be allocated, which is not based on the number of SMs.

S​hared memory sizes for GPU devices has always been larger than 128 MB.

F​alse

T​his is true because shared memory is fairly small, below 200KBs per SM and started at 16 KB per SM with at most dozens of SMs on the most powerful devices.
 
질문 3

T​he extern keyword is used in conjunction with shared memory allocation in which execution target(s) to indicate dynamic memory will be shared on the GPU card?

device

T​his keyword indicates that this function is executed on the GPU and being called by a function also on the device. When the extern keyword is used during memory allocation on the GPU, the memory available is dynamic, determined during runtime.

global

T​his keyword indicates that the function will executed on the device, and in this case shared memory would be dynamic.

질문 4

W​hich keyword is used as part of shared memory allocation?

__shared__

 

질문 5

W​hen writing code that uses shared memory, which of the following are valid considerations (pros and cons) for whether to use this type of memory?

S​hared memory can be faster than global memory

T​his is correct because if the size of shared memory allocation is within per SM limits, it will be faster than global memory.

S​hared memory is an mechanism for threads within the same block to share data in a fast manner.

T​his is correct. It is a common way for threads within a block to communicate, such as giving access to interim results that will not be placed in global memory.

The value in s​hared memory may change based on the logical and physical order of reads and writes, so tools such as thread barriers will need to be considered.

This is correct, as you will need to consider this when developing device kernels.

질문 6

W​hich function is used to allocate transfer data from the host to device constant memory?

c​udaMemcpyToSymbol

This is the correct function, as its sole use is in copying data from host to device constant memory.