summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7421c39a3c882d004d9d6294ec181b41427c40a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Maintainer: Ulysses R. Ribeiro <ulyssesrr@gmail.com>

pkgname=llama-cpp-rocm-git
pkgver=r1110.423db74
pkgrel=1
pkgdesc="Port of Facebook's LLaMA model in C/C++ (with ROCm) (PR#1087)"
arch=('x86_64')
url="https://github.com/ggerganov/llama.cpp"
_reponame="llama.cpp"
license=("MIT")
depends=('hipblas')
makedepends=('git' 'rocm-llvm')
conflicts=('llama.cpp' 'llama-cpp')
provides=('llama.cpp' 'llama-cpp')
source=("$_reponame::git+${url}")
sha256sums=('SKIP')

prepare() {
  cd "$srcdir/$_reponame"
  git fetch origin pull/1087/head:hipblas
  git checkout hipblas
}

pkgver() {
  cd "$srcdir/$_reponame"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

build() {
  cd "$srcdir/$_reponame"
  
  # Compile source code for supported GPU archs in parallel
  export HIPCC_COMPILE_FLAGS_APPEND="-parallel-jobs=$(nproc)"
  export HIPCC_LINK_FLAGS_APPEND="-parallel-jobs=$(nproc)"
  # -fcf-protection is not supported by HIP, see
  # https://rocm.docs.amd.com/en/latest/reference/rocmcc/rocmcc.html#support-status-of-other-clang-options
  PATH="/opt/rocm/llvm/bin:/opt/rocm/bin:${PATH}" \
  CXXFLAGS="${CXXFLAGS} -fcf-protection=none" \

  export CC=/opt/rocm/llvm/bin/clang
  export CXX=/opt/rocm/llvm/bin/clang++
  
  cmake -B ./build \
    -Wno-dev \
    -S . \
    -DCMAKE_INSTALL_PREFIX="${pkgdir}/usr" \
    -DCMAKE_BUILD_TYPE=Release \
    -DLLAMA_HIPBLAS=ON \
    -DAMDGPU_TARGETS="$(/opt/rocm/llvm/bin/amdgpu-arch)"

  cmake --build ./build
}

package() {
  cd "$srcdir/$_reponame"

  cmake --install ./build

  cd "${pkgdir}/usr/bin/"
  for filename in *; do
    mv "$filename" "$_reponame-${filename}"
  done
  
  mv "${pkgdir}/usr/bin/$_reponame-main" \
    "${pkgdir}/usr/bin/$_reponame"
}