TIDE
Languages

OpenCL

Installing OpenCL development environment on Ubuntu in TIDE

OpenCL

OpenCL (Open Computing Language) is an open, cross-platform standard for low-level parallel programming across heterogeneous systems including CPUs, GPUs, DSPs, and FPGA accelerators.

Installation

Install OpenCL headers, ICU loader, POCL (Portable Computing Language CPU backend), and GCC:

apt update
apt install -y build-essential ocl-icd-opencl-dev opencl-headers pocl-opencl-icd clinfo

Verification

Check available OpenCL platforms and devices using clinfo:

clinfo

Writing and Compiling Code

Create a C program named main.c that uses OpenCL:

#include <stdio.h>
#include <CL/cl.h>

int main() {
    cl_platform_id platform;
    cl_uint num_platforms;
    cl_int err = clGetPlatformIDs(1, &platform, &num_platforms);
    
    if (err == CL_SUCCESS && num_platforms > 0) {
        char name[128];
        clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(name), name, NULL);
        printf("Hello, OpenCL Platform: %s\n", name);
    } else {
        printf("Hello, OpenCL! (No active platform detected)\n");
    }
    return 0;
}

Compile the program linking against libOpenCL:

gcc main.c -lOpenCL -o hello_opencl

Run the binary:

./hello_opencl

Official Resources

On this page