summaryrefslogtreecommitdiff
blob: a0d1bba614529dc0ba006832e3c5aa81d1990cad (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{10..12} )
DISTUTILS_OPTIONAL=1
DISTUTILS_USE_PEP517=setuptools
CMAKE_MAKEFILE_GENERATOR=emake
# Doc building insists on fetching mathjax
# DOCS_BUILDER="doxygen"
# DOCS_DEPEND="
# 	media-gfx/graphviz
# 	dev-libs/mathjax
# "

inherit cmake fortran-2 distutils-r1 # docs

convert_month() {
	local months=( "" Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec )
	echo ${months[${1#0}]}
}

MY_PV="$((10#${PV:6:2}))$(convert_month ${PV:4:2})${PV:0:4}"
MY_P="${PN}-stable_${MY_PV}"

DESCRIPTION="Large-scale Atomic/Molecular Massively Parallel Simulator"
HOMEPAGE="https://www.lammps.org"
SRC_URI="
	https://github.com/lammps/lammps/archive/refs/tags/stable_${MY_PV}.tar.gz
	test? (
		https://github.com/google/googletest/archive/release-1.12.1.tar.gz -> ${PN}-gtest-1.12.1.tar.gz
	)
"
S="${WORKDIR}/${MY_P}/cmake"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ~x86"
IUSE="cuda examples extra gzip hip lammps-memalign mpi opencl openmp python test"
# Requires write access to /dev/dri/renderD...
RESTRICT="test"

RDEPEND="
	app-arch/gzip
	media-libs/libpng:0
	sys-libs/zlib
	mpi? (
		virtual/mpi
		sci-libs/hdf5:=[mpi]
	)
	python? ( ${PYTHON_DEPS} )
	sci-libs/voro++
	virtual/blas
	virtual/lapack
	sci-libs/fftw:3.0=
	sci-libs/netcdf:=
	cuda? ( >=dev-util/nvidia-cuda-toolkit-4.2.9-r1:= )
	opencl? ( virtual/opencl )
	hip? (
		dev-util/hip:=
		sci-libs/hipCUB:=
	)
	dev-cpp/eigen:3
	"
	# Kokkos-3.5 not in tree atm
	# kokkos? ( dev-cpp/kokkos-3.5.* )
BDEPEND="${DISTUTILS_DEPS}"
DEPEND="${RDEPEND}
	test? (
		dev-cpp/gtest
		dev-libs/libyaml
	)
"

REQUIRED_USE="
	python? ( ${PYTHON_REQUIRED_USE} )
	?? ( cuda opencl hip )
"

src_prepare() {
	cmake_src_prepare
	if use python; then
		pushd ../python || die
		distutils-r1_src_prepare
		popd || die
	fi
	if use test; then
		mkdir "${BUILD_DIR}/_deps"
		cp "${DISTDIR}/${PN}-gtest-1.12.1.tar.gz" "${BUILD_DIR}/_deps/release-1.12.1.tar.gz"
	fi
}

src_configure() {
	local mycmakeargs=(
		-DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc"
		-DBUILD_SHARED_LIBS=ON
		-DBUILD_MPI=$(usex mpi)
		-DBUILD_DOC=OFF
		#-DBUILD_DOC=$(usex doc)
		-DENABLE_TESTING=$(usex test)
		-DPKG_ASPHERE=ON
		-DPKG_BODY=ON
		-DPKG_CLASS2=ON
		-DPKG_COLLOID=ON
		-DPKG_COMPRESS=ON
		-DPKG_CORESHELL=ON
		-DPKG_DIPOLE=ON
		-DPKG_EXTRA-COMPUTE=$(usex extra)
		-DPKG_EXTRA-DUMP=$(usex extra)
		-DPKG_EXTRA-FIX=$(usex extra)
		-DPKG_EXTRA-MOLECULE=$(usex extra)
		-DPKG_EXTRA-PAIR=$(usex extra)
		-DPKG_GRANULAR=ON
		-DPKG_KSPACE=ON
		-DFFT=FFTW3
		-DPKG_KOKKOS=OFF
		#-DPKG_KOKKOS=$(usex kokkos)
		#$(use kokkos && echo -DEXTERNAL_KOKKOS=ON)
		-DPKG_MANYBODY=ON
		-DPKG_MC=ON
		-DPKG_MEAM=ON
		-DPKG_MISC=ON
		-DPKG_MOLECULE=ON
		-DPKG_OPENMP=$(usex openmp)
		-DPKG_PERI=ON
		-DPKG_QEQ=ON
		-DPKG_REPLICA=ON
		-DPKG_RIGID=ON
		-DPKG_SHOCK=ON
		-DPKG_SRD=ON
		-DPKG_PYTHON=$(usex python)
		-DPKG_MPIIO=$(usex mpi)
		-DPKG_VORONOI=ON
	)
	if use cuda || use opencl || use hip; then
		mycmakeargs+=( -DPKG_GPU=ON )
		use cuda && mycmakeargs+=( -DGPU_API=cuda )
		use opencl && mycmakeargs+=( -DGPU_API=opencl -DUSE_STATIC_OPENCL_LOADER=OFF )
		use hip && mycmakeargs+=( -DGPU_API=hip -DHIP_PATH="${EPREFIX}/usr" )
	else
		mycmakeargs+=( -DPKG_GPU=OFF )
	fi
	cmake_src_configure
	if use python; then
		pushd ../python || die
		distutils-r1_src_configure
		popd || die
	fi
}

src_compile() {
	cmake_src_compile
	if use python; then
		pushd ../python || die
		distutils-r1_src_compile
		popd || die
	fi
}

src_test() {
	cmake_src_test
	if use python; then
		pushd ../python || die
		distutils-r1_src_test
		popd || die
	fi
}

src_install() {
	cmake_src_install

	if use opencl; then
		dobin "${BUILD_DIR}/ocl_get_devices"
	fi

	if use python; then
		pushd ../python || die
		distutils-r1_src_install
		popd || die
	fi

	if use examples; then
		for d in examples bench; do
			local LAMMPS_EXAMPLES="/usr/share/${PN}/${d}"
			insinto "${LAMMPS_EXAMPLES}"
			doins -r "${S}"/../${d}/*
		done
	fi
}