summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4d4f7a8d3ba50df6baf79f8f9d83cd32934b62e1 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Maintainer: Anton Kudelin <kudelin at proton dot me>

pkgname=elpa
pkgver=2024.05.001
_pkgver=${pkgver}
pkgrel=1
arch=(x86_64 aarch64)
pkgdesc="Eigenvalue SoLvers for Petaflop-Applications"
url="https://elpa.mpcdf.mpg.de"
license=(LGPL-3.0-only)
makedepends=(gcc-fortran cython vim)
depends=(scalapack python-numpy python-mpi4py)
checkdepends=(blas-openblas)
source=($url/software/tarball-archive/Releases/$pkgver/$pkgname-$_pkgver.tar.gz)
sha256sums=('9caf41a3e600e2f6f4ce1931bd54185179dade9c171556d0c9b41bbc6940f2f6')
options=(!makeflags !buildflags)

prepare() {
  # Detecting vectorization compatibility
  _AVXCOMP=$( $CC -march=native -dM -E - < /dev/null \
    | grep -E "AVX" | sort -d | tail -n 1 | awk -F'_' '{print $3}' )
  case $_AVXCOMP in
    AVX512*)
      _AVX=yes
      _AVX2=yes
      _AVX512=yes
      echo "Full vectorization is enabled"
      ;;
    AVX2)
      _AVX=yes
      _AVX2=yes
      _AVX512=no
      echo "Improved vectorization is enabled"
      ;;
    AVX)
      _AVX=yes
      _AVX2=no
      _AVX512=no
      echo "Basic vectorization is enabled"
      ;;
    *)
      _AVX=no
      _AVX2=no
      _AVX512=no
      echo "No advanced vectorization is enabled"
      ;;
  esac
  # SSE is always enabled on x86_64 architecture
  _SSE=yes

  # Checking CPU architecture
  if [ $CARCH == 'aarch64' ];
  then
    _SSE=no
    _AVX=no
    _AVX2=no
    _AVX512=no
    echo "No vectorization is enabled"
  fi

  # Python version
  _python_version=$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')

  # Python 3 semantics
  sed -i "s@cython@cython -3@" "$srcdir/$pkgname-$pkgver/Makefile.am"

  cd "$srcdir/$pkgname-$pkgver"
  autoreconf -if
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  ./configure \
    --prefix=/usr \
    --enable-openmp \
    --enable-sse=$_SSE \
    --enable-sse-assembly=$_SSE \
    --enable-avx=$_AVX \
    --enable-avx2=$_AVX2 \
    --enable-avx512=$_AVX512 \
    --enable-autotune-redistribute-matrix \
    --enable-python \
    --enable-scalapack-tests \
    --without-threading-support-check-during-build \
    FC="mpifort" \
    CFLAGS="-O2 -march=native" \
    FCFLAGS="-O2 -march=native -fallow-argument-mismatch" \
    LIBS="-lscalapack -lblas -llapack -lmpi" \
    PYTHON_INCLUDE="-I/usr/include/python$_python_version"
  make
}

check() {
  cd "$srcdir/$pkgname-$pkgver"
  make check
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  make DESTDIR="$pkgdir" install
}