Using Cache and Unified Memory in OpenACC¶
1. In OpenACC, what is the primary purpose of the cache
directive?
- A. To allocate memory on the CPU
- B. To store frequently accessed data in the GPU’s shared memory
- C. To transfer data from the GPU to the CPU
- D. To perform reduction operations
Click to reveal the answer
Answer: B. To store frequently accessed data in the GPU’s shared memoryCache Directive¶
2. True or False: The cache
directive in OpenACC can be applied to specific sections of an array to optimize memory access speed.
Click to reveal the answer
Answer: TrueUnified Memory¶
3. Which of the following best describes unified memory in OpenACC?
- A. It requires manual data transfers between CPU and GPU
- B. It uses a unified address space shared between the CPU and GPU, managing data transfers automatically
- C. It only supports single-dimensional arrays
- D. It is exclusive to Fortran programs
Click to reveal the answer
Answer: B. It uses a unified address space shared between the CPU and GPU, managing data transfers automatically4. True or False: When using unified memory in OpenACC, explicit data clauses like copyin
and copyout
are still required.
Click to reveal the answer
Answer: FalsePractical Usage¶
5. To enable unified memory in OpenACC, which compiler flag should be used?
- A.
-fast
- B.
-acc=gpu,managed
- C.
-Minfo=all
- D.
-acc