Skip to content

Introduction to OpenMP Offloading

1. In OpenMP Offloading, which directive is primarily used to specify code regions that should be executed on a device, such as a GPU?

  • A. #pragma omp parallel
  • B. #pragma omp for
  • C. #pragma omp target
  • D. #pragma omp simd
Click to reveal the answer Answer: C. `#pragma omp target`

Device Memory Management and Data Movement

2. Which of the following map clauses is used to transfer data from the host (CPU) to the device (GPU) before computation?

  • A. map(from:)
  • B. map(to:)
  • C. map(tofrom:)
  • D. map(alloc:)
Click to reveal the answer Answer: B. `map(to:)`

3. True or False: In OpenMP Offloading, the map(tofrom:) clause ensures that data is updated both on the device and on the host, allowing bidirectional data movement.

Click to reveal the answer Answer: True

Offloading and Parallelization

4. Which directive divides loop iterations across multiple teams on a device, making it particularly useful for GPU offloading in OpenMP?

  • A. teams
  • B. declare target
  • C. distribute
  • D. target
Click to reveal the answer Answer: C. `distribute`

Compilation and Tool Support

5. To enable OpenMP Offloading targeting an NVIDIA GPU using Clang, which compilation flag would you use?

  • A. -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa
  • B. -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
  • C. -mp -gpu=cc70
  • D. -fopenmp-targets=spir64
Click to reveal the answer Answer: B. `-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda`

Practical Understanding

6. True or False: OpenMP Offloading's teams and parallel directives can be combined to organize work distribution across teams of threads on a GPU.

Click to reveal the answer Answer: True