Skip to content

Instantly share code, notes, and snippets.

@JaHIY
Last active October 20, 2023 08:18
Show Gist options
  • Save JaHIY/188d8de65966342bc7c1097c11d2de2a to your computer and use it in GitHub Desktop.
Save JaHIY/188d8de65966342bc7c1097c11d2de2a to your computer and use it in GitHub Desktop.
AUR PKGBUILD for CP2K 2023.2
CC = gcc
CXX = g++
CPP =
FC = mpifort
LD = mpifort
AR = ar -r
DFLAGS = -D__FFTW3 \
-D__LIBINT \
-D__parallel -D__ELPA -D__COSMA -D__SCALAPACK \
-D__LIBXSMM \
-D__LIBXC \
-D__SPGLIB
INCS = -I/usr/include \
-I/usr/include/elpa_openmp-$(_elpaver)/elpa \
-I/usr/include/elpa_openmp-$(_elpaver)/modules
OPTFLAGS = -O3 -march=native -fopenmp
CFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS)
CXXFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) -std=c++11
CPPFLAGS =
FCFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) \
-ffree-form -ffree-line-length-none \
-fallow-argument-mismatch
LDFLAGS = $(FCFLAGS)
LIBS = -lxsmmf -lxsmm -lelpa_openmp \
-lcosma_prefixed_pxgemm -lcosma -lcosta \
-lscalapack -lblas -llapack \
-lfftw3 -lfftw3_threads \
/usr/lib/libint2.a \
-lxcf03 -lxc \
-lsymspg \
-lstdc++ -lpthread -lm -ldl -lz
CC = gcc
CXX = g++
CPP =
FC = mpifort
LD = mpifort
NVCC = nvcc
GPUVER = $(_gpuver)
AR = ar -r
DFLAGS = -D__FFTW3 \
-D__LIBINT \
-D__parallel -D__ELPA -D__COSMA -D__SCALAPACK \
-D__LIBXSMM \
-D__LIBXC \
-D__SPGLIB \
-D__DBCSR_ACC -D__PW_CUDA -D__GRID_CUDA
INCS = -I/usr/include \
-I/usr/include/elpa_openmp-$(_elpaver)/elpa \
-I/usr/include/elpa_openmp-$(_elpaver)/modules \
-I/opt/cuda/include
OPTFLAGS = -O3 -march=native -fopenmp
CFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS)
CXXFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) -std=c++11
CPPFLAGS =
FCFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) \
-ffree-form -ffree-line-length-none \
-fallow-argument-mismatch
NVFLAGS = $(DFLAGS) -O3 -Xcompiler="-fopenmp" \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_86,code=sm_86 \
-Wno-deprecated-gpu-targets
LDFLAGS = $(FCFLAGS)
LIBS = -L/opt/cuda/lib64 -lcudart -lcuda \
-lcublas -lcufft -lrt -lnvrtc \
-lxsmmf -lxsmm -lelpa_openmp \
-lcosma_prefixed_pxgemm -lcosma -lcosta -lTiled-MM \
-lscalapack -lblas -llapack \
-lfftw3 -lfftw3_threads \
/usr/lib/libint2.a \
-lxcf03 -lxc \
-lsymspg \
-lstdc++ -lpthread -lm -ldl -lz
CC = gcc
CXX = g++
CPP =
FC = mpifort
LD = mpifort
NVCC = nvcc
GPUVER = $(_gpuver)
AR = ar -r
DFLAGS = -D__FFTW3 \
-D__LIBINT \
-D__parallel -D__ELPA -D__COSMA -D__SCALAPACK \
-D__LIBXSMM \
-D__LIBXC \
-D__SPGLIB \
-D__DBCSR_ACC -D__PW_CUDA -D__GRID_CUDA \
-D__PLUMED2
INCS = -I/usr/include \
-I/usr/include/elpa_openmp-$(_elpaver)/elpa \
-I/usr/include/elpa_openmp-$(_elpaver)/modules \
-I/opt/cuda/include
OPTFLAGS = -O3 -march=native -fopenmp
CFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS)
CXXFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) -std=c++11
CPPFLAGS =
FCFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) \
-ffree-form -ffree-line-length-none \
-fallow-argument-mismatch
NVFLAGS = $(DFLAGS) -O3 -Xcompiler="-fopenmp" \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_86,code=sm_86 \
-Wno-deprecated-gpu-targets
LDFLAGS = $(FCFLAGS)
LIBS = -L/opt/cuda/lib64 -lcudart -lcuda \
-lcublas -lcufft -lrt -lnvrtc \
-lxsmmf -lxsmm -lelpa_openmp \
-lcosma_prefixed_pxgemm -lcosma -lcosta -lTiled-MM \
-lscalapack -lblas -llapack \
-lfftw3 -lfftw3_threads \
/usr/lib/libint2.a \
-lxcf03 -lxc \
-lsymspg \
-l$(_plumed) \
-lstdc++ -lpthread -lm -ldl -lz
include /usr/lib/$(_plumed)/src/lib/Plumed.inc
# Maintainer: Viktor Drobot (aka dviktor) <linux776 [at] gmail [dot] com>
# Maintainer: Anton Kudelin <kudelin [at] protonmail [dot] com>
# Contributor: Kars Wang <jaklsy [at] gmail [dot] com>
pkgname=cp2k
pkgver=2023.2
_dbcsrver=2.6.0
pkgrel=1
# NVIDIA GPU Generation: Kepler, Pascal, or Volta;
# please specify one closest to yours or leave unchanged
# if CUDA isn't supposed to be used
_GPU=Kepler
pkgdesc="A quantum chemistry and solid state physics software package"
arch=("x86_64")
url="https://www.cp2k.org"
license=("GPL2")
depends=('fftw' 'elpa' 'libxc>=5.0.0' 'libxsmm' 'spglib' 'cosma')
makedepends=('gcc-fortran' 'python' 'git' 'libint-cp2k')
checkdepends=('numactl')
optdepends=('cuda: GPU calculations support'
'plumed-mpi: enhanced sampling support')
provides=("$pkgname")
conflicts=("$pkgname-bin" "$pkgname-git" "$pkgname-data")
source=("$pkgname-$pkgver.tar.gz::https://github.com/cp2k/cp2k/archive/v$pkgver.tar.gz"
"git+https://github.com/cp2k/dbcsr.git#tag=v$_dbcsrver"
"basic.psmp"
"cuda_plumed.psmp"
"cuda.psmp"
"plumed.psmp")
sha256sums=('90b6d777aeac5e18f15dad4a61181c575ca023783d484740e2728a0e05169188'
'SKIP'
'9f573a24af68a89676cdc51dfdc8edfd55ed87ab189f4ebf632b2ca4552bfb1b'
'b54c9f1eb1cf968aa672e771f9f56770acc40d5a26ba0f1e58b20d6ab1797eb1'
'504df2b2ab5415ac56807933ae499f2ed0cfdbac9eb8f0a2440387f1f2411911'
'ea915cb5d50a4aa86695679ccd46d7aa56f8ff8c81a862403b3e1a89ca2b4a90')
prepare() {
# Set up the default build environment
export _buildmode=0
export _arch="basic"
export _elpaver="$(find /usr/include -maxdepth 1 -name 'elpa_openmp-*' -printf '%f\n' | sed 's/elpa_openmp-//')"
export _plumed="$(find /usr/lib -maxdepth 1 -type d -name 'plumed-mpi')"
export _corenumber="$(grep -c '^processor' /proc/cpuinfo)"
# Enabling additional features
if which nvcc >/dev/null 2&>1; then
_gpumem="$(nvidia-smi --query-gpu=memory.total --format=csv,nounits,noheader)"
# Tests require at least 150 MB of GPU memory per core
_memcore="$(($_gpumem / 150))"
if [ "$_memcore" -ge 2 ]; then
echo "Adding CUDA support"
_buildmode="$(($_buildmode | 1))"
if [ "$_corenumber" -gt "$_memcore" ] ; then
_corenumber="$_memcore"
fi
fi
fi
if [ -n "$_plumed" ]; then
echo "Adding PLUMED support"
_buildmode="$(($_buildmode | 2))"
fi
case "$_buildmode" in
0)
_arch="basic"
;;
1)
_arch="cuda"
;;
2)
_arch="plumed"
;;
3)
_arch="cuda_plumed"
;;
esac
case "$_GPU" in
Kepler)
export _gpuver=K20X
;;
Pascal)
export _gpuver=P100
;;
Volta)
export _gpuver=V100
;;
esac
# Move arch-file into a proper directory
cd "$srcdir/$pkgname-$pkgver"
mv ../"$_arch.psmp" arch
# Changing the location of the data directory
sed -i 's@$(CP2KHOME)/data@/usr/share/cp2k/data@g' Makefile
# Prepare DBCSR
cp -r ../dbcsr exts
cd exts/dbcsr
git submodule update --init --recursive
}
build() {
cd "$srcdir/$pkgname-$pkgver"
make ARCH="$_arch" VERSION=psmp
}
check() {
cd "$srcdir/$pkgname-$pkgver/tools/regtesting"
export CP2K_DATA_DIR="$srcdir/$pkgname-$pkgver/data"
# In the case of a test failure you must examine it carefully
# because it can lead to an unpredictable error during a production run.
./do_regtest.py \
--workbasedir ../.. \
--maxtasks $_corenumber \
--timeout 1000 \
--smoketest \
$_arch \
psmp
}
package() {
cd "$pkgdir"
install -dm755 usr/{bin,share/"$pkgname"}
cd "$srcdir/$pkgname-$pkgver/exe/$_arch"
install -Dm755 cp2k.psmp "$pkgdir/usr/bin/cp2k"
install -Dm755 cp2k_shell.psmp "$pkgdir/usr/bin/cp2k-shell"
install -Dm755 graph.psmp "$pkgdir/usr/bin/cp2k-graph"
cp -r ../../data "$pkgdir/usr/share/$pkgname"
chmod -R 755 "$pkgdir/usr/share/$pkgname"
}
CC = gcc
CXX = g++
CPP =
FC = mpifort
LD = mpifort
AR = ar -r
DFLAGS = -D__FFTW3 \
-D__LIBINT \
-D__parallel -D__ELPA -D__COSMA -D__SCALAPACK \
-D__LIBXSMM \
-D__LIBXC \
-D__SPGLIB \
-D__PLUMED2
INCS = -I/usr/include \
-I/usr/include/elpa_openmp-$(_elpaver)/elpa \
-I/usr/include/elpa_openmp-$(_elpaver)/modules
OPTFLAGS = -O3 -march=native -fopenmp
CFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS)
CXXFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) -std=c++11
CPPFLAGS =
FCFLAGS = $(DFLAGS) $(INCS) $(OPTFLAGS) \
-ffree-form -ffree-line-length-none \
-fallow-argument-mismatch
LDFLAGS = $(FCFLAGS)
LIBS = -lxsmmf -lxsmm -lelpa_openmp \
-lcosma_prefixed_pxgemm -lcosma -lcosta \
-lscalapack -lblas -llapack \
-lfftw3 -lfftw3_threads \
/usr/lib/libint2.a \
-lxcf03 -lxc \
-lsymspg \
-l$(_plumed) \
-lstdc++ -lpthread -lm -ldl -lz
include /usr/lib/$(_plumed)/src/lib/Plumed.inc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment