OpenCL - adda-team/adda GitHub Wiki

OpenCL is a framework for programming highly parallel devices like graphic cards (GPUs) and mutlicore CPUs. The ADDA implementation works on relatively modern GPUs, for details and benchmarks see (Huntemann et al. 2011). The main limitations are the required support of double precision floating point operations and the maximum problem size being limited by the available GPU memory, more specifically, by its part available to ADDA. See also other limitations. The following outlines the setup of environment. For compiling ADDA you may also need Installing clFFT and Installing clBLAS (the latter is used for optional features under development). ADDA itself requires support for OpenCL 1.0, but commonly linked clFFT requires OpenCL 1.2.

Unix

  • Install recent GPU driver. There are two options:
    • Obtain it from the corresponding vendor (Nvidia or AMD).
    • Use driver packages if available. They are usually more convenient to install and update. Also they cause less trouble with kernel updates. The drawback is a delay in updates relative to original vendor drivers. Moreover, for some systems there are no official packages, since the driver is not open-source. In this case search in non-official repositories, like RPM Fusion. On Ubuntu search for packages nvidia-###-updates or for AMD fglrx-updates (incompatible with kernel linux > 3.13, which instead includes kernel module amdgpu; the latter, however, is incompatible with AMD cards architecture older than gcn 1.2).

To obtain headers and libraries there are several options:

  • Either use vendor SDK, e.g. (Nvidia CUDA toolkit. Additionally, you will get some nice development tools, such as visual profiler. We have, however, encountered issues with headers and libraries (for linking) themselves. One of such issues is errors during linking of clFFT with message like
    ...libclFFT.so: undefined reference to `clRetainContext@OPENCL_1.0'
    
    This particular one can be solved by uncommenting the line
    LDFLAGS +=-Wl,--unresolved-symbols=ignore-in-shared-libs
    
    in ocl/Makefile. Still, if you encounter this or other problems, we recommend to try other options below.
  • Or obtain a special package, e.g. ocl-icd-opencl-dev for Ubuntu. It is based on open-source implementation of libOpenCL.so, which further links to vendor-specific libraries.
  • Or supply the files manually:
    • Get headers from the official repository, e.g., by git:
      git clone https://github.com/KhronosGroup/OpenCL-Headers.git
      
      or install a special package, e.g., opencl-headers.
    • Installed GPU driver always provides libraries, which are used at runtime. Compiler can link to them directly.
    • update the environment:
      • add headers location to environmental variables C_INCLUDE_PATH and CPLUS_INCLUDE_PATH and libraries location - to LIBRARY_PATH and LD_LIBRARY_PATH (for linking and runtime). Setting LD_LIBRARY_PATH can be replaced by modifying /etc/ld.so.conf, which sometimes is done automatically during driver installation.
      • or specify paths to corresponding include and lib folders in ocl/Makefile, as described in CompilingADDA. You may also need updating LD_LIBRARY_PATH as described above.

macOS

Windows

  • Download and install recent GPU driver from the corresponding vendor (Nvidia or AMD). Most probably, it is already installed on your system.

The driver alone is sufficient to run ADDA OpenCL executables, e.g. those that are provided for 64-bit Windows. To compile OpenCL version of ADDA you will need additionally headers and libraries. Potentially, they can be obtained from vendor SDK, e.g. (Nvidia CUDA toolkit, but we recommend another option:

  • Download headers from official repository. They can also be obtained and further updated by git:
    git clone https://github.com/KhronosGroup/OpenCL-Headers.git
    
  • If you are setting up the MinGW/MSYS environment with advanced instructions follow those instructions.
  • Alternatively, do the following:
    • GCC can link to OpenCL.dll (located in C:\Windows\System32). However, on 64-bit Windows this system folder is not accessible (substituted) for a 32-bit application (such as a compiler). Thus, it is necessary to move this DLL to (or create a link to it in) a non-system folder using a 64-bit application (Windows Explorer or a file manager) .
    • specify paths to this non-system folder and folder with headers in ocl/Makefile, as described in CompilingADDA.
⚠️ **GitHub.com Fallback** ⚠️