0 Replies Latest reply on Mar 20, 2018 9:58 AM by matszpk

    Mesa OpenCL with RX Vega support for OpenSUSE Tumbleweed


      Some days ago, I successfully ran the Mesa-OpenCL on my OpenSUSE Tumbleweed. Because, an OpenSUSE Tumbleweed still doesn't provide new LLVM 6.0 needed to support RX VEGA on Mesa-OpenCL, I wrote small tutorial to do it (these tutorial can be used on other Linux distros with missing LLVM 6.0).


      Before all, you need in your the Linux installation:

      * linux kernel 4.15 or later with AMDGPU drivers

      * GCC, G++ compilers - to compile sources

      * CMake - tool generate Makefiles

      * GNU make

      * Autoconf, Automake, libtool

      * devel packages (includes) for libdrm

      * Python (for libclc configure script)

      * OpenCL ICD - OpenCL Installable Client Driver

      * git - git source control system


      In this tutorial we install our Mesa-OpenCL to non-system directory (for safety) like '/opt/newgallium'. You should prepare sources before this procedure:

      * LLVM 6.0.0 - can be downloaded from http://llvm.org/

      * CLANG 6.0.0 - can be downloaded from http://llvm.org/

      * libclc (svn revision r319017 or later) - repository http://llvm.org/svn/llvm-project/libclc/trunk

      * Mesa (18.0.0-rc1 or later) - can be downloaded from https://www.mesa3d.org/


      Small note: before all preparation check umask (should 022 to set correct permissions for buildings and installation).


      Typical procedure to prepare sources:


      # LLVM with CLANG
      tar Jxvf llvm-6.0.0.src.tar.xz
      cd llvm-6.0.0.src
      cd tools
      tar Jxvf cfe-6.0.0.src.tar.xz
      mv cfe-6.0.0.src clang
      cd ../../ # top source directory
      # libclc
      svn checkout http://llvm.org/svn/llvm-project/libclc/trunk libclc
      # Mesa
      tar Jxvf mesa-18.0.0-rc4.tar.xz


      Now, we configure and build LLVM 6.0.0:


      cd llvm-6.0.0.src
      mkdir build
      cd build
      cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/newgallium -DLLVM_LIBDIR_SUFFIX=64
      make -j4


      Now, we can install LLVM 6.0 '/opt/newgallium' by using command (should be run as root):

      make install


      Now we should set LD_LIBRARY_PATH to LLVM 6.0.0 binaries:

      export LD_LIBRARY_PATH=/opt/newgallium/lib64

      Next step is building a libclc library:

      cd libclc
      ./configure --prefix=/opt/newgallium --with-llvm-config=/opt/newgallium/bin/llvm-config


      And libclc installation (should be run as root):

      make install


      Next step is Mesa3D building:

      cd mesa-18.0.0-rc4
      NOCONFIGURE=1 ./autogen.sh  # run autogen without configuring
      mkdir build
      cd build
      export PKG_CONFIG_PATH=/opt/newgallium/lib64/pkgconfig:/opt/newgallium/share/pkgconfig
      ../configure --prefix=/opt/newgallium --enable-opencl --enable-opencl-icd --enable-gbm --with-llvm-prefix=/opt/newgallium \
            --with-platforms=drm,x11 --with-dri-drivers=swrast,radeon \
            --with-gallium-drivers=svga,r600,radeonsi --enable-glx-tls
      make -j4


      And finally Mesa3D installation (as root):

      make install


      After all building and installation you should add to '/etc/OpenCL/vendors' directory your ICD (run as root):

      echo /opt/newgallium/lib64/libMesaOpenCL.so > /etc/OpenCL/vendors/newgallium.icd


      Sometimes, you need to set LD_LIBRARY_PATH to installation before testing a Mesa-OpenCL

      export LD_LIBRARY_PATH=/opt/newgallium/lib64


      Now, you can try installation by running command clinfo or other an OpenCL program.