Skip to content

Key CUDA and HIP APIs and Qualifiers

1. Which function qualifier in CUDA and HIP is used to define a function that executes on the GPU and is callable from the CPU?

  • A. __host__
  • B. __device__
  • C. __global__
  • D. __constant__
Click to reveal the answer Answer: C. `__global__`

Variable Qualifiers in CUDA and HIP

2. True or False: The __shared__ qualifier in CUDA and HIP specifies that the variable is accessible only by threads within the same block.

Click to reveal the answer Answer: True

3. Which qualifier is used to define a variable that resides in read-only memory and is accessible by all threads on the GPU?

  • A. __device__
  • B. __shared__
  • C. __global__
  • D. __constant__
Click to reveal the answer Answer: D. `__constant__`

Thread Qualifiers in CUDA and HIP

4. What does threadIdx represent in CUDA and HIP?

  • A. The number of threads in each block.
  • B. The index of the current thread within its block.
  • C. The dimensions of the grid.
  • D. The number of blocks in the grid.
Click to reveal the answer Answer: B. The index of the current thread within its block.

5. In CUDA, a warp is composed of how many threads?

  • A. 16
  • B. 32
  • C. 64
  • D. 128
Click to reveal the answer Answer: B. 32

6. True or False: In HIP (for AMD GPUs), a wavefront typically contains 64 threads.

Click to reveal the answer Answer: True

Memory Access in CUDA and HIP

7. Which memory qualifier would you use to store a variable in global memory, making it accessible from both the host and the GPU?

  • A. __device__
  • B. __shared__
  • C. __constant__
  • D. __local__
Click to reveal the answer Answer: A. `__device__`