OpenMP Offloading: Data Transfer with map
Clause¶
1. What is the primary function of the map(to:)
clause in OpenMP Offloading?
- A. Allocates memory on the device without initializing it.
- B. Copies data from the device back to the host after execution.
- C. Transfers the original variable from the host to the device at the start of the region.
- D. Synchronizes data between the host and device at any point.
Click to reveal the answer
Answer: C. Transfers the original variable from the host to the device at the start of the region.Types of map
Clauses¶
2. Which map
clause should be used if the variable is updated on the device and needs to be available on the host after computation?
- A.
map(to:)
- B.
map(from:)
- C.
map(alloc:)
- D.
map(delete:)
Click to reveal the answer
Answer: B. `map(from:)`3. True or False: The map(alloc:)
clause allocates memory for a variable on the device without copying any data from the host.
Click to reveal the answer
Answer: TruePractical Data Management with target data
and target update
¶
4. Which OpenMP construct is used to keep data on the device across multiple target regions without remapping it each time?
- A.
target update
- B.
target data
- C.
target teams
- D.
parallel
Click to reveal the answer
Answer: B. `target data`5. True or False: The target update from(list)
clause is used to transfer data from the host to the device within a target data
region.
Click to reveal the answer
Answer: False (It updates data from the device back to the host).target enter data
and target exit data
¶
6. Which construct should be used to allocate device memory without immediately executing code?
- A.
target
- B.
target data
- C.
target enter data
- D.
target exit data
Click to reveal the answer
Answer: C. `target enter data`7. In the following code, what will the target exit data
construct do for array C
?
#pragma omp target exit data map(from: C[0:n]) map(delete: A[0:n], B[0:n])
- A. Transfer
C
from the device to the host and keepA
andB
on the device. - B. Transfer
C
from the device to the host and deleteA
andB
on the device. - C. Keep
C
on the device but transferA
andB
to the host. - D. Delete
C
,A
, andB
from the device without transferring data to the host.
Click to reveal the answer
Answer: B. Transfer `C` from the device to the host and delete `A` and `B` on the device.8. True or False: The map(tofrom:)
clause ensures that the variable is both copied to the device at the start of the region and copied back to the host after the region ends.
Click to reveal the answer
Answer: True9. Which OpenMP construct allows you to synchronize data from the device to the host during the execution of a target data region?
- A.
target update
- B.
map(from:)
- C.
target enter data
- D.
target exit data
Click to reveal the answer
Answer: A. `target update`10. In OpenMP Offloading, what does the map(delete:)
clause do?
- A. Deletes the data from the device without copying it back to the host.
- B. Deletes the data from the device and copies it back to the host.
- C. Allocates memory on the device but does not initialize it.
- D. Copies the data to the device without copying it back.