Hello World from GPU with CUDA and HIP¶
1. Which keyword in CUDA and HIP marks a function to execute on the GPU?
- A) 
__host__ - B) 
__global__ - C) 
__device__ - D) 
__shared__ 
Click to reveal the answer
Answer: B) `__global__`Kernel Launch Configuration¶
2. What does the syntax <<<1, 1>>> specify in CUDA kernel launches?
- A) It sets one GPU block with one thread.
 - B) It defines one CPU thread to run the GPU function.
 - C) It sets the kernel to run on one GPU core.
 - D) It specifies that the function will run on a single CPU core.
 
Click to reveal the answer
Answer: A) It sets one GPU block with one thread.Synchronization¶
3. True or False: cudaDeviceSynchronize() in CUDA and hipDeviceSynchronize() in HIP ensure the CPU waits until the GPU completes all tasks.
Click to reveal the answer
Answer: TrueHIP Portability¶
4. Which of the following is true about HIP?
- A) HIP code only runs on AMD GPUs.
 - B) HIP code can be compiled to run on both AMD and NVIDIA GPUs.
 - C) HIP requires major syntax changes from CUDA.
 - D) HIP is only compatible with OpenCL devices.
 
Click to reveal the answer
Answer: B) HIP code can be compiled to run on both AMD and NVIDIA GPUs.Thread Synchronization in Kernels¶
5. In both CUDA and HIP, which command synchronizes all threads within a GPU block?
- A) 
cudaDeviceSynchronize()orhipDeviceSynchronize() - B) 
__device_sync() - C) 
__syncthreads() - D) 
gpu_synchronize()