This repository contains functional code examples for parallel programming using OpenACC. The repository is intended to help users learn and practice using OpenACC directives to accelerate their own codes.
- A OpenACC Compiler is required:
- NVIDIA HPC SDK compiler
- Cray compiler
- GCC (Configured with OpenACC)
- Clacc compiler (OpenACC support for clang/LLVM)
OpenACC Practicecodes can be built using CMake as follows:
-
Create a new directory for the build files and Change directory to the build directory.
-
Run the cmake command to generate the build files, pointing it to the CMakeLists.txt file.
-
Run the make command to build the project.You can then run the example programs by executing the resulting executables.
$ mkdir build && cd build
$ cmake -S ../ -B . -DCMAKE_C_COMPILER=nvc
$ make
$ ./<example_program>
Compiling and executing OpenACC code individually for different compilers, without using CMake.
To compile and run code for host:
export ACC_DEVICE_TYPE=host
gcc -fopenacc -foffload=disable program.c -o execfile -lm
To compile and run code for Nvidia and AMD GPU:
export ACC_DEVICE_TYPE=nvidia|radeon
gcc -fopenacc program.c -o execfile -lm
To compile and run code for host:
nvc -acc -ta=host -o execfile file.c
To compile and run code for multicores:
nvc -acc -ta=multicore -o execfile file.c
To compile and run code for Nvidia GPU:
nvc -acc -gpu=[options] -o execfile file.c
To compile and run code for only host:
clang -fopenacc -o execfile file.c
To compile and run code for Nvidia and AMD GPU:
clang -fopenacc -fopenmp-targets=nvptx64-nvidia-cuda -o execfile file.c
clang -fopenacc -fopenmp-targets=amdgcn-amd-amdhsa -o execfile test.c
To execute the compiled code, simply run the executable file:
./execfile
If you have any questions, issues, or suggestions related to this code, please feel free to contact the maintainers:
- Vaidhyanathan Ravichandran - [email protected]
- Sunita Chandrasekaran - [email protected]
- CRPL OpenACC Verification and Validation Testsuite - https://crpl.cis.udel.edu/oaccvv/
- The OpenACC website (https://www.openacc.org/) provides documentation on using the OpenACC programming model.
- GCC documentationGCC OpenACC documentation
- Nvidia documentationNVIDIA OpenACC documentation
- Cray documentationCray OpenACC documentation
- Clacc documentationClacc website
- Cuda website CUDA website