Skip to content

Instantly share code, notes, and snippets.

@antifermion
Last active February 20, 2019 11:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antifermion/bfc1a218af478a38da1a75118dd4ace9 to your computer and use it in GitHub Desktop.
Save antifermion/bfc1a218af478a38da1a75118dd4ace9 to your computer and use it in GitHub Desktop.
_git_url=https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git
_git_branch=roc-2.0.x
pkgname=rocm-opencl-git
pkgver=2.0.r0.184c0ef
pkgrel=1
pkgdesc="ROCm OpenCL™ Compatible Runtime"
arch=('x86_64')
url="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
license=('MIT')
groups=()
depends=(rocr-runtime)
makedepends=(cmake gcc git ocaml-findlib python2-z3 repo)
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
replaces=()
backup=()
options=()
source=()
prepare() {
cd "$srcdir"
# fetch everything as described in project's README
repo init -u ${_git_url} -b ${_git_branch} -m opencl.xml || exit 1
repo sync --force-sync || exit 1
}
pkgver() {
cd "$srcdir/opencl"
# Git tags _sometimes_ available
last_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
ver=${_git_branch#roc-}
commits_since_tag=$(git rev-list --count ${last_tag}..HEAD)
short_hash=$(git rev-parse --short HEAD)
printf "${ver%x}r%s.%s" ${commits_since_tag} ${short_hash}
}
build() {
cd "$srcdir/opencl"
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/rocm/opencl -DCLANG_ENABLE_STATIC_ANALYZER=ON ..
make
}
package() {
cd "$srcdir/opencl/build"
make DESTDIR="$pkgdir/" install
# OpenCL vendor file
mkdir -p "$pkgdir/etc/OpenCL/vendors"
echo "/opt/rocm/opencl/lib/x86_64/libamdocl64.so" > "$pkgdir/etc/OpenCL/vendors/rocm-opencl64.icd"
mkdir -p "$pkgdir/etc/ld.so.conf.d/"
echo "/opt/rocm/opencl/lib" > "$pkgdir/etc/ld.so.conf.d/rocm-opencl.conf"
ln -s "/opt/rocm/opencl/lib/libOpenCL.so.1.2" "$pkgdir/opt/rocm/opencl/lib/libOpenCL.so" # not created automatically by ldconfig
}
Copy link

ghost commented Feb 14, 2019

I was having issues where build failed at 97% on "Building CXX object runtime/CMakeFiles/oclruntime.dir/device/devprogram.cpp". The error included not being able to find a few specific headers. The quick fix was to just build the headers first and then run the build. After looking around a bit I saw the ROCm Experimental scripts were multithreading the build and when I tried all the errors went away. If you replace the make in build() section with code below everything works on my system 2.0.x and 2.1.x

MEM_AVAIL=`cat /proc/meminfo | grep MemTotal | awk {'print $2'}`
AVAIL_THREADS=`nproc`
MAX_THREADS=`echo $(( ${MEM_AVAIL} / $(( 1024 * 1024 * 4 )) ))`
if [ ${MAX_THREADS} -lt ${AVAIL_THREADS} ]; then
    NUM_BUILD_THREADS=${MAX_THREADS}
else
    NUM_BUILD_THREADS=${AVAIL_THREADS}
fi
if [ ${NUM_BUILD_THREADS} -lt 1 ]; then
    NUM_BUILD_THREADS=1
fi
make -j ${NUM_BUILD_THREADS}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment