File PKGBUILD of Package chipstar-src
# pkgname=chipstar-llvm
# pkgname=chipstar
pkgver=20000000
pkgrel=2
pkgdesc="A tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs."
arch=('x86_64')
url="https://github.com/CHIP-SPV/chipStar"
license=('MIT')
depends=('opencl-icd-loader' 'level-zero-loader' 'spirv-tools' 'intel-oneapi-basekit')
# git is required to obtain the version
# vim is installed for `xxd`
makedepends=('vim' 'git' 'python-yaml' 'level-zero-headers' 'spirv-tools' 'opencl-headers' 'doxygen')
# Expand this if manually for build in OBS
if [[ "$pkgname" != *llvm* ]]; then
depends+=('chipstar-llvm') # Expand this into the original line for build in OBS
makedepends+=('chipstar-llvm') # Expand this into the original line for build in OBS
provides=('chipstar')
conflicts=('chipstar')
else
provides=('chipstar-llvm')
conflicts=('chipstar-llvm')
fi
options=(!lto !debug staticlibs)
# Manually preparing the source
#
# wget https://github.com/Kitware/CMake/releases/download/v3.31.8/cmake-3.31.8-linux-x86_64.tar.gz
#
# git clone --depth=1 https://github.com/CHIP-SPV/chipStar.git
# cd chipStar
# git submodule update --init --recursive
# export CHIPSTAR_LLVM_DIR=/opt/chipStar/llvm
# cp /bin/echo bin/cmake
# PATH="$PWD/bin:$PATH" ./scripts/configure_llvm.sh --version 20 --install-dir $CHIPSTAR_LLVM_DIR
# rm bin/cmake
# cd ..
# tar czf chipStar.tar.gz chipStar
#
# git clone https://github.com/KhronosGroup/SPIRV-Headers.git
# cd SPIRV-Headers
# git checkout $(cat ../chipStar/llvm-project/llvm/projects/SPIRV-LLVM-Translator/spirv-headers-tag.conf)
# cd ..
# tar czf SPIRV-Headers.tar.gz SPIRV-Headers
source=('chipStar.tar.gz' 'cmake-3.31.8-linux-x86_64.tar.gz' 'SPIRV-Headers.tar.gz' 'hipblas.bundle' 'hipfft.bundle' 'hipsolver.bundle')
md5sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')
pkgver() {
cd "$srcdir/chipStar"
git log -1 --format=%cd --date=format:%Y%m%d
}
# prepare() {
# }
build() {
MAKEFLAGS=-j8 # OpenSUSE build service seems not providing MAKEFLAGS
export CC=clang
export CXX=clang++
export CHIPSTAR_DIR=/opt/chipStar
export CHIPSTAR_LLVM_DIR=/opt/chipStar/llvm
export PATH=$srcdir/cmake-3.31.8-linux-x86_64/bin:$PATH
if [[ "$pkgname" == *llvm* ]]; then
cd "$srcdir"
cmake \
-B build_llvm -S $srcdir/chipStar/llvm-project/llvm/ -G 'Unix Makefiles' \
-DCMAKE_INSTALL_PREFIX=${CHIPSTAR_LLVM_DIR} \
-DCMAKE_BUILD_TYPE="Release" \
-DLLVM_ENABLE_PROJECTS="clang;openmp;clang-tools-extra" \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_EXPERIMENTAL_TARGETS_TOBUILD="SPIRV" \
-DLLVM_ENABLE_ASSERTIONS=On \
-DCLANG_DEFAULT_PIE_ON_LINUX=off \
-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR="$srcdir/SPIRV-Headers"
cd "$srcdir/build_llvm"
make $MAKEFLAGS && make DESTDIR="$srcdir/" install
else
. /opt/intel/oneapi/setvars.sh
cd "$srcdir"
sed -i "s%GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/hipblas%GIT_REPOSITORY $srcdir/hipblas.bundle%" chipStar/H4I-HipBLAS/src/CMakeLists.txt
sed -i "s%GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/hipfft%GIT_REPOSITORY $srcdir/hipfft.bundle%" chipStar/H4I-HipFFT/src/CMakeLists.txt
sed -i "s%GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/hipsolver%GIT_REPOSITORY $srcdir/hipsolver.bundle%" chipStar/H4I-HipSOLVER/src/CMakeLists.txt
cmake \
-B build -S chipStar -G 'Unix Makefiles' \
-Wno-dev -DCMAKE_BUILD_TYPE:STRING='Release' \
-DBUILD_TESTING:BOOL='OFF' \
-DCHIP_BUILD_TESTS:BOOL='OFF' \
-DCHIP_BUILD_SAMPLES:BOOL='ON' \
-DCMAKE_INSTALL_PREFIX:PATH="$CHIPSTAR_DIR" \
-DLLVM_CONFIG_BIN="$CHIPSTAR_LLVM_DIR/bin/llvm-config" \
-DCHIP_BUILD_HIPBLAS=ON \
-DCHIP_BUILD_HIPFFT=ON \
-DCHIP_BUILD_HIPSOLVER=ON \
-DCHIP_BUILD_DOCS=ON \
-DCMAKE_C_COMPILER_PATH="$CHIPSTAR_LLVM_DIR/bin/clang" \
-DCLANG_COMPILER_PATH="$CHIPSTAR_LLVM_DIR/bin/clang++" \
-DCMAKE_CXX_COMPILER_PATH="$CHIPSTAR_LLVM_DIR/bin/clang++" \
-DMKL_ROOT=/opt/intel/oneapi/mkl/latest \
-DICPX_EXECUTABLE=/opt/intel/oneapi/compiler/latest/bin/icpx \
-DINTEL_COMPILER_PATH=/opt/intel/oneapi/compiler/latest/bin/icpx \
-DIntelSYCL_DIR=/opt/intel/oneapi/compiler/latest/lib/cmake/IntelSYCL \
-DOpenCL_DIR=/opt/intel/oneapi/compiler/latest/lib \
-DOpenCL_INCLUDE_DIR=/opt/intel/oneapi/compiler/latest/include \
-DSYCL_PACKAGE_DIR=/opt/intel/oneapi/compiler/latest \
-DCHIP_SET_RPATH=ON
cd build
make $MAKEFLAGS
fi
}
package() {
if [[ "$pkgname" == *llvm* ]]; then
cd "$srcdir/build_llvm"
make DESTDIR="$pkgdir/" install
else
cd "$srcdir/build"
make DESTDIR="$pkgdir/" install
sed -i 's!^HIP_CLANG_PATH.*!HIP_CLANG_PATH=/opt/chipStar/llvm/bin!' "$pkgdir/opt/chipStar/share/.hipInfo"
fi
}
# vim:set ts=2 sw=2 et: