View on GitHub ROCm_Logo

ROCm, a New Era in Open GPU Computing

Platform for GPU-Enabled HPC and Ultrascale Computing

Overview

The AMD ROCm Platform supports OpenCL as of ROCm 1.6!

As of ROCm 2.0, this includes the following:

Quickstart Instructions

Here is a simple workflow to get you quickly up and running with OpenCL on ROCm. First, a supported kernel driver is required to allow AMD’s use-level ROCm software to access supported GPUs. For many ROCm installations, this is the rock-dkms kernel driver package. However, if you are using a newer kernel (depending on your GPU, this can be as early as 4.17), you can choose to use the upstream kernel driver and skip installing any ROCm-specific drivers.

Install the ROCm OpenCL Runtime

Once you have a working kernel driver, the following command can be used to install the ROCm OpenCL runtime on Ubuntu:

sudo apt-get install rocm-opencl-dev

If you are using RHEL/CentOS, you can use the following command ionstead:

sudo yum install rocm-opencl-devel
Test your OpenCL Installation

For a sample OpenCL application, let’s use a simple vector-add example from the University of Bristol’s very nice “Hands On OpenCL” lectures.

OPENCL_ROOT=/opt/rocm/opencl/
git clone https://github.com/HandsOnOpenCL/Exercises-Solutions.git

cd Exercises-Solutions/Exercises/Exercise02/C

make \
  CCFLAGS="-I$OPENCL_ROOT/include/ -O3 -DDEVICE=CL_DEVICE_TYPE_DEFAULT" \
  LIBS="-L$OPENCL_ROOT/lib/x86_64 -lOpenCL -lm"

./vadd

Note that your applications will need to include OpenCL headers when you compile it. These can be found in /opt/rocm/opencl/include/ in ROCm installations, and they are added by the rocm-opencl-dev (on Ubuntu) and rocm-opencl-devel (on RHEL/CentOS) packages.

If you have previously built your applications on a system using the AMD APP SDK, you do not need to install anything else besides rocm-opencl. You only need to set the AMDAPPSDKROOT environment variable to point towards /opt/rocm/opencl/. Please do not install the AMD APPS DK along with ROCm OpenCL. The former is designed for old drivers and may cause older versions of the OpenCL runtime to be instantiated.

Example 1 for AMDAPPSDKROOT

export AMDAPPSDKROOT=/opt/rocm/opencl 

Example 2 for AMDAPPSDK

export AMDAPPSDK=/opt/rocm/opencl

Where is clinfo?

/opt/rocm/opencl/bin/x86_64/clinfo 
That’s it! Super easy.

ROCm Developer website will have more information: http:/rocm.github.io

University of Bristol’s “Hands On OpenCL” course webpage: https://handsonopencl.github.io/