wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CUDA C/C++ Basics Quiz

Total questions: 25

Worksheet time: 53mins

Name
Class
Date
1.

What is CUDA?

4 lines
2.

What will you learn in this session?

4 lines
3.

You (probably) need experience with C or C++

4 lines
4.

What is the purpose of the __syncthreads() function?

4 lines
5.

What does the CUDA C/C++ keyword __global__ indicate?

a)

A function that runs on the host

b)

A function that runs on the device

c)

A function that is called from device code

d)

A function that is called from host code

6.

What is the first step in the Simple Processing Flow?

a)

Load GPU code and execute it

b)

Copy input data from CPU memory to GPU memory

c)

Copy results from GPU memory to CPU memory

d)

Manage GPU memory

7.

What is the output of the following code: printf("Hello World!\n");?

a)

Hello World!

b)

Hello World

c)

Hello

d)

World!

8.

What is the purpose of the cudaMalloc() function?

4 lines
9.

What is the result of the add() kernel when executed?

4 lines
10.

What is the significance of the triple angle brackets in mykernel<<<1,1>>>();?

4 lines
11.

What is referred to as a block in parallel invocation of add()?

a)

Each parallel invocation of add()

b)

The set of blocks

c)

The grid

d)

The block index

12.

What does blockIdx.x refer to in the context of the add() function?

a)

The index of the block

b)

The index of the thread

c)

The size of the array

d)

The number of blocks

13.

What is the purpose of cudaMalloc() in the main() function?

a)

To allocate space for device copies

b)

To copy data from host to device

c)

To free allocated memory

d)

To launch the kernel

14.

What is the significance of using threadIdx.x instead of blockIdx.x?

a)

To handle different elements of the array

b)

To execute in parallel

c)

To index into the array

d)

To declare a function as device code

15.

How do you calculate the unique index for each thread when using both blocks and threads?

a)

int index = threadIdx.x + blockIdx.x * M

b)

int index = blockIdx.x + threadIdx.x * M

c)

int index = blockIdx.x * M + threadIdx.x

d)

int index = threadIdx.x * M + blockIdx.x

16.

What is the purpose of the if condition in the add() function when handling arbitrary vector sizes?

a)

To avoid accessing beyond the end of the arrays

b)

To ensure all threads execute

c)

To synchronize threads

d)

To allocate memory

17.

What mechanisms do threads have to efficiently communicate and synchronize?

4 lines
18.

What is the output element in a 1D stencil applied to a 1D array of elements?

4 lines
19.

How many input elements are read from global memory to shared memory when caching data?

4 lines
20.

What is the purpose of __syncthreads() in CUDA programming?

4 lines
21.

What happens if thread 15 reads the halo before thread 0 has fetched it?

4 lines
22.

What is the role of cudaMemcpy() in managing device memory?

4 lines
23.

What does the compute capability of a device describe?

4 lines
24.

What are the built-in variables used in CUDA for thread and block identification?

4 lines
25.

What are the characteristics of textures in CUDA?

4 lines