Page MenuHomePhabricator

Setup OpenCL on Nouveau using SPIR-V
ActivePublic

Authored by pmoreau on Jan 18 2016, 10:48 PM.
#!/bin/bash
# Last updated: 06 May 2017 18:10 GMT+1
ROOT_DIR=${1}
if [[ -z ${ROOT_DIR} ]]
then
echo "You need to specify a root directory where the software will be cloned/installed."
unset ROOT_DIR
exit 1
fi
cd ${ROOT_DIR}
ROOT_DIR=`pwd`
LLVM_DIR="${ROOT_DIR}/llvm"
SPVTOOLS_DIR="${ROOT_DIR}/spvtools"
MESA_DIR="${ROOT_DIR}/mesa"
LLVM_INSTALL_PREFIX="${ROOT_DIR}/llvm_install"
SPVTOOLS_INSTALL_PREFIX="${ROOT_DIR}/spvtools_install"
MESA_INSTALL_PREFIX="${ROOT_DIR}/mesa_install"
# Cloning LLVM and clang + building
git clone -b khronos/spirv-3.6.1 https://github.com/pierremoreau/SPIRV-LLVM.git llvm
cd ${LLVM_DIR}/tools
git clone -b spirv-1.0 https://github.com/KhronosGroup/SPIR.git clang
cd ${ROOT_DIR}
mkdir llvm_build
cd llvm_build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL_PREFIX}" -DBUILD_SHARED_LIBS=On -DLLVM_TARGETS_TO_BUILD="X86" -DSPIRV_USE_LLVM_API=On ${LLVM_DIR}
make install
# Cloning and building SPIRV-Tools
cd ${ROOT_DIR}
git clone -b for_nouveau https://github.com/pierremoreau/SPIRV-Tools.git spvtools
cd spvtools/external
git clone https://github.com/google/googletest.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git spirv-headers
cd ${ROOT_DIR}
mkdir spvtools_build
cd spvtools_build
cmake -DCMAKE_INSTALL_PREFIX="${SPVTOOLS_INSTALL_PREFIX}" -DCMAKE_BUILD_TYPE=Release -DSPIRV_BUILD_COMPRESSION=ON ../spvtools
make install
# Cloning and building Mesa
cd ${ROOT_DIR}
git clone -b nouveau_spirv_support https://phabricator.pmoreau.org/diffusion/MESA/mesa.git mesa
mkdir mesa_build
cd mesa_build
../mesa/autogen.sh --prefix=${MESA_INSTALL_PREFIX} --disable-gles1 --disable-gles2 --disable-gbm --disable-egl --disable-osmesa --disable-xvmc --disable-va --disable-vdpau --enable-llvm -with-dri-drivers= --enable-dri3 --with-gallium-drivers=nouveau --enable-opencl --with-llvm-prefix=${LLVM_INSTALL_PREFIX} --enable-debug
make install
# Generate env file
cd ${ROOT_DIR}
echo "#!/bin/bash
PATH=\"${LLVM_INSTALL_PREFIX}/bin:${SPVTOOLS_INSTALL_PREFIX}/bin:${MESA_INSTALL_PREFIX}/bin:${PATH}\"
LD_LIBRARY_PATH=\"${LLVM_INSTALL_PREFIX}/lib:${SPVTOOLS_INSTALL_PREFIX}/lib64:${MESA_INSTALL_PREFIX}/lib:${LD_LIBRARY_PATH}\"
PKG_CONFIG_PATH=\"${SPVTOOLS_INSTALL_PREFIX}/lib64/pkgconfig:${MESA_INSTALL_PREFIX}/lib/pkgconfig/:${PKG_CONFIG_PATH}\"
ACLOCAL=\"aclocal -I ${LLVM_INSTALL_PREFIX}/share/aclocal:${MESA_INSTALL_PREFIX}/share/aclocal\"
export LD_LIBRARY_PATH PKG_CONFIG_PATH ACLOCAL PATH" > mesa-spirv-env.sh
chmod +x mesa-spirv-env.sh
echo "An environment file was created in \"${ROOT_DIR}\": just source it before running any OpenCL program."
# Unset variables
unset ROOT_DIR
unset LLVM_DIR
unset SPVTOOLS_DIR
unset MESA_DIR
unset LLVM_INSTALL_PREFIX
unset SPVTOOLS_INSTALL_PREFIX
unset MESA_INSTALL_PREFIX

Event Timeline

pmoreau created this paste.Jan 18 2016, 10:48 PM
pmoreau created this object with visibility "Public (No Login Required)".
pmoreau edited the content of this paste. (Show Details)Apr 22 2016, 9:11 PM
pmoreau edited the content of this paste. (Show Details)Apr 23 2016, 2:04 AM
pmoreau edited the content of this paste. (Show Details)Apr 20 2017, 10:24 AM
pmoreau changed the edit policy from "All Users" to "GPGPU Support (Project)".
pmoreau edited the content of this paste. (Show Details)Apr 20 2017, 5:26 PM
pmoreau edited the content of this paste. (Show Details)May 6 2017, 6:11 PM
pmoreau edited the content of this paste. (Show Details)Sep 18 2017, 7:45 PM
pmoreau edited the content of this paste. (Show Details)Sep 18 2017, 8:12 PM
pmoreau edited the content of this paste. (Show Details)Sep 18 2017, 8:21 PM
pmoreau edited the content of this paste. (Show Details)Sep 19 2017, 12:40 AM
pmoreau edited the content of this paste. (Show Details)Sep 20 2017, 11:36 PM
pmoreau edited the content of this paste. (Show Details)Sep 20 2017, 11:41 PM
pmoreau edited the content of this paste. (Show Details)Oct 22 2017, 9:04 PM
pmoreau edited the content of this paste. (Show Details)Dec 2 2017, 4:54 PM
pmoreau edited the content of this paste. (Show Details)Dec 2 2017, 4:58 PM