














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















TB lifecycle residency rule
Correct Answer: Thread blocks reside on their assigned SMs for their entire lifecycle (from assignment to end of execution).
dim3 syntax (C)
Correct Answer: dim3 my_xyz(x_value, y_value, z_value);
Built-in CUDA indexing variables
Correct Answer: threadIdx.(x, y, z), blockDim.(x, y, z), blockIdx.(x, y, z), gridDim.(x, y, z)
TB mapping order assumption
Correct Answer: Thread blocks may be assigned to SMs in random order; do not assume a specific mapping order.
Where does synchronize go in C?
Correct Answer: In C, the synchronize call appears after the kernel launch line.
Instruction Decoder (CPU core)
Correct Answer: CPU core component that decodes instructions into control signals/operations (as shown in the diagram).
Global thread index formula (1D grid of 1D blocks)
Correct Answer: i = blockIdx. x * blockDim. x + threadIdx. x
Thread index in a 1D block
Correct Answer: i = threadIdx. x
Why CUDA synchronization is needed
Correct Answer: To ensure all threads finish processing before collecting results.
Extra threads problem
Correct Answer: More threads may be allocated than needed for the data size.
Kernel (definition)
Correct Answer: A kernel is a device-only function that must be explicitly designated in code.
CUDA cores contain what units?
Correct Answer: CUDA cores are a cluster of units including INT, FP32/FP64, Tensor, and special function units.
CUDA kernel (basic idea)
Correct Answer: A CUDA kernel is the GPU function you deploy across the grid of threads (as part of CUDA programming).
CPU core (hardware blocks shown)
Correct Answer: A CPU core includes ALU/FPU, Control Unit, Cache, Registers, Program Counter, MMU, Prefetch Buffer, Instruction Decoder, and Branch Predictor.
Thread identification for vector addition
Correct Answer: The first N threads handle the vector addition, where N is the vector length.
Can multiple thread blocks share the same SM?
Correct Answer: Yes, multiple thread blocks may share the same SM (if resources allow).
What if SM resource capacity does not meet a TB's requirement?
Correct Answer: The job will not be launched.
Tuple-like example (2D grid, 2D block)
Correct Answer: 2D grid of 2 by 4 blocks and 2D blocks of 4 by 2 threads (y by x): blocks_per_grid(4,2,1); threads_per_block(2,4,1)
blockDim values in 1D block
Correct Answer: blockDim. x=N; blockDim. y=1; blockDim. z=
Built-in CUDA variables (block dimensions)
Correct Answer: blockDim. x, blockDim. y, blockDim. z
Two key quantities when requesting a grid
Correct Answer: (1) Number of threads per thread block, and (2) Number of thread blocks.
Special function unit (inside CUDA cores)
Correct Answer: Hardware for special math functions (as listed in the lecture's CUDA core unit cluster).
Built-in CUDA variables (threads)
Correct Answer: threadIdx. x, threadIdx. y, threadIdx. z
Thread block dimensionality options
Correct Answer: A thread block can be organized in 1D, 2D, or 3D.
Cost per execution unit (GPU vs CPU)
Correct Answer: On average, each GPU execution unit ("CUDA core") costs less than a CPU execution unit.
2D thread block shape
Correct Answer: (N, M, 1)
Prefetch Buffer (CPU core)
Correct Answer: CPU core buffer that preloads upcoming instructions/data (as shown in the diagram).
Multi-dimensional launch coordinates
Correct Answer: For multi- dimensional arrangement, use a coordinate like (x, y, z).
How is a multidimensional grid executed on SMs?
Correct Answer: CUDA internally linearizes a multidimensional grid and executes it as a 1D grid.
How to handle extra threads
Correct Answer: Pass a memory bound to the kernel, and inside the kernel check if the mapped index exceeds the bound before doing work.
CPU parallelism measurement
Correct Answer: CPU parallelism is commonly measured by the number of CPU cores.
What if you allocate more threads than needed?
Correct Answer: Pass a memory bound to the kernel and check inside the kernel whether the mapped index exceeds the bound before doing work.
Cleaning memory in C + CUDA
Correct Answer: Memory must be cleaned in C, and CUDA memory must also be cleaned manually.
Multidimensional indexing idea
Correct Answer: CPU core component that tracks the next instruction to execute (as shown in the diagram).
Tuple-like example (1D)
Correct Answer: dim3 blocks_per_grid(1,1,1); dim3 threads_per_block(2,1,1); then <<>>
Organization example: Thread block 1 with Grid 2
Correct Answer: Thread block stays (x=8, y=1, z=1) while grid is (x=4, y=2, z=1).
Grid request (CUDA programming topic)
Correct Answer: Specifying the grid/thread-block configuration before launching a kernel (listed as a topic).
Kernel (CUDA term)
Correct Answer: Each worker function in CUDA is called a "kernel".
mem_bound meaning in 1D
Correct Answer: mem_bound is the size of the array.
gridDim values in 1D grid
Correct Answer: gridDim. x=N; gridDim. y=1; gridDim. z=
When do "on hold" TBs run?
Correct Answer: When active TBs finish and release SM resources, TBs on the waitlist get assigned to available SMs.
Python multi-dimensional dims
Correct Answer: In Python, a simple tuple (x, y, z) is used for dimensional parameters.
Independent execution: start times
Correct Answer: Thread blocks execute independently-some may start early or late depending on the scheduler.
Grid/block organization dimensions
Correct Answer: Both grids and thread blocks can be organized as 1D, 2D, or 3D (and they can differ in dimensionality).
gridDim values in 3D grid
Correct Answer: gridDim. x=N; gridDim. y=M; gridDim. z=K
Python multi-dim kernel params
Correct Answer: In Python, a simple tuple (x, y, z) works for multi-dimensional settings.
CUDA core vs CPU core (functionality mapping)
Correct Answer: A CUDA core is like an execution unit on a CPU core; one SM (collection of CUDA cores) is like one CPU core.
Built-ins in Python access
Correct Answer: In Python, use cuda. threadIdx. x etc. (prefix with cuda.)
GPU parallelism measurement
Correct Answer: GPU parallelism is commonly measured by (# of CUDA cores) × (# of SMs).
After GPU job finishes, how access results on CPU?
Correct Answer: Copy results from GPU memory back to CPU memory before accessing them.
What does "# of threads per block" represent?
Correct Answer: # of threads per block is the block dimension.
Correct Answer: Grid 1: dimension=4 with coordinates (x=1, y=1, z=1) (as shown in the table).
Assumption to avoid about SM sharing
Correct Answer: Do not assume how multiple thread blocks will share the same SM (or which ones will share).
Where to place synchronize in Python
Correct Answer: In Python, the synchronize call appears at the end of the kernel function.
When do "on hold" TBs run?
Correct Answer: When active TBs finish and release SM resources, TBs on the waitlist are assigned to available SMs.
Grid (definition)
Correct Answer: A grid is a collection of threads grouped into thread blocks; deploying a function on GPU deploys the job on a grid.
dim3 argument type warning
Correct Answer: dim3 arguments are unsigned integers; be mindful when computing values.
Global index: 1D grid of 1D blocks
Correct Answer: i = blockIdx. x * blockDim. x + threadIdx. x
After GPU work, how do you access results on CPU?
Correct Answer: Copy results from GPU memory back to CPU memory.
TB lifecycle rule
Correct Answer: Thread blocks stay on their assigned; SMs for their entire lifecycle (assignment → completion).
FP64 unit (inside CUDA cores)
Correct Answer: Floating-point (64-bit) arithmetic/operations hardware inside a CUDA core.
Built-in variables in Python (access)
Correct Answer: In Python, add "cuda." before built-in variables (e. g., cuda. threadIdx. x).
2D grid shape
Correct Answer: (N, M, 1)
Scalar example: <<<1, 2>>>
Correct Answer: 1D grid of a 1D block of 2 threads.
Matrix linear index formula (x, y) in MxN
Correct Answer: y * N + x
1D grid shape
Correct Answer: (N, 1, 1)
C coordinate types for launch dims (dimX)
Correct Answer: In C, CUDA uses dimX types where X ∈ {2,3,4}; most commonly dim3.
Why GPU tends to have more "cores" than CPU
Correct Answer: Compared to a CPU, a GPU has more execution units ("CUDA cores").
Kernel launch concept
Correct Answer: Launching a kernel is like calling a function, except you must specify grid/block dimensions.
Thread (definition)
Correct Answer: A thread is the smallest execution unit ("the hard worker").
Kernel-to-thread mapping
Correct Answer: Each kernel instance is mapped to a thread.
Vector addition (goal)
Correct Answer: Implement vector addition by parallelizing the work across GPU threads.
1D thread block shape
Correct Answer: (N, 1, 1)
Built-in CUDA variables (grid dimensions)
Correct Answer: gridDim. x, gridDim. y, gridDim. z
How CPU vs GPU parallelism is measured
Correct Answer: CPU parallelism is often measured by number of CPU cores; GPU parallelism is often measured by (# CUDA cores × # SMs).
Built-in CUDA variables (block indices)
Correct Answer: blockIdx. x, blockIdx. y, blockIdx. z
Linear index of (x, y) in an M×N matrix
Correct Answer: y * N + x
Ampere A100 (context on slide)
Correct Answer: A named example GPU architecture/model referenced in the lecture slide: "Ampere A100".
When do thread blocks share the same SM?
Correct Answer: When there are too many TBs and an SM has enough resources to handle more than one TB's resource needs.
Organization example: Grid 2 (x, y, z)
Correct Answer: Grid 2: (x=4, y=2, z=1).
Why request a grid before running GPU work?
Correct Answer: You must request a grid with the right amount of threads before deploying the job.
Global index: 1D grid of 2D blocks
Correct Answer: i = blockIdx. x * blockDim. x * blockDim. y + threadIdx. y * blockDim. x + threadIdx. x
threadIdx ranges in 1D block
Correct Answer: threadIdx. x: 0... N-1; threadIdx. y always 0; threadIdx. z always 0
TB mapping order guarantee?
Correct Answer: There is no guaranteed order: thread blocks may be assigned to SMs in a random order; do not assume a specific mapping order.
TB lifecycle on an SM
Correct Answer: Thread blocks stay on their assigned SMs for their entire lifecycle (from assignment to completion).
Cache (CPU core)
Correct Answer: On-chip memory in a CPU core used to store frequently accessed data/instructions (as shown in the diagram).
C multi-dim coordinate type for kernel params
C kernel specifier
Correct Answer: In C, a kernel function must be declared with the "global" specifier.
Before passing CPU data to GPU, what must you do?
Correct Answer: Allocate GPU memory of the same size and copy data from CPU memory to GPU memory.
What is inside a "CUDA core" (high level)?
Correct Answer: CUDA cores are a cluster of units including INT, FP32/FP64, Tensor, and special function units.
MMU (CPU core)
Correct Answer: Memory Management Unit; handles memory address translation/management (as shown in the diagram).
Data transfer (CUDA programming topic)
Correct Answer: Moving data between CPU memory and GPU memory is a required part of many CUDA programs (listed as a topic).
TB→SM mapping rule
Correct Answer: A thread block (TB) is mapped to a single SM.
FP32 unit (inside CUDA cores)
Correct Answer: Floating-point (32-bit) arithmetic/operations hardware inside a CUDA core.
Kernel launch syntax (Python)
Correct Answer: kernel_name# of blocks, # of threads per block
Scalar launch assumption
Correct Answer: Using scalars makes the system assume a 1D dimension.
Deploying a function on GPU means what?
Correct Answer: Each time we deploy a function on the GPU, we deploy the job on a grid.
CPU vs GPU tasks (high level)
Correct Answer: CPU is sequential & complex; GPU is parallel & simple.
Streaming Multiprocessor (SM)
Correct Answer: An SM is a major processing unit on a GPU chip; each GPU chip contains multiple SMs.
CPU/GPU memory sharing
Correct Answer: GPU and CPU cannot share memory.
Grid/block dimensionality options
Correct Answer: Both grids and thread blocks can be organized in 1D, 2D, or 3D (and they can have different dimensionalities).
TB splitting rule
Correct Answer: A thread block cannot be split across multiple SMs.
blockIdx ranges in 1D grid
Correct Answer: blockIdx. x: 0... N-1; blockIdx. y always 0; blockIdx. z always 0
Tensor unit (inside CUDA cores)
Correct Answer: Specialized hardware units used for tensor/matrix-style operations (as listed in the lecture's CUDA core unit cluster).
gridDim values in 2D grid
Correct Answer: gridDim. x=N; gridDim. y=M; gridDim. z=
Who can call a device function?
Correct Answer: Only kernels can call a device function.
"Linearized by CUDA internally" means what?
Correct Answer: Even if the grid is defined in multiple dimensions, CUDA flattens it into a 1D ordering for execution.
TB independent execution (finish times)
Correct Answer: Depending on workload, some thread blocks may finish early or late.
Why "use GPU" in application code?
Correct Answer: To parallelize work: keep sequential/complex parts on CPU and offload parallel/simple parts to GPU.
Organization example: Grid 3 (x, y, z)
Correct Answer: Grid 3: (x=4, y=2, z=4).
When do multiple TBs share one SM?
Correct Answer: When there are too many TBs AND one SM has enough resources to handle more than one TB's resource requirements.
GPU Hardware Model (hierarchy)
Correct Answer: A GPU has a two-level hierarchy: GPU chip → multiple Streaming Multiprocessors (SMs) → each SM has multiple (non-identical) "CUDA cores".
TB→SM mapping rule (core rule)
Correct Answer: A thread block (TB) is mapped to a single SM and cannot be split across multiple SMs.
Can grid and thread blocks have different dimensions?
Correct Answer: Yes. A grid and its thread blocks can have different numbers of dimensions.
What if there are more than NK TBs on the grid?
Correct Answer: At most NK TBs run; the remaining TBs are put on hold (waitlist).
Why multi-block > single-block (same total threads)?
Correct Answer: Because each thread block maps to an SM; multi-block uses multiple SMs in parallel.
Total threads in a grid (basic idea)
Correct Answer: Total threads = (# thread blocks) × (# threads per thread block) (taking dimensionality into account).
INT unit (inside CUDA cores)
Correct Answer: Integer arithmetic/operations hardware inside a CUDA core.
CUDA core (in the GPU model)
Correct Answer: A CUDA core is a processing/execution unit within an SM; CUDA cores in an SM can be non-identical.
host specifier (CUDA C)
Correct Answer: Non-kernel (CPU) functions can be marked with "host" (optional to write).
Two ways to specify dimensional parameters
Correct Answer: Use scalars for 1D; use tuple-like objects for multi-dimensional structures.
Thread block (definition)