Q:

Install OpenCL/Pyopencl on Ubuntu 14.04

There are a lot of instructions on how to get OpenCL running on Ubuntu, but all of them are outdated (>4 years) or simply not working.  
Is there any current, working tutorial on how to get open CL running on Ubuntu (14.04 or 15.04)?  
I tried to follow this instruction but I wonder if it's best practice to install from a converted *rpm as it seems to be kind of a hack.  

A:

If you want to code on your CPU/GPU the AMD guide is probably a good place to start.  To get the OpenCL drivers working on a computer with an AMD APU/GPU you simply need to install the fglrx driver from the software center.  To test that its working and to write code you may also want the AMD APP SDK. 
I used version 3.0 of the SDK from the AMD site. 
The install guide is here. 
Once you have it you can follow their programming guide. 
Here is one of the early examples modified to simply print out the number of compute units on your machines GPU:
            //
            // Copyright (c) 2010 Advanced Micro Devices, Inc. All rights reserved. 
            // Modified by Aedazan for learning purposes. 
            // Uploaded as fair use teaching material 17 U.S. Code § 107. 
            // A minimalist OpenCL program. 
            #include <CL/cl.h>
            #include <stdio.h>

            #define NWITEMS 512

            // A simple memset kernel

            //const char *source = "__kernel void memset( __global uint *dst ) \n" "{ \n" " dst[get_global_id(0)] = get_global_id(0);  \n" "} \n";
            const char *source = "__kernel void memset( __global uint *dst ) " "{ " " dst[get_global_id(0)] = get_global_id(0)*get_global_id(0);" 
            ""
            "\n" "} \n";

            int main(int argc, char ** argv)
            {
            // 1.  Get a platform. 
            cl_platform_id platform;
            clGetPlatformIDs( 1, &platform, NULL );
            // 2.  Find a gpu device. 
            cl_device_id device;
            cl_uint compute_units;
            clGetDeviceIDs( platform, CL_DEVICE_TYPE_GPU,1,&device,NULL);
            clGetDeviceInfo( device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint), &compute_units, NULL);
            printf("Compute units: %d\n", compute_units);

            // 3.  Create a context and command queue on that device. 
            cl_context context = clCreateContext( NULL, 1, &device, NULL, NULL, NULL);
            cl_command_queue queue = clCreateCommandQueue( context, device, 0, NULL );
            // 4.  Perform runtime source compilation, and obtain kernel entry point. 
            cl_program program = clCreateProgramWithSource( context, 1, &source, NULL, NULL );
            clBuildProgram( program, 1, &device, NULL, NULL, NULL );
            cl_kernel kernel = clCreateKernel( program, "memset", NULL );
            // 5.  Create a data buffer. 
            cl_mem buffer = clCreateBuffer( context, CL_MEM_WRITE_ONLY, NWITEMS * sizeof(cl_uint), NULL, NULL );

            // 6.  Launch the kernel.  Let OpenCL pick the local work size. 
            size_t global_work_size = NWITEMS;
            clSetKernelArg(kernel, 0, sizeof(buffer), (void*) &buffer);
            clEnqueueNDRangeKernel( queue,
            kernel,
            1,
            NULL,
            &global_work_size,
            NULL, 0, NULL, NULL);
            clFinish( queue );
            // 7.  Look at the results via synchronous buffer map. 
            cl_uint *ptr;
            ptr = (cl_uint *) clEnqueueMapBuffer( queue, buffer, CL_TRUE, CL_MAP_READ, 0, NWITEMS * sizeof(cl_uint), 0, NULL, NULL, NULL );
            int i;
            for(i=0; i < NWITEMS; i++)
            //printf("%d %d\n", i, ptr[i]);
            return 0;
            }

You can compile it with the following line.  It assumes you installed the SDK as root into the default locations. 
gcc -o computec.bin -I /opt/AMDAPPSDK-3.0/include/ -L /opt/AMDAPPSDK-3.0/lib/x86_64/ test.c -lOpenCL

